Skip to content
Build, tag, and push Docker images to Amazon ECR
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
hooks
.DS_Store
LICENSE
README.md chore(docs): Increment own version Mar 14, 2019
plugin.yml

README.md

Docker ECR Publish Buildkite Plugin

GitHub Release

A Buildkite plugin to build, tag, and push Docker images to Amazon ECR.

Example

The following pipeline builds the default ./Dockerfile and pushes it to a pre-existing ECR repository my-repo:

steps:
  - plugins:
      - seek-oss/docker-ecr-publish#v1.1.7:
          ecr-name: my-repo

An alternate Dockerfile may be specified:

steps:
  - plugins:
      - seek-oss/docker-ecr-publish#v1.1.7:
          dockerfile: path/to/final.Dockerfile
          ecr-name: my-repo

Build-time variables are supported, either with an explicit value, or without one to propagate an environment variable from the pipeline step:

steps:
  - plugins:
      - seek-oss/docker-ecr-publish#v1.1.7:
          args:
            - BUILDKITE_BUILD_NUMBER # propagate environment variable
          branch-args:
            - BRANCH_TYPE=branch # explicit value
          default-args:
            - BRANCH_TYPE=default # explicit value
          ecr-name: my-repo

All images are tagged with their corresponding $BUILDKITE_BUILD_NUMBER, and images built from the default branch are tagged with latest. Additional tags may be listed:

steps:
  - plugins:
      - seek-oss/docker-ecr-publish#v1.1.7:
          branch-tags:
            - branch-$BUILDKITE_BUILD_NUMBER
          default-tags:
            # - latest
            - default-$BUILDKITE_BUILD_NUMBER
          ecr-name: my-repo
          tags:
            # - $BUILDKITE_BUILD_NUMBER
            - any-$BUILDKITE_BUILD_NUMBER

More complex branch workflows can be achieved by using multiple pipeline steps with differing branches:

steps:
  - branches: '!dev !prod'
    plugins:
      - seek-oss/docker-ecr-publish#v1.1.7:
          args: BRANCH_TYPE=branch
          ecr-name: my-repo
          tags: branch-$BUILDKITE_BUILD_NUMBER
  - branches: dev
    plugins:
      - seek-oss/docker-ecr-publish#v1.1.7:
          args: BRANCH_TYPE=dev
          ecr-name: my-repo
          tags: dev-$BUILDKITE_BUILD_NUMBER
  - branches: prod
    plugins:
      - seek-oss/docker-ecr-publish#v1.1.7:
          args: BRANCH_TYPE=prod
          ecr-name: my-repo
          tags: prod-$BUILDKITE_BUILD_NUMBER

This plugin can be used in combination with the Create ECR plugin to fully manage an ECR application repository within one pipeline step:

steps:
  - plugins:
      - seek-oss/create-ecr#v1.1.2:
          name: my-repo
      - seek-oss/docker-ecr-publish#v1.1.7:
          ecr-name: my-repo

This plugin can be used in combination with the Docker ECR Cache plugin to reuse a base image across pipeline steps:

steps:
  - command: npm test
    plugins:
      - seek-oss/docker-ecr-cache#v1.1.3:
          ecr-name: my-cache
          target: deps
      - docker#v3.0.1:
          volumes:
            - /workdir/node_modules
  - plugins:
      - seek-oss/docker-ecr-cache#v1.1.3:
          ecr-name: my-cache
          target: deps
      - seek-oss/docker-ecr-publish#v1.1.7:
          cache-from: ecr://my-cache # defaults to latest tag
          ecr-name: my-repo

Configuration

  • args (optional, array|string)

    Build args to provide to all builds. These are listed before the branch-specific branch-args and default-args properties in the resulting docker build command.

    Sensitive arguments should be propagated as an environment variable (MY_ARG instead of MY_ARG=blah), so that they are not checked into your source control and then logged to Buildkite output by this plugin.

  • branch-args (optional, array|string)

    Build args to provide to non-default branch builds.

  • branch-tags (optional, array|string)

    Tags to push on non-default branch builds.

  • cache-from (optional, array|string)

    Images for Docker to use as cache sources, e.g. a base or dependency image.

    Use standard Docker image notation (e.g. debian:jessie, myregistry.local:5000/testing/test-image), or the ecr://cache-repo:tag shorthand to point to an ECR repository in the current AWS account.

  • default-args (optional, array|string)

    Build args to provide to default branch builds.

  • default-tags (optional, array|string)

    Tags to push on default branch builds.

    Default: latest (non-removable)

  • dockerfile (optional, string)

    Local path to a custom Dockerfile.

    Default: Dockerfile

  • ecr-name (required, string)

    Name of the ECR repository.

  • tags (optional, array|string)

    Tags to push on all builds.

    Default: $BUILDKITE_BUILD_NUMBER (non-removable)

License

MIT (see LICENSE)

You can’t perform that action at this time.