Multi-Container Docker Platform AWS EB
If your application consists of only one container, all you need is a Dockerfile in the repository: Elastic Beanstalk will use it to build the image and run the container with application.
However, if your app consists of more than one container (eg. you need to use docker compose to run it), then you need to add Dockerrun.aws.json
with the configuration of your containers. Of course, the images must be built and pushed to the public registry first .
This article will show you how to automate the whole process with Buddy. We have covered the single-container configuration in a separate article.
Set a Multi-Docker application in Elastic Beanstalk
- Log in to your AWS account
- Go to the Elastic Beanstalk service
Add the application:
- Select Web server as the Tier
Select Multi-container Docker as the Platform
Copy the Access key and the Secret key
To automate the deployment you need a user with the permission AWSElasticBeanstalkFullAccess
so you can copy their Access and Secret keys. To create such user do the following:
- Log in to your AWS account
- Go to Users and click Add user
Set the access type to
Programmatic Access
- Look up and add
AWSElasticBeanstalkFullAccess
permission Once the user is added, download the CSV with its access details
Configure a pipeline in Buddy
Now you can create a pipeline that automatically build a Docker image on push to the repository, push it to the Docker Hub and deploy to Elastic Beanstalk. In this example we'll use this repository, a Node.JS app with Redis.
- Add a new project in Buddy and select GitHub as the provider.
Choose the repository from the list:
- Add a new pipeline and set the trigger mode to On every push:
Add the Docker build action that will build and push your image to the registry:
Add the Upload to ElasticBeanstalk action
- Copy and paste the Access and Secret keys from your AWS account
- Select your AWS region and Application
Select Repository as the deployment source
When you're ready, make a push and watch Buddy build and deploy your Docker image.
Notes:
- You can add an action that will build and test your application before deploying it to Elastic Beanstalk as a Docker image. In this case select the Filesystem as the source in the deployment action.
- If you have more than one Dockerfile in the app, you can add a build action for every image.
Last modified on April 26, 2022