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.
This article will show you how to automate the process of building and deploying single-container images with Buddy. The multi-container version of the article is available here.
Set a 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 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 static HTML site displayed with NGINX.
- 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: if you open your application in Elastic Beanstalk you'll see it's being updated. Once the update is over, open the app to see the "Hello World" page.
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