29

I am having trouble getting my docker elastic beanstalk deploy to read my .ebextensions/setup.config file.

The documentation for eb environment configuration says:

You can include one or more configuration files with your source bundle. Configuration files must be named with the extension .config (for example, myapp.config) and placed in an .ebextensions top-level directory in your source bundle.

However it looks like for Docker that the source bundle is not a .zip or .war file, but a .json file, e.g., the docs say to create a Dockerrun.aws.json file—and it looks like that is the source bundle?

In creating a version of the app I upload a custom Dockerrun-$VERSION.aws.json file to s3 and the run something like the following (where $APP is the versioned dockerrun json file):

aws elasticbeanstalk create-application-version \
    --application-name $APP_NAME \
    --version-label $VERSION \
    --source-bundle S3Bucket=$S3_BUCKET,S3Key=$S3_PATH/$APP

So… how is the .ebextensions directory going to be found in the top-level directory of the source bundle when the “bundle” is just a json file that ends up building a container? (My first attempt was to just put it in the root of the project, but that didn’t work.)

MrColes
  • 2,453
  • 1
  • 28
  • 38

1 Answers1

36

If you are using a .json file for docker deploys, then you cannot use .ebextensions.

You can however create a zip that contains your .json and your .ebextension directory and everything should work. Use the zip as your deployment artifact instead of the raw json.

Nick Humrich
  • 14,905
  • 8
  • 62
  • 85
  • 2
    Cool, worked fine, I ended up pointing to a zip as my source bundle instead and it contained just a `Dockerrun.aws.json` file and the `.ebextensions` directory with whatever config files I wanted. – MrColes Jun 24 '15 at 15:09
  • I am having trouble getting my config.json, with my keys in, onto the server without adding it to git. Do I take it that it explicitly avoids these and Ihave to zip it up ? – Mark Lester Dec 15 '15 at 09:35
  • @MarkLester I take it your using the cli. You can either zip it all up, or you can add a .ebignore file and ignore everything you dont want to deploy. Ebignore overrides gitignore, so you don't have to commit things – Nick Humrich Dec 15 '15 at 14:13
  • @NickHumrich thanks, yes am using eb deploy. if I have to zip i will zip, but where do I put that ?. but what i want is ebinclude, not an ignore, I just want it to get on with copying config.json to somewhere the server api wont see it, without sticking on github. – Mark Lester Dec 15 '15 at 14:50
  • @MarkLester you might just want to use an "artifact deploy". See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-configuration.html#eb-cli3-artifact – Nick Humrich Dec 15 '15 at 14:54
  • @NickHumrich OK, thats works a bit too well, all I have now is the config file. – Mark Lester Dec 15 '15 at 15:19
  • OK well if you want the config file as well, you either need to add a script that does the zip, and use the zip as the artifact, or you can use an ebignore file. For the ebignore file you can ignore everything then exclude the json and ebextensions directory. – Nick Humrich Dec 15 '15 at 23:10
  • @NickHumrich , MrColes can you please add some tutorial link, it will be helpful – Bikesh M Feb 22 '17 at 13:38
  • 1
    Doesn't appear to work. The eb-activity.log says it's unpacked a .zip from /opt/elasticbeanstalk/deploy/appsource/source_bundle but than complains Dockerfile and Dockerrun.aws.json are both missing. My buildspec post_build has the zip command, and lists that as artifact – Tom Chiverton Aug 20 '18 at 15:53
  • @TomChiverton did you manage to solve this? Im getting the same error – Oron Bendavid Jan 23 '23 at 11:06
  • Yes. our buildspec (for Pipeline) creates Dockerrun.aws.json (ports,volumes) and Dockerfile (FROM $REPOSITORY_URI:$IMAGE_TAG, EXPOSE ...). We have files in .ebextensions/ & .platform/. These are listed as wildcard artifacts.files in the buildspec (.ebextensions/**/*) – Tom Chiverton Jan 24 '23 at 09:47