Build a Docker image

Building images with Bitbucket Pipelines

When building Docker images, use pipelines as much as possible. This example assumes that you are using the default Atlassian builder image in this example.

To publish a new image to AWS Elastic Container Registry (ECR), for example, use the following sample code to publish a new image when the repo is tagged:

pipelines:
  tags:
    '**': 
    - step: 
        name: Publish New Image
        # oidc: true indicates that OIDC authentication has been enabled.
        oidc: true  
        script:
        - docker build . -t $BITBUCKET_REPO_SLUG
        - pipe: atlassian/aws-ecr-push-image:1.6.2
          variables:
            AWS_DEFAULT_REGION: us-east-1
            AWS_OIDC_ROLE_ARN: $AWS_OIDC_ROLE_ARN
            IMAGE_NAME: $BITBUCKET_REPO_SLUG
            TAGS: "latest $BITBUCKET_TAG"           

NOTE: OIDC is true when OIDC Authentication is enabled.

Last updated

Logo

© DuploCloud, Inc. All rights reserved. DuploCloud trademarks used herein are registered trademarks of DuploCloud and affiliates