简体   繁体   中英

AWS Elastic Beanstalk with AMI2 and docker-compose.yml

I have been trying to make Elastic Beanstalk work with Docker AMI2 image and docker-compose.yml . The documentation says it should work out of the box with docker-compose.yml file. I use ECR as docker registry and have updated Elastic Beanstalk role to be able to pull images from ECR. https://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/single-container-docker-configuration.html

Create a docker-compose.yml file to deploy a Docker image from a hosted repository to Elastic Beanstalk. No other files are required if all your deployments are sourced from images in public repositories. (If your deployment must source an image from a private repository, you need to include additional configuration files for authentication. For more information, see Using images from a private repository.) For more information about the docker-compose.yml file, see Compose file reference on the Docker website.

However, I keep getting the following message when spinning up the environment:

Instance deployment: You must specify a Docker image in either 'Dockerfile' or 'Dockerrun.aws.json' in your source bundle. The deployment failed.

According to documentation Dockerrun.aws.json should only be required for the old AMI. Has anyone come across similar issue?

Found the solution. The documentation states docker-compose.yml is the only file needed but it still needs to be zipped before being uploaded to Elastic Beanstalk environment.

I have had some similar issues when migrating to docker-compose file from the dockerrun.json file.

What I did was to basically create a new app on elastic beanstalk and specify the Amazon Linux 2 platform under Docker as deployement option.

Below I will attach my docker-compose.yaml file and also the Github workflow with the part of deploying to ELB if you are interested (Or if it might help someone else)

Docker-compose.yaml, you will need to either remove the image or insert your own image tag url.

version: '3'
services:
  node-app:
    image: <IMG-TAG here e.g from ECR repository>
    ports:
      - 80:80

github.yaml

  deploy-staging:
    runs-on: ubuntu-latest
    needs: [build]
    steps:
      - uses: actions/checkout@v2

      - name: Generate deployment package
        run: |
          zip -r deploy.zip *
      - name: Deploy to EB
        uses: einaregilsson/beanstalk-deploy@v9
        with:
          aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          application_name: test
          environment_name: test
          version_label: ${{ github.sha }}
          region: eu-north-1
          deployment_package: deploy.zip
          use_existing_version_if_available: true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM