Last active
September 5, 2022 08:46
-
-
Save tstrohmeier/488f42ca7c66372b0c679bbb932c6ca5 to your computer and use it in GitHub Desktop.
AWS ECS: Deploy Docker Container from Bitbucket Pipeline to AWS ECR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# enable Docker for your repository | |
options: | |
docker: true | |
pipelines: | |
branches: | |
development: | |
- step: | |
#python image with aws-cli installed | |
image: tstrohmeier/awscli:3.8.3 | |
script: | |
# aws login | |
- eval $(aws ecr get-login --region ${AWS_DEFAULT_REGION} --no-include-email) | |
# docker | |
- export BUILD_ID=$BITBUCKET_BRANCH_$BITBUCKET_COMMIT_$BITBUCKET_BUILD_NUMBER | |
- docker build -t ${AWS_REGISTRY_URL}:$BUILD_ID . | |
- docker push ${AWS_REGISTRY_URL}:$BUILD_ID | |
- docker tag ${AWS_REGISTRY_URL}:$BUILD_ID ${AWS_REGISTRY_URL}:development | |
- docker push ${AWS_REGISTRY_URL}:development |
That works for me. Needed awscli to be installed :)
- pip install awscli - eval $(aws ecr get-login --region ${AWS_DEFAULT_REGION} --no-include-email) - export BUILD_ID=$BITBUCKET_BRANCH_$BITBUCKET_COMMIT_$BITBUCKET_BUILD_NUMBER - docker build -f docker/app/Dockerfile -t ${AWS_REGISTRY_URL}:$BUILD_ID . - docker push ${AWS_REGISTRY_URL}:$BUILD_ID - docker tag ${AWS_REGISTRY_URL}:$BUILD_ID ${AWS_REGISTRY_URL}:development - docker push ${AWS_REGISTRY_URL}:development
@mistillate Yes you are right, aws-cli
needs to be installed in the image you are using.
In Line 10/11 of the Gist, I mentioned this:
#python image with aws-cli installed
image: tstrohmeier/awscli:3.6.4
Why you push it again with
development
tag, in docker hub ppl push it withlatest
tag instead?
@mhewedy Because I use for every branch a own tag. I use development
tag for the latest build of development
branch.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That works for me. Needed awscli to be installed :)