1

How do I setup/configure AWS Elastic Beanstalk's Docker Platform to run extensions (.ebextensions)? I cannot find any examples of this. There are several examples of the app running WITHOUT Docker but not WITH. Where do I put my extension files? How do they get executed? I've tried several different methods...it just doesn't seem feasible that beanstalk will reach into the docker image to pull out extension files to run and configure the OS.

I need to know how to configure the EC2 services such as NGINX web server parameters using .ebextensions.

How does this work? Is this a Pre/Post deploy step I need to do to configure the OS?

TylerH
  • 20,799
  • 66
  • 75
  • 101
chdev77
  • 505
  • 4
  • 18
  • How about this doc-tutorial? https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/docker.html – shimo Jul 22 '21 at 22:12
  • @shimo - Thanks Mate but this isn't exactly what I am after. I need to know how to configure the EC2 services such as NGINX web server parameters using .ebextensions. – chdev77 Jul 23 '21 at 01:03

1 Answers1

1

I think you're trying to solve an incorrect problem: you're supposed to deploy a Docker image that is already configured the way you need it. It would be best if you did not make any configuration changes during deployment. Doing so will tightly couple your Docker image behaviour to your deployment process, exposing you to a risk of having different behaviour between individual environments (local dev Docker vs. production EB Docker, fox example). Eliminating this risk is one of the reasons Docker exists in the first place.

To answer your question of "how to use .ebextensions in Docker platform:"

Long story short, assuming you have a pre-built Docker image, just create a zip file containing your docker-compose.yml and .ebextensions and use the zip file to deploy a new version.

You can find a complete answer in https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/single-container-docker-configuration.html#docker-configuration.remote-repo if you expand the "Using the AWS Systems Manager (SSM) Parameter Store" section.

Just in case the AWS website changed, here is the directory structure they propose:

├── .ebextensions
│   └── env.config
├── .platform
│   ├── confighooks
│   │   └── pre-build
│   │       └── 01login.sh
│   └── hooks
│       └── pre-build
│           └── 01login.sh
├── docker-compose.yml  

In this example, they are using .ebextensions to configure environment variables later used to log in to Docker Hub.

In your case, you can use a file in .ebextensions to either run commands or replace configuration files altogether. Check out Github repo with samples; it's an excellent source of inspiration. One of the examples in particular demonstrates how to update the Nginx configuration.

Alternatively, you can run any commands in your .platform/hooks directory.

The commands you want to run to tweak your Nginx configuration are, of course, docker exec ..., but I repeat, if you plan to tweak Nginx-in-Docker configuration on deploy, you're probably doing it wrong.

If you run your docker exec ... commands, you need to ensure you're running them on the correct containers. I can't give you further guidance in that regard as I have never done it this way, and, I repeat, I don't think you should do it this way.

Do share the solution if you find one.

Jan Klan
  • 667
  • 6
  • 16