docker.el icon indicating copy to clipboard operation
docker.el copied to clipboard

Support for multiple compose files

Open maaroen opened this issue 5 years ago • 10 comments

Hello @Silex,

I'm trying to run some docker compose files with the Compose option, but if I use the -f to select a compose file I don't see the option to add multiple files.

In my case now I have a docker-compose and a docker-compose.override file which both need to be used at the same time.

Is this possible with the current implementation?

With kind regards,

Maaroen

maaroen avatar May 29 '20 09:05 maaroen

@maaroen: it's not supported directly but you can select one file then add the 2nd -f flag yourself.

So, in the popup you'd type "docker-compose.yml -f docker-compose.override" as the value for the -f flag.

Silex avatar May 29 '20 14:05 Silex

@Silex ah ok I'll use that for now, but I think it would be a nice feature to add extra ones with an additional command.

Thanks for your fast reply!

maaroen avatar May 29 '20 14:05 maaroen

@maaroen: with what interface tho?

@tarsius: do you have something in transient to input "multiple times the same flag"? Right now all I can suggest is the above.

The end command is cmd -f foo.yml -f bar.yml -f keke.yml.

EDIT: maybe some sort of read-file-name implementation wrapper that displays a prompt like select file (C-RET to enter another one, RET to finish) and then joins that list using -f .

Silex avatar May 30 '20 08:05 Silex

@Silex, Or you could make a sub interface in the mean time in which you can keep pressing the same - f untill you added all you wanted. Like

Docker-mode > compose -Ff and then something which shows options to add additional files or ready and back to compose menu. Not sure if it is possible tho.

Or perhaps a dired (like) window in which you can mark the files you want?

maaroen avatar May 30 '20 13:05 maaroen

Look at magit:--, which is used to pass a list of files to git log. Also look at the class of that: transient-files and in particular all the methods implemented for that class. You will likely have to create your own class and implement some of these generic functions slightly differently.

tarsius avatar May 30 '20 15:05 tarsius

@tarsius: thanks! will do.

Silex avatar May 30 '20 15:05 Silex

Is this discussion about

(docker-utils-transient-define-prefix docker-container-logs ()
  "Transient for showing containers logs."
  :man-page "docker-container-logs"
  ["Arguments"
   ("f" "Follow" "-f")          ; <--------- this argument?
   ("s" "Since" "--since " read-string)
   ("t" "Tail" "--tail " read-string)
   ("u" "Until" "--until " read-string)]
  [:description docker-utils-generic-actions-heading
   ("L" "Logs" docker-utils-generic-action-async)])

tarsius avatar Oct 29 '21 16:10 tarsius

(If not, then please point me to the thing that needs to be improved.)

tarsius avatar Oct 29 '21 16:10 tarsius

@tarsius: sorry, being a new father makes me really busy :sweat_smile:

This is about this https://github.com/Silex/docker.el/blob/master/docker-compose.el#L312:

(transient-define-prefix docker-compose ()
  "Transient for docker-compose."
  :man-page "docker-compose"
  ["Arguments"
   ("a" "No ANSI" "--no-ansi")
   ("c" "Compatibility" "--compatibility")
   ("d" "Project directory" "--project-directory " docker-compose-read-directory)
   ("f" "Compose file" "--file " docker-compose-read-compose-file)      ; <------ THIS
   ("h" "Host" "--host " read-string)
   ("l" "Log level" "--log-level " docker-compose-read-log-level)
   ("p" "Project name" "--project-name " read-string)
   ("v" "Verbose" "--verbose")]
  [["Images"
    ("B" "Build"      docker-compose-build)
    ("F" "Pull"       docker-compose-pull)
    ("P" "Push"       docker-compose-push)]
   ["Containers"
    ("C" "Create"     docker-compose-create)
    ("D" "Remove"     docker-compose-rm)
    ("U" "Up"         docker-compose-up)
    ("W" "Down"       docker-compose-down)]
   ["State"
    ("O" "Stop"       docker-compose-stop)
    ("S" "Start"      docker-compose-start)
    ("T" "Restart"    docker-compose-restart)]
   ["Other"
    ("R" "Run"        docker-compose-run)
    ("L" "Logs"       docker-compose-logs)
    ("E" "Exec"       docker-compose-exec)
    ("V" "Config"     docker-compose-config)]])

Basically, the resulting command can be (examples):

  • docker-compose run --rm someservice foobar
  • docker-compose -f dev.yml run --rm someservice foobar
  • docker-compose -f dev.yml -f with_env.yml run --rm someservice foobar
  • docker-compose -f dev.yml -f another_env.yml -f production_mailer.yml run --rm someservice foobar

That is, the -f argument can go from 0 to N files, but in practice it's often 0/1 or 2. This argument is only for docker-compose and then the subcommand (run) takes other flags etc.

Silex avatar Oct 31 '21 21:10 Silex

@noorul at the moment to use multiple compose file you press f then input foo.yml -f bar.yml.

I'm not sure it's even feasible as https://github.com/Silex/docker.el/blob/master/docker-compose.el#L317 doens't use read-string.

There's this discussion about how we'd support that at #169, but we basically wait on finding a transient way to do that.

Silex avatar Feb 09 '22 16:02 Silex