Search code examples
amazon-web-servicesdockeramazon-elastic-beanstalkgithub-actionsdockerhub

How to pull a Docker image from DockerHub to Elastic Beanstalk?


I wanted to make a CI/CD with a project on Github using GitHub Actions. Used this tutorial:
https://www.blog.labouardy.com/elastic-beanstalk-docker-tips/
But I still do not understand how elastic beanstalk will pull the docker image from the DockerHub. How should this happen?
And why do we need a Dockerrun.aws.json file and how to use it?


Solution

  • There are different approaches that can be followed. The blogger chose to use the Dockerrun.aws.json + Dockerfile + zipfile approach. In other words, every time the CircleCI builds, it uploads a zip file containing the Dockerrun.aws.json (the Dockerfile is not really needed in this case since he's building the image remotely as well as the rest of the application since he's not mapping anything).

    The circleci executes the following steps:

    • build image
    • push image
    • send zip file to AWS Elastic Beanstalk

    AWS Elastic Beanstalk will simply follow the configuration inside the Dockerrun.aws.json and update using the tag ${CIRCLE_SHA1}.

    Is the Dockerrun.aws.json necessary? No, you can also use a docker-compose.yml file.

    I suggest you check AWS documentation on this topic.

    EDIT: IMHO it's better to use docker-compose.yml since it allows to start the containers locally and make sure they're ok before updating the application remotely