Giter Club home page Giter Club logo

Comments (6)

jesseduffield avatar jesseduffield commented on April 28, 2024

interestingly my own company does something similar. We have a program that you can basically use in place of docker-compose and you're able to do it from any directory and it will work. So I made setting the docker-compose command configurable. You just need to do have:

commandTemplates:
  dockerCompose: 'custom-compose'

In your case it would be dockerCompose: 'docker-compose -f foo.yml

That satisfies my use case where we only ever really need to be in a single context, but it seems like you would need to change your 'dockerCompose' config value depending on your current context. I think making it a command-line arg makes sense, though I'm not sure what the best approach would be.

One approach would be to pass in the entire docker-compose command like

ld --dc "docker-compose -f foo.yml -f bar.yml"

This is the most flexible because it supports adding pretty much anything you want into that command, and allows as many -f arguments as you want. It's also simply because it will just replace the default docker-compose command from your config. But it might be annoying to have to write 'docker-compose' all the time when you're not somebody who has their own custom docker-compose program.

So maybe it should be that if you supply -f flags, each one is just going to be tacked onto whatever the docker-compose command is from the config. And then we'll wait and see if anybody needs more flexibility than that.

What are your thoughts?

from lazydocker.

mcintyre94 avatar mcintyre94 commented on April 28, 2024

Our use case is always just one docker-compose file at a time, I didn't actually realise you could pass multiple! So for me ld -f foo.yml would be perfect as opposed to ld --dc "docker compose -f foo.yml", and for the multiple files case multiple -f flags definitely sounds nicer if that works. I guess the other question would be whether there's any other docker-compose flags others would want to pass through though, since at some point it might be preferable to use the --dc approach than proxy multiple flags through.

BTW I'd be interested in tackling this as a learning exercise if it's not a burning issue for others :)

from lazydocker.

jesseduffield avatar jesseduffield commented on April 28, 2024

If you wanna have a crack be my guest :)
It turns out that the standard 'flag' package doesn't support using the same flag multiple times, but flaggy https://github.com/integrii/flaggy does, and from the looks of it it's not too hard to set up. We only parse a couple flags so far, and it's all in main.go, so I don't think it would be too hard to use that package. Then we'd need to pass in a dockerComposeFiles array of strings into config.NewAppConfig() (in the same way we currently pass in debuggingFlag) and then do something like this:

	if len(dockerComposeFiles) > 0 {
		userConfig.CommandTemplates.DockerCompose += "-f " + strings.Join(dockerComposeFiles, " -f ")
	}

How does that sound difficulty wise? If it's a bit daunting I'm happy to take care of the flaggy package part and leave you to actually dealing with the arg :)

from lazydocker.

mcintyre94 avatar mcintyre94 commented on April 28, 2024

Thanks for the pointers! Sounds like it should be doable, I’ll try to make a PR to move the existing code to Flaggy and then a separate one to add the multiple -f flags for this. I’m a newbie with Go so the PR might need a bit of feedback, and I’ll reach out on the Slack or here if I’m having trouble. I’ll see what I can do though! :)

from lazydocker.

markphip avatar markphip commented on April 28, 2024

FWIW, in my company we have a microservices based app and we use multiple docker-compose files for the various services. We have a local configuration file a dev can edit to decide which services they want to have running. You can dev/test parts of our app without having everything running and this just saves CPU and RAM. We have a shell script we use which reads the config file and then builds the list of docker-compose files to use. So it is just a simple script that mirrors the common docker-compose commands except it builds the -f option.

I was thinking maybe lazydocker could have an optional -f option that it would use to pass along to docker-compose? We could then just add an option to our shell script to run lazydocker with this option?

from lazydocker.

mcintyre94 avatar mcintyre94 commented on April 28, 2024

@markphip I think we have the same use case :) Just you need the multiple -f commands which validates that decision too.

from lazydocker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.