amazon-ecs-cli icon indicating copy to clipboard operation
amazon-ecs-cli copied to clipboard

compose different environments

Open esetnik opened this issue 10 years ago • 12 comments

docker-compose expose the -f switch to load one or more docker-compose override files. Is there something similar for ecs-cli?

esetnik avatar Jan 06 '16 06:01 esetnik

It seems to me that #129 is a duplicate of this. It would be really great to make ecs-cli support multiple -f.

In the meantime, there is a workaround : docker-compose has a validation command that shows the yaml files' concatenation in the console :

docker-compose -f docker-compose.file1.yml -f docker-compose.file2.yml config will output the concatenation of docker-compose.file1.yml and docker-compose.file2.yml.

floostmodern avatar Aug 03 '16 12:08 floostmodern

Hi, I have just started using AWS for running docker and this is the first issue i encountered, is there any update on this? The workaround suggested by @floostmodern is good and can be put in a bash script to capture the output to a new file and execute the ecs-cli command with that file, but it would be better if the workaround was not required. Thanks

chrisckc avatar Mar 01 '17 17:03 chrisckc

While it is true that docker-compose -f docker-compose.file1.yml -f docker-compose.file2.yml config will output the merged config for all the given override files, the resulting file:

  • is not valid YAML
  • is not valid docker-compose format
  • is not consumable by ecs-cli
  • requires additional touch-ups before it can be successfully to ecs-cli

I don't really see this as a valid work-around for this. If this feature is not to be supported, it would be helpful to show an error when ecs-cli is run with this type of syntax (today this is allowed, seems to work but silently fails): ecs-cli compose -f docker-compose.yml -f docker-compose.override-aws.yml -p MyProject create

PeterRJones avatar Mar 11 '17 01:03 PeterRJones

We require this functionality as well to set a few environment/stage/cluster specific options for our containers. While we could potentially configure them with environment variables as well, it is much more inline with our development workflow to merge and overwrite them using different files.

We normally run services like this: $ docker-compose -f service.yml -f stage.yml up/run

While the workaround by @floostmodern works for now, it would be great if ecs-cli supported this functionality natively. Especially since, as @PeterRJones mentioned, the output cannot be used directly and needs to be cleaned up first.

jdno avatar Mar 13 '17 08:03 jdno

Building on what @floostmodern said, this works for me temporarily.

Full Command:

docker-compose -f docker-compose.yml -f docker-compose.production.yml config | sed "s/version: '2.0'/version: 2/" | ecs-cli compose --verbose --file /dev/stdin create

I tend to shorten it like so:

alias docker-compose-prod='docker-compose -f docker-compose.yml -f docker-compose.production.yml'
alias docker-compose-prod-config="docker-compose-prod config | sed \"s/version: '2.0'/version: 2/\""
alias ecs-cli-compose="docker-compose-prod-config | ecs-cli compose --file /dev/stdin --project-name $(basename $(pwd))"

Usage:

Just replace "ecs-cli compose" with "ecs-cli-compose".

ecs-cli help
ecs-cli-compose help
ecs-cli-compose create
ecs-cli-compose ps

AlJohri avatar Mar 30 '17 19:03 AlJohri

You can now run ecs-cli compose up with multiple compose files with the latest commit. This will be included in the next release.

yinshiua avatar Jun 28 '17 20:06 yinshiua

@yinshiua Great! When is the next release is scheduled?

timwah avatar Jul 11 '17 17:07 timwah

Looks like it was included in the following release (according to the release notes): https://github.com/aws/amazon-ecs-cli/releases/tag/v0.6.1

jfroom avatar Sep 13 '17 23:09 jfroom

I am still having this issue in v0.6.5... Is there any update on this? Was this feature removed after v0.6.1?

rogersgt avatar Oct 05 '17 14:10 rogersgt

this doesnt work for me with latest client: ecs-cli compose --file docker-compose.yml --file docker-compose-aws.yml service up

so how to define multiple files? the overridden settings in my second file wont get picked up.

logemann avatar Sep 15 '18 11:09 logemann

@logemann Are you sure you are using the latest ecs-cli? The above example does work for me. If you run with —debug what task definition does it spit out?

esetnik avatar Sep 15 '18 14:09 esetnik

cant see a debug parameter. Tried several ways without luck. My ecs-cli version is 1.8

logemann avatar Oct 05 '18 12:10 logemann