Git Product home page Git Product logo

docker-ecr-publish-buildkite-plugin's Introduction

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.2.0:
          ecr-name: my-repo

An alternate Dockerfile may be specified:

steps:
  - plugins:
      - seek-oss/docker-ecr-publish#v1.2.0:
          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.2.0:
          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.2.0:
          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.2.0:
          args: BRANCH_TYPE=branch
          ecr-name: my-repo
          tags: branch-$BUILDKITE_BUILD_NUMBER
  - branches: dev
    plugins:
      - seek-oss/docker-ecr-publish#v1.2.0:
          args: BRANCH_TYPE=dev
          ecr-name: my-repo
          tags: dev-$BUILDKITE_BUILD_NUMBER
  - branches: prod
    plugins:
      - seek-oss/docker-ecr-publish#v1.2.0:
          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.2.0:
          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.4.0:
          ecr-name: my-cache
          target: deps
      - docker#v3.0.1:
          volumes:
            - /workdir/node_modules
  - plugins:
      - seek-oss/docker-ecr-cache#v1.4.0:
          ecr-name: my-cache
          target: deps
      - seek-oss/docker-ecr-publish#v1.2.0:
          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.

  • build-context (optional, string)

    The Docker build context. Valid values are as per the API

    Default: .

  • 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)

  • ssh (optional, string)

    Docker buildkit ssh string to be used to securely share ssh keys with container.

  • target (optional, string)

    Target a specifc build stage to build, mostly used with buildkit

License

MIT (see LICENSE)

docker-ecr-publish-buildkite-plugin's People

Contributors

72636c avatar bennycao avatar blai-seek avatar brycekk avatar jameshopkins avatar tamoore avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.