This is apparently the only way to set ENV with dynamic values ββin a beanstalk. I came up with a workaround that works for my setup of several dockers:
1) Add this to your Docker file before creating + uploading to the ECS Repository:
CMD eval `cat /tmp/envs/env_file$`; <base image CMD goes here>;
2) In the Dockerrun.aws.json file, create a volume:
{ "name": "env-file", "host": { "sourcePath": "/var/app/current/envs" } }
3) Connect the volume to your container
{ "sourceVolume": "env-file", "containerPath": "/tmp/envs", "readOnly": true }
4) In the file .ebextensions / options.config add container_commands block like this:
container_commands: 01_create_mount: command: "mkdir -p envs/" 02_create_env_file: command: { "Fn::Join" : [ "", [ 'echo "', "export ENVIRONMENT_NAME=" , { "Ref", "RESOURCE" }, ';" > envs/env_file;' ] ] }
5) eb deploy and your ENVS should be available in your docker container
You can add additional ENVs by adding more container_ commands, for example:
02_create_env_file_2: command: { "Fn::Join" : [ "", [ 'echo "', "export ENVIRONMENT_NAME_2=" , { "Ref", "RESOURCE2" }, ';" >> envs/env_file;' \] \] }
Hope this helps!
dsorensen Nov 17 '16 at 0:32 2016-11-17 00:32
source share