Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Docker compose in Bitbucket Pipeline to ECR

ragnar.callan January 25, 2021

I have 3 containers that are built with docker-compose and I need to push these to ECR. This is my current pipeline. How can I get this to push to ECR? I have multiple repositories, one for each container that I need to push too.   

image: python:3.7.2

options:
docker: true

pipelines:
default:
- step:
script:
- pipe: atlassian/aws-ecr-push-image:1.2.0
variables:
AWS_ACCESS_KEY_ID: 'xxxx'
AWS_SECRET_ACCESS_KEY: 'xxxx'
AWS_DEFAULT_REGION: 'xxxx'
IMAGE_NAME: ""
- step:
script:
- pip install docker
- pip install docker-compose
- docker-compose build
- docker push

 

1 answer

0 votes
brbojorque
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 25, 2021

Hi @ragnar.callan ,

You have to specify the ECR endpoint and make sure you are able to authenticate to the ECR.

  • Create an ECR entry
  • Get the endpoint 
  • Authenticate to ECR inside the pipeline
    • ecr login (something similar)
  • Modify the docker push like so below
    • docker push 321321321321.dkr.ecr.us-east-1.amazonaws.com/image:latest
ragnar.callan January 25, 2021

Hi, thanks for the reply. I have created my ECR endpoints. I have 3. One for each containers with different names. In my docker-compose file I labelled the images with the names of these repos. I want to push all 3 images to their respective ECR 

Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 17, 2021

Hi @ragnar.callan ,

Thank you for your question!

You could follow a Build Once Deploy Many approach and implement the next pipeline:

script:
# do other
- ...
- ...

# build the image
- docker-compose build

# use the pipe to push the image_1 to AWS ECR
- pipe: atlassian/aws-ecr-push-image:1.2.2
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: my-docker-image_1
# use the pipe to push the image_2 to AWS ECR
- pipe: atlassian/aws-ecr-push-image:1.2.2
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: my-docker-image_2
# use the pipe to push the image_3 to AWS ECR
- pipe: atlassian/aws-ecr-push-image:1.2.2
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: my-docker-image_3

 Make sure that you provide right IMAGE_NAME for each push:

The name of the image to push to the ECR. The name should be the same as your ECR repository name. Remember that you don't need to add your registry URL in front of the image name, the pipe will fetch this URL from AWS and add it to the image tag for you.


Cheers,
Oleksandr

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events