Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
docker: circleci/docker@2.8.2
Use docker
elements in your existing workflows and jobs.
Build and publish, and update the description of an image using the publish job
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
update-description: true
build-docker-image-only-with-buildkit:
jobs:
- docker/publish:
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
remote-docker-version: 20.10.12
update-description: true
use-buildkit: true
use-remote-docker: true
Build and push an image, save the digest to a file and echo the file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
jobs:
build-and-push:
executor: docker/docker
steps:
- setup_remote_docker
- checkout
- docker/check
- docker/build:
image: my_repo/orb-test
- docker/push:
digest-path: /tmp/digest.txt
image: my_repo/orb-test
- run:
command: |
echo "Digest is: $(</tmp/digest.txt)"
workflows:
commit:
jobs:
- build-and-push
Build, but don't publish, an image using the publish job
1
2
3
4
5
6
7
8
9
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
deploy: false
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
Build, but don't publish, an image using the check and build commands
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
jobs:
check-and-build-only:
executor: docker/machine
steps:
- checkout
- docker/check
- docker/build:
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
workflows:
build-docker-image-only:
jobs:
- check-and-build-only
Build and Deploy docker image with a custom name and tag, using a non-default executor with custom parameter values (note: when using a Docker-based excecutor, the `use-remote-docker` parameter must be set to true in order for Docker commands to run successfully).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
build-and-publish-docker-image:
jobs:
- docker/publish:
executor:
image: circleci/node
name: docker/docker
tag: boron-browsers
image: my/image
remote-docker-dlc: true
tag: my-tag
use-remote-docker: true
Use the pull command to pull one or more Docker images
1
2
3
4
5
6
7
8
9
10
11
12
13
14
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
jobs:
pull:
executor: docker/machine
steps:
- checkout
- docker/pull:
images: ubuntu:16.04,ubuntu:18.04
workflows:
pull-images:
jobs:
- pull
Build, deploy, and update the description of a Docker image with a non-standard description file
1
2
3
4
5
6
7
8
9
10
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
build-and-publish-docker-image:
jobs:
- docker/publish:
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
path: path/to/Docker/build/context
readme: my.README.md
Build and deploy a Docker image with a non-standard Dockerfile to a custom registry
1
2
3
4
5
6
7
8
9
10
11
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
build-and-publish-docker-image:
jobs:
- docker/publish:
dockerfile: my.Dockerfile
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
path: path/to/Docker/build/context
registry: my.docker.registry
Use hadolint to lint a Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
lint:
jobs:
- docker/hadolint:
dockerfiles: path/to/Dockerfile
executor-class: medium
hadolint-tag: 2.2.0-debian
ignore-rules: DL4005,DL3008
trusted-registries: docker.io,my-company.com:5000
Quickly install Docker, docker-compose, and dockerize in any CircleCI job environment where they are missing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
jobs:
your-job:
executor:
name: docker/docker
tag: '3.6'
steps:
- checkout
- docker/install-docker-tools
workflows:
your-workflow:
jobs:
- your-job
Build and deploy a Docker image with custom lifecycle hooks: after checking out the code from the VCS repository, before building the Docker image, and after building the Docker image
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
build-and-publish-docker-image:
jobs:
- docker/publish:
after_build:
- run:
command: echo "Did this after the build"
name: Do this after the build
after_checkout:
- run:
command: echo "Did this after checkout"
name: Do this after checkout
before_build:
- run:
command: echo "Did this before the build"
name: Do this before the build
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
Use the `dockerlint` command to install Dockerlint and lint a Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
jobs:
lint:
executor: docker/machine
steps:
- checkout
- docker/dockerlint:
dockerfile: path/to/and/name/of/Dockerfile
treat-warnings-as-errors: true
workflows:
lint-dockerfile:
jobs:
- lint
This demonstrates performing docker login with a credentials store configured, and then building an image with a Dockerfile in the root of your repository, naming the image to be the same name as your repository, and then pushing to the default docker registry (at docker.io)
1
2
3
4
5
6
7
8
9
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
build-and-publish-docker-image:
jobs:
- docker/publish:
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
use-docker-credentials-store: true
A standard Docker workflow, where you are building an image with a Dockerfile in the root of your repository, naming the image to be the same name as your repository, pushing to the default docker registry (at docker.io), and then updating the image description
1
2
3
4
5
6
7
8
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
build-and-publish-docker-image:
jobs:
- docker/publish:
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
Build/publish a Docker image bash substitution
1
2
3
4
5
6
7
8
9
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
image: ${CIRCLE_PROJECT_USERNAME,,}/${CIRCLE_PROJECT_REPONAME/_/-}
tag: ${CIRCLE_SHA1:0:10}
Build/publish a Docker image using --cache-from
1
2
3
4
5
6
7
8
9
10
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
cache_from: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME:latest
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
tag: latest
Build/publish a Docker image using --cache-to
1
2
3
4
5
6
7
8
9
10
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
cache_to: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME:cache
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
tag: latest
Build/publish a Docker image with extra build arguments
1
2
3
4
5
6
7
8
9
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
extra_build_args: '--build-arg=FOO=bar --build-arg=BAZ=qux'
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
Build/publish a Docker image with extra build arguments
1
2
3
4
5
6
7
8
9
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
tag: tag1,tag2,tag3
Build/publish a Docker image building from a nested Dockerfile
1
2
3
4
5
6
7
8
9
10
version: '2.1'
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
docker-context: .
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
path: dockerfiles/prod
Lint a given Dockerfile using a hadolint Docker image: https://hub.docker.com/r/hadolint/hadolint
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
attach-workspace | Boolean for whether or not to attach to an existing workspace, default is false
| No | false | boolean |
checkout | Checkout as a first step? Default is true | No | true | boolean |
dockerfiles | Relative or absolute path, including name, to Dockerfile(s) to be linted, e.g., `~/project/app/deploy.Dockerfile`, defaults to a Dockerfile named `Dockerfile` in the working directory. To lint multiple Dockerfiles, pass a colon-separated string, e.g., `~/project/app/deploy.Dockerfile:~/project/app/test.Dockerfile`.
| No | Dockerfile | string |
executor-class | Resource class to use for the hadolint executor | No | small | enum |
failure-threshold | Hadolint threshold level to fail on. Exit with failure code only when rules with a severity equal to or above THRESHOLD are violated
| No | info | enum |
hadolint-tag | Specific Hadolint image (make sure to use a `debian` tag, otherwise image will not be usable on CircleCI): https://hub.docker.com/r/hadolint/hadolint/tags
| No | latest-debian | string |
ignore-rules | Comma-separated string list of rules to ignore (e.g., `DL3000,SC1010`): https://github.com/hadolint/hadolint#rules
| No | '' | string |
trusted-registries | Comma-separated list of trusted registries (e.g., `docker.io,my-company.com:5000`); if set, return an error if Dockerfiles use any images from registries not included in this list
| No | '' | string |
workspace-root | Workspace root path that is either an absolute path or a path relative to the working directory
| No | workspace | string |
Build and optionally deploy a Docker image
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
after_build | Optional steps to run after building the Docker image | No | [] | steps |
after_checkout | Optional steps to run after checking out the code | No | [] | steps |
attach-at | Provide a path if you wish to attach a workspace. Use `./` for the working directory. `attach_workspace` attached location - where to mount folder/files that were `persist_to_workspace` in a previous step. https://circleci.com/docs/2.0/configuration-reference/#attach_workspace
| No | '' | string |
before_build | Optional steps to run before building the Docker image | No | [] | steps |
cache_from | Comma-separated list of images to pull before build for --cache-from This parameter only support registry type, the accepted syntax is: cache_from: user/app:cache,user/app2:cache2
| No | '' | string |
cache_to | Comman-separated list of images where cache will be pushed to. This parameter only support registry type, the accepted syntax is: cache_to: user/app:cache,user/app2:cache2
| No | '' | string |
deploy | Push the image to a registry? | No | true | boolean |
docker-context | Path to the directory containing your build context, defaults to . (working directory)
| No | . | string |
docker-password | Name of environment variable storing your Docker password
| No | DOCKER_PASSWORD | env_var_name |
docker-username | Name of environment variable storing your Docker username
| No | DOCKER_LOGIN | env_var_name |
dockerfile | Name of dockerfile to use, defaults to Dockerfile | No | Dockerfile | string |
executor | Executor to use for this job, defaults to this orb's `machine` executor
| No | machine | executor |
extra_build_args | Extra flags to pass to docker build. For examples, see https://docs.docker.com/engine/reference/commandline/build Pass the desired args using an equal sign (=) instead of an space. For example, --build-arg=ARG1=value, instead of --build-arg ARG1=vallue.
| No | '' | string |
image | Name of image to build | Yes | - | string |
lint-dockerfile | Lint Dockerfile before building?
| No | false | boolean |
path | Path to the directory containing your Dockerfile, defaults to . (working directory)
| No | . | string |
readme | Name of the file containing the image description to update, defaults to README.md | No | README.md | string |
registry | Name of registry to use, defaults to docker.io
| No | docker.io | string |
remote-docker-dlc | Enable docker layer caching if using remote Docker engine. Defaults to false.
| No | false | boolean |
remote-docker-version | Pick remote Docker engine version. Available versions can be found at: https://circleci.com/docs/2.0/building-docker-images/#docker-version. Must be >= 18.09 for BuildKit support.
| No | default | string |
tag | Comma-separated list of image tags, defaults to the value of $CIRCLE_SHA1 | No | $CIRCLE_SHA1 | string |
treat-warnings-as-errors | If linting Dockerfile, treat linting warnings as errors (would trigger an exist code and fail the CircleCI job)?
| No | false | boolean |
update-description | Update the image description on Docker Hub? | No | false | boolean |
use-buildkit | Use buildkit to build the image. Available on Docker >= 18.09.0 https://docs.docker.com/develop/develop-images/build_enhancements/
| No | false | boolean |
use-docker-credentials-store | Configure Docker to use a credentials store. This option is only supported on Ubuntu/Debian platforms.
| No | false | boolean |
use-remote-docker | Setup a remote Docker engine for Docker commands? Only required if using a Docker-based executor
| No | false | boolean |
Build and tag a Docker image
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
attach-at | Provide a path if you wish to attach a workspace. Use `./` for the working directory. `attach_workspace` attached location - where to mount folder/files that were `persist_to_workspace` in a previous step. https://circleci.com/docs/2.0/configuration-reference/#attach_workspace
| No | '' | string |
cache_from | Comma-separated list of images, images will first be pulled, then passed as the --cache-from build argument. This parameter only support registry type, the accepted syntax is: cache_from: user/app:cache,user/app2:cache2
| No | '' | string |
cache_to | Comman-separated list of images where cache will be pushed to. This parameter only support registry type, the accepted syntax is: cache_to: user/app:cache,user/app2:cache2
| No | '' | string |
debug | Extra output for orb developers
| No | false | boolean |
docker-context | Path to the directory containing your build context, defaults to . (working directory)
| No | . | string |
dockerfile | Name of dockerfile to use, defaults to Dockerfile | No | Dockerfile | string |
extra_build_args | Extra flags to pass to docker build. For examples, see https://docs.docker.com/engine/reference/commandline/build. Pass the desired args using an equal sign (=) instead of an space. For example, --build-arg=ARG1=value, instead of --build-arg ARG1=vallue.
| No | '' | string |
image | Name of image to build | Yes | - | string |
lint-dockerfile | Lint Dockerfile before building?
| No | false | boolean |
no_output_timeout | Pass through a default timeout if your Docker build does not output anything for more than 10 minutes.
| No | 10m | string |
path | Path to the directory containing your Dockerfile, defaults to . (working directory)
| No | . | string |
registry | Name of registry to use, defaults to docker.io
| No | docker.io | string |
step-name | Specify a custom step name for this command, if desired | No | Docker build | string |
tag | Image tag, defaults to the value of $CIRCLE_SHA1 | No | $CIRCLE_SHA1 | string |
treat-warnings-as-errors | If linting Dockerfile, treat linting warnings as errors? (would trigger an exit code and fail the CircleCI job)
| No | false | boolean |
use-buildkit | Use buildkit to build the image. Available on Docker >= 18.09.0 https://docs.docker.com/develop/develop-images/build_enhancements/
| No | false | boolean |
Sanity check to make sure you can build a Docker image. Check that Docker username and password environment variables are set, then run docker login to ensure that you can push the built image
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
arch | Which architecture is being used.
Values accepted are amd64 and arm64. Defaults to amd64.
When running on MacOS arm64 will be used.
| No | amd64 | enum |
docker-password | Name of environment variable storing your Docker password
| No | DOCKER_PASSWORD | env_var_name |
docker-username | Name of environment variable storing your Docker username
| No | DOCKER_LOGIN | env_var_name |
registry | Name of registry to use, defaults to docker.io | No | docker.io | string |
use-docker-credentials-store | Configure Docker to use a credentials store. This option is only supported on Ubuntu/Debian/macOS platforms.
| No | false | boolean |
Configure a credentials store for docker to use. See: https://docs.docker.com/engine/reference/commandline/login/#credentials-store#credentials-store Supported platforms: Linux and macOS.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
docker-config-path | Path to the Docker CLI config file.
| No | $HOME/.docker/config.json | string |
helper-name | Name of the credential helper to be used, e.g. "pass". If left blank, the orb will attempt to choose one based on the platform.
| No | '' | enum |
Install dockerlint and lint a given Dockerfile
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
debug | Extra output for orb developers
| No | false | boolean |
dockerfile | Relative or absolute path, including name, to Dockerfile to be linted, e.g., `~/project/app/deploy.Dockerfile`, defaults to a Dockerfile named `Dockerfile` in the working directory
| No | Dockerfile | string |
treat-warnings-as-errors | Treat linting warnings as errors (would trigger an exit code and fail the CircleCI job)?
| No | false | boolean |
Lint a given Dockerfile using hadolint. If the hadolint docker image is not used, hadolint will be installed.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
dockerfiles | Relative or absolute path, including name, to Dockerfile(s) to be linted, e.g., `~/project/app/deploy.Dockerfile`, defaults to a Dockerfile named `Dockerfile` in the working directory. To lint multiple Dockerfiles, pass a colon-separated string, e.g., `~/project/app/deploy.Dockerfile:~/project/app/test.Dockerfile`.
| No | Dockerfile | string |
failure-threshold | Hadolint threshold level to fail on. Exit with failure code only when rules with a severity equal to or above THRESHOLD are violated
| No | info | enum |
ignore-rules | Comma-separated string list of rules to ignore (e.g., `DL3000,SC1010`): https://github.com/hadolint/hadolint#rules
| No | '' | string |
trusted-registries | Comma-separated list of trusted registries (e.g., `docker.io,my-company.com:5000`); if set, return an error if Dockerfiles use any images from registries not included in this list
| No | '' | string |
Install the Docker CLI. Supports stable versions `v17.06.0-ce` and newer, on all platforms (Linux, macOS). Requirements: curl, grep, jq, tar
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
install-dir | Directory in which to install Docker binaries
| No | /usr/local/bin | string |
version | Version of Docker to install, defaults to the latest stable release. If specifying a version other than latest, provide a full release tag, as listed at https://api.github.com/repos/docker/cli/tags, e.g., `v18.09.4`.
| No | latest | string |
Install the `docker-compose` CLI. Supports stable versions. Requirements: curl, Docker, grep, jq, sha256sum,
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
install-dir | Directory in which to install `docker-compose`
| No | /usr/local/bin | string |
version | Version of `docker-compose` to install, defaults to the latest stable release. If specifying a version other than latest, provide a full release tag, as listed at https://github.com/docker/compose/releases or https://api.github.com/repos/docker/compose/releases, e.g., `v2.10.0`. Only versions equal or above v2.0.1 are supported.
| No | latest | string |
Install a credential helper for Docker, automatically chosen based on platform detection. See: https://docs.docker.com/engine/reference/commandline/login/#credentials-store#credential-helpers Supported platforms: Ubuntu/Debian and macOS.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
arch | Which architecture is being used.
Values accepted are amd64 and arm64. Defaults to amd64.
When running on MacOS arm64 will be used.
| No | amd64 | enum |
helper-name | Name of the credential helper to be installed, e.g. "pass". If left blank, the orb will attempt to choose one based on the platform.
| No | '' | enum |
release-tag | Use this to specify a tag to select which published release of the docker credential helper, as listed on https://github.com/docker/docker-credential-helpers/releases, to install. If no value is specified, the latest release will be installed. Note: Pre or alpha releases cannot be specified.
| No | '' | string |
Install commonly used Docker tools (Docker, `docker-compose`, `dockerize`). Requirements: curl, grep, jq, sha256sum, tar
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
debug | Extra output for orb developers
| No | false | boolean |
docker-compose-install-dir | Directory in which to install `docker-compose`
| No | /usr/local/bin | string |
docker-compose-version | Version of `docker-compose` to install, defaults to the latest stable release. If specifying a version other than latest, provide a full release tag, as listed at https://github.com/docker/compose/releases or https://api.github.com/repos/docker/compose/releases, e.g., `1.23.1`.
| No | latest | string |
docker-install-dir | Directory in which to install Docker binaries
| No | /usr/local/bin | string |
docker-version | Version of Docker to install, defaults to the latest stable release. If specifying a version other than latest, provide a full release tag, as listed at https://api.github.com/repos/docker/cli/tags, e.g., `v18.09.4`.
| No | latest | string |
dockerize-install-dir | Directory in which to install `dockerize`
| No | /usr/local/bin | string |
dockerize-version | Version of `dockerize` to install, defaults to the latest release. If specifying a version other than latest, provide a full release tag, as listed at https://github.com/jwilder/dockerize/releases, e.g., `v0.5.0`. Supports versions `v.0.4.0` and later.
| No | latest | string |
goss-architecture | Which Goss architecture to use. Supports `arm64` architecture from `v0.3.18` and newer.
| No | amd64 | enum |
goss-install-dir | Directory in which to install Goss and `dgoss`
| No | /usr/local/bin | string |
goss-version | Version of Goss and `dgoss` to install, defaults to the latest stable release. If specifying a version other than latest, provide a full release tag, as listed at https://github.com/aelsabbahy/goss/releases or https://api.github.com/repos/aelsabbahy/goss/releases, e.g., `v0.3.7`.
| No | latest | string |
install-docker | Install the Docker CLI? Supports stable versions `v17.06.0-ce` and newer, on all platforms (Linux, macOS). Requirements: curl, grep, jq, tar
| No | true | boolean |
install-docker-compose | Install the `docker-compose` CLI? Supports stable versions. Requirements: curl, Docker, grep, jq, sha256sum
| No | true | boolean |
install-dockerize | Install `dockerize`? Supports versions `v.0.4.0` and later. Requirements: curl, Docker
| No | true | boolean |
install-goss-dgoss | Install Goss and `dgoss`?
| No | true | boolean |
Install `dockerize`. Supports versions `v.0.4.0` and later. Requirements: curl, Docker
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
install-dir | Directory in which to install `dockerize`
| No | /usr/local/bin | string |
version | Version of `dockerize` to install, defaults to the latest release. If specifying a version other than latest, provide a full release tag, as listed at https://github.com/jwilder/dockerize/releases, e.g., `v0.5.0`. Supports versions `v.0.4.0` and later.
| No | latest | string |
Install the Goss and `dgoss` CLI tools, commonly using for testing Docker containers. Only compatible with Linux-based execution environments. More info: https://github.com/aelsabbahy/goss https://github.com/aelsabbahy/goss/tree/master/extras/dgoss
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
architecture | Which Goss architecture to use. Supports `arm64` architecture from `v0.3.18` and newer.
| No | amd64 | enum |
debug | Extra output for orb developers
| No | false | boolean |
install-dir | Directory in which to install Goss and `dgoss`
| No | /usr/local/bin | string |
version | Version of Goss and `dgoss` to install, defaults to the latest stable release. If specifying a version other than latest, provide a full release tag, as listed at https://github.com/aelsabbahy/goss/releases or https://api.github.com/repos/aelsabbahy/goss/releases, e.g., `v0.3.7`. Supports versions `v0.3.1` and newer.
| No | latest | string |
Pull one or more Docker images from a registry
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
ignore-docker-pull-error | Ignores errors from docker pull command | No | false | boolean |
images | Comma-separated list of images to pull | No | '' | string |
Push a Docker image to a registry
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
digest-path | The path to save the RepoDigest of the pushed image | No | '' | string |
image | Name of image to push | Yes | - | string |
registry | Name of registry to use, defaults to docker.io
| No | docker.io | string |
step-name | Specify a custom step name for this command, if desired | No | Docker push | string |
tag | Comma-separated list of image tag, defaults to the value of $CIRCLE_SHA1 | No | $CIRCLE_SHA1 | string |
Update a Docker image's description on Docker Hub
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
docker-password | Name of environment variable storing your Docker password
| No | DOCKER_PASSWORD | env_var_name |
docker-username | Name of environment variable storing your Docker username
| No | DOCKER_LOGIN | env_var_name |
image | Name of image to push | Yes | - | string |
path | Path to the directory containing your Dockerfile, defaults to . (working directory)
| No | . | string |
readme | Name of the file containing the image description to update, defaults to README.md | No | README.md | string |
registry | Name of registry to use, defaults to docker.io
| No | docker.io | string |
The docker container to use when running this orb's jobs
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
image | Docker image name | No | cimg/python | string |
tag | Image tag | No | '3.8' | string |
Hadolint Docker image
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
resource-class | - | No | small | enum |
tag | Specific Hadolint image (make sure to use a `debian` tag, otherwise image will not be usable on CircleCI): https://hub.docker.com/r/hadolint/hadolint/tags
| No | latest-debian | string |
CircleCI's Ubuntu-based machine executor VM: https://circleci.com/docs/2.0/executor-types/#using-machine
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
dlc | Enable Docker Layer Caching? | No | false | boolean |
image | - | No | ubuntu-2204:current | string |
resource-class | Resource class. | No | medium | enum |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: |
Quickly and easily install/configure/use Docker, `dockerize`, and `docker-compose` in any CircleCI job.
display:
source_url: https://github.com/CircleCI-Public/docker-orb
orbs:
bt: circleci/build-tools@3.0
jq: circleci/jq@2.2
commands:
build:
description: |
Build and tag a Docker image
parameters:
attach-at:
default: ""
description: |
Provide a path if you wish to attach a workspace. Use `./` for the working directory. `attach_workspace` attached location - where to mount folder/files that were `persist_to_workspace` in a previous step. https://circleci.com/docs/2.0/configuration-reference/#attach_workspace
type: string
cache_from:
default: ""
description: |
Comma-separated list of images, images will first be pulled, then passed as the --cache-from build argument. This parameter only support registry type, the accepted syntax is: cache_from: user/app:cache,user/app2:cache2
type: string
cache_to:
default: ""
description: |
Comman-separated list of images where cache will be pushed to. This parameter only support registry type, the accepted syntax is: cache_to: user/app:cache,user/app2:cache2
type: string
debug:
default: false
description: |
Extra output for orb developers
type: boolean
docker-context:
default: .
description: |
Path to the directory containing your build context, defaults to . (working directory)
type: string
dockerfile:
default: Dockerfile
description: Name of dockerfile to use, defaults to Dockerfile
type: string
extra_build_args:
default: ""
description: |
Extra flags to pass to docker build. For examples, see https://docs.docker.com/engine/reference/commandline/build. Pass the desired args using an equal sign (=) instead of an space. For example, --build-arg=ARG1=value, instead of --build-arg ARG1=vallue.
type: string
image:
description: Name of image to build
type: string
lint-dockerfile:
default: false
description: |
Lint Dockerfile before building?
type: boolean
no_output_timeout:
default: 10m
description: |
Pass through a default timeout if your Docker build does not output anything for more than 10 minutes.
type: string
path:
default: .
description: |
Path to the directory containing your Dockerfile, defaults to . (working directory)
type: string
registry:
default: docker.io
description: |
Name of registry to use, defaults to docker.io
type: string
step-name:
default: Docker build
description: Specify a custom step name for this command, if desired
type: string
tag:
default: $CIRCLE_SHA1
description: Image tag, defaults to the value of $CIRCLE_SHA1
type: string
treat-warnings-as-errors:
default: false
description: |
If linting Dockerfile, treat linting warnings as errors? (would trigger an exit code and fail the CircleCI job)
type: boolean
use-buildkit:
default: false
description: |
Use buildkit to build the image. Available on Docker >= 18.09.0 https://docs.docker.com/develop/develop-images/build_enhancements/
type: boolean
steps:
- when:
condition: <<parameters.lint-dockerfile>>
steps:
- dockerlint:
debug: <<parameters.debug>>
dockerfile: <<parameters.path>>/<<parameters.dockerfile>>
treat-warnings-as-errors: <<parameters.treat-warnings-as-errors>>
- when:
condition: <<parameters.use-buildkit>>
steps:
- run: echo 'export DOCKER_BUILDKIT=1' >> $BASH_ENV
- when:
condition: <<parameters.attach-at>>
steps:
- attach_workspace:
at: <<parameters.attach-at>>
- run:
command: |
#!/usr/bin/env bash
# Import "utils.sh".
eval "$SCRIPT_UTILS"
expand_env_vars_with_prefix "PARAM_"
DOCKER_TAGS_ARG=""
parse_tags_to_docker_arg() {
# Set comma as the new delimiter for the scope of this function.
local IFS=","
# Split tags into an array based on IFS delimiter.
read -ra tags \<<< "$PARAM_TAG"
local docker_arg
for tag in "${tags[@]}"; do
if [ -z "$docker_arg" ]; then
docker_arg="--tag=\"$PARAM_REGISTRY/$PARAM_IMAGE:$tag\""
else
docker_arg="$docker_arg --tag=\"$PARAM_REGISTRY/$PARAM_IMAGE:$tag\""
fi
done
# Set IFS to null to stop "," from breaking bash substitution
local IFS=
DOCKER_TAGS_ARG="$(eval echo $docker_arg)"
}
if ! parse_tags_to_docker_arg; then
echo "Unable to parse provided tags."
echo "Check your \"tag\" parameter or refer to the docs and try again: https://circleci.com/developer/orbs/orb/circleci/docker."
exit 1
fi
build_args=(
"--file=$PARAM_DOCKERFILE_PATH/$PARAM_DOCKERFILE_NAME"
)
eval 'for t in '$DOCKER_TAGS_ARG'; do build_args+=("$t"); done'
if [ -n "$EXTRA_BUILD_ARGS" ]; then
eval 'for p in '$EXTRA_BUILD_ARGS'; do build_args+=("$p"); done'
fi
if [ -n "$PARAM_CACHE_FROM" ]; then
cache_from=$(eval echo $PARAM_CACHE_FROM)
build_args+=("--cache-from=$cache_from")
fi
if [ -n "$PARAM_CACHE_TO" ]; then
cache_to="$(eval echo $PARAM_CACHE_TO)"
docker buildx create --name cache --use
docker buildx use cache
build_args+=("--cache-to=$cache_to" --load)
fi
# The context must be the last argument.
build_args+=("$PARAM_DOCKER_CONTEXT")
old_ifs="$IFS"
IFS=' '
set -x
docker buildx build "${build_args[@]}"
set +x
IFS="$old_ifs"
environment:
EXTRA_BUILD_ARGS: <<parameters.extra_build_args>>
PARAM_CACHE_FROM: <<parameters.cache_from>>
PARAM_CACHE_TO: <<parameters.cache_to>>
PARAM_DOCKER_CONTEXT: <<parameters.docker-context>>
PARAM_DOCKERFILE_NAME: <<parameters.dockerfile>>
PARAM_DOCKERFILE_PATH: <<parameters.path>>
PARAM_IMAGE: <<parameters.image>>
PARAM_REGISTRY: <<parameters.registry>>
PARAM_TAG: <<parameters.tag>>
PARAM_USE_BUILDKIT: <<parameters.use-buildkit>>
SCRIPT_UTILS: |
#!/usr/bin/env bash
# Public: Expand the value from environment variables with given prefix.
#
# Takes a prefix as an argument and expands the value of the environment variables
# starting with the prefix. The expansion is done by using the eval command.
#
# $1 - Prefix used to filter the envinronment variables.
#
# Examples
#
# expand_env_vars_with_prefix "ORB_PARAM_"
# expand_env_vars_with_prefix "PARAM_"
#
# Returns 1 if no argument is provided or no environment variables were found with prefix.
# Returns 0 if the expansion was successful.
expand_env_vars_with_prefix() {
if [ "$#" -eq 0 ]; then
>&2 printf '%s\n' "Please provide a prefix to filter the envinronment variables."
return 1
fi
# Fetch parameters from the environment variables.
local prefix="$1"
local env_vars
env_vars="$(printenv | grep "^$prefix")"
if [ -z "$env_vars" ]; then
>&2 printf '%s\n' "No environment variables found with the prefix: \"$prefix\"."
return 1
fi
while IFS= read -ra line; do
# Split the line into key and value.
local var_value="${line#*=}"
local var_name="${line%="$var_value"}"
# Expand the value.
local expanded_value
expanded_value="$(eval echo "$var_value")"
# The -v option assignes the output to a variable rather than printing it.
printf -v "$var_name" "%s" "$expanded_value"
done \<<< "$env_vars"
return 0
}
name: <<parameters.step-name>>
no_output_timeout: << parameters.no_output_timeout >>
check:
description: |
Sanity check to make sure you can build a Docker image. Check that Docker username and password environment variables are set, then run docker login to ensure that you can push the built image
parameters:
arch:
default: amd64
description: |
Which architecture is being used.
Values accepted are amd64 and arm64. Defaults to amd64.
When running on MacOS arm64 will be used.
enum:
- amd64
- arm64
type: enum
docker-password:
default: DOCKER_PASSWORD
description: |
Name of environment variable storing your Docker password
type: env_var_name
docker-username:
default: DOCKER_LOGIN
description: |
Name of environment variable storing your Docker username
type: env_var_name
registry:
default: docker.io
description: Name of registry to use, defaults to docker.io
type: string
use-docker-credentials-store:
default: false
description: |
Configure Docker to use a credentials store. This option is only supported on Ubuntu/Debian/macOS platforms.
type: boolean
steps:
- when:
condition: <<parameters.use-docker-credentials-store>>
steps:
- install-docker-credential-helper:
arch: <<parameters.arch>>
- configure-docker-credentials-store
- run:
command: |
#!/usr/bin/env bash
# Import "utils.sh".
eval "$SCRIPT_UTILS"
expand_env_vars_with_prefix "PARAM_"
echo "${!PARAM_DOCKER_PASSWORD}" | docker login -u "${!PARAM_DOCKER_USERNAME}" --password-stdin "$PARAM_REGISTRY"
environment:
PARAM_DOCKER_PASSWORD: <<parameters.docker-password>>
PARAM_DOCKER_USERNAME: <<parameters.docker-username>>
PARAM_REGISTRY: <<parameters.registry>>
SCRIPT_UTILS: |
#!/usr/bin/env bash
# Public: Expand the value from environment variables with given prefix.
#
# Takes a prefix as an argument and expands the value of the environment variables
# starting with the prefix. The expansion is done by using the eval command.
#
# $1 - Prefix used to filter the envinronment variables.
#
# Examples
#
# expand_env_vars_with_prefix "ORB_PARAM_"
# expand_env_vars_with_prefix "PARAM_"
#
# Returns 1 if no argument is provided or no environment variables were found with prefix.
# Returns 0 if the expansion was successful.
expand_env_vars_with_prefix() {
if [ "$#" -eq 0 ]; then
>&2 printf '%s\n' "Please provide a prefix to filter the envinronment variables."
return 1
fi
# Fetch parameters from the environment variables.
local prefix="$1"
local env_vars
env_vars="$(printenv | grep "^$prefix")"
if [ -z "$env_vars" ]; then
>&2 printf '%s\n' "No environment variables found with the prefix: \"$prefix\"."
return 1
fi
while IFS= read -ra line; do
# Split the line into key and value.
local var_value="${line#*=}"
local var_name="${line%="$var_value"}"
# Expand the value.
local expanded_value
expanded_value="$(eval echo "$var_value")"
# The -v option assignes the output to a variable rather than printing it.
printf -v "$var_name" "%s" "$expanded_value"
done \<<< "$env_vars"
return 0
}
name: Docker login
configure-docker-credentials-store:
description: |
Configure a credentials store for docker to use. See: https://docs.docker.com/engine/reference/commandline/login/#credentials-store#credentials-store Supported platforms: Linux and macOS.
parameters:
docker-config-path:
default: $HOME/.docker/config.json
description: |
Path to the Docker CLI config file.
type: string
helper-name:
default: ""
description: |
Name of the credential helper to be used, e.g. "pass". If left blank, the orb will attempt to choose one based on the platform.
enum:
- ""
- pass
- osxkeychain
type: enum
steps:
- jq/install
- run:
command: |
#!/usr/bin/env bash
# Import "utils.sh".
eval "$SCRIPT_UTILS"
expand_env_vars_with_prefix "PARAM_"
HELPER_NAME="$PARAM_HELPER_NAME"
DOCKER_CONFIG_PATH="$(eval echo ${PARAM_DOCKER_CONFIG_PATH})"
if [ -z "${HELPER_NAME}" ]; then
if uname | grep -q "Darwin"; then
HELPER_NAME="osxkeychain"
else
HELPER_NAME="pass"
fi
fi
if [ ! -e "$DOCKER_CONFIG_PATH" ]; then
echo "${DOCKER_CONFIG_PATH} does not exist; initializing it..."
mkdir -p "$(dirname "$DOCKER_CONFIG_PATH")"
echo "{}" > "$DOCKER_CONFIG_PATH"
fi
cat "$DOCKER_CONFIG_PATH" |
jq --arg credsStore "$HELPER_NAME" '. + {credsStore: $credsStore}' \
>/tmp/docker-config-credsstore-update.json
cat /tmp/docker-config-credsstore-update.json > "$DOCKER_CONFIG_PATH"
rm /tmp/docker-config-credsstore-update.json
environment:
PARAM_DOCKER_CONFIG_PATH: <<parameters.docker-config-path>>
PARAM_HELPER_NAME: <<parameters.helper-name>>
SCRIPT_UTILS: |
#!/usr/bin/env bash
# Public: Expand the value from environment variables with given prefix.
#
# Takes a prefix as an argument and expands the value of the environment variables
# starting with the prefix. The expansion is done by using the eval command.
#
# $1 - Prefix used to filter the envinronment variables.
#
# Examples
#
# expand_env_vars_with_prefix "ORB_PARAM_"
# expand_env_vars_with_prefix "PARAM_"
#
# Returns 1 if no argument is provided or no environment variables were found with prefix.
# Returns 0 if the expansion was successful.
expand_env_vars_with_prefix() {
if [ "$#" -eq 0 ]; then
>&2 printf '%s\n' "Please provide a prefix to filter the envinronment variables."
return 1
fi
# Fetch parameters from the environment variables.
local prefix="$1"
local env_vars
env_vars="$(printenv | grep "^$prefix")"
if [ -z "$env_vars" ]; then
>&2 printf '%s\n' "No environment variables found with the prefix: \"$prefix\"."
return 1
fi
while IFS= read -ra line; do
# Split the line into key and value.
local var_value="${line#*=}"
local var_name="${line%="$var_value"}"
# Expand the value.
local expanded_value
expanded_value="$(eval echo "$var_value")"
# The -v option assignes the output to a variable rather than printing it.
printf -v "$var_name" "%s" "$expanded_value"
done \<<< "$env_vars"
return 0
}
name: Configure Docker credentials store
dockerlint:
description: |
Install dockerlint and lint a given Dockerfile
parameters:
debug:
default: false
description: |
Extra output for orb developers
type: boolean
dockerfile:
default: Dockerfile
description: |
Relative or absolute path, including name, to Dockerfile to be linted, e.g., `~/project/app/deploy.Dockerfile`, defaults to a Dockerfile named `Dockerfile` in the working directory
type: string
treat-warnings-as-errors:
default: false
description: |
Treat linting warnings as errors (would trigger an exit code and fail the CircleCI job)?
type: boolean
steps:
- run:
command: |
#!/usr/bin/env bash
# Import "utils.sh".
eval "$SCRIPT_UTILS"
expand_env_vars_with_prefix "PARAM_"
if [[ $EUID == 0 ]]; then SUDO=""; else SUDO="sudo"; fi
if ! command -v dockerlint &> /dev/null; then
if ! command -v npm &> /dev/null; then
echo "npm is required to install dockerlint.";
echo "Consider running this command with an image that has node available: https://circleci.com/developer/images/image/cimg/node";
echo "Alternatively, use dockerlint's docker image: https://github.com/RedCoolBeans/dockerlint#docker-image."
exit 1
fi
if [ "$PARAM_DEBUG" = true ]; then
npm install -g dockerlint || "$SUDO" npm install -g dockerlint
else
npm install -g dockerlint &> /dev/null || "$SUDO" npm install -g dockerlint &> /dev/null
fi
fi
if [ "$PARAM_TREAT_WARNING_AS_ERRORS" = true ]; then
dockerlint -f "$PARAM_DOCKERFILE" -p
else
dockerlint -f "$PARAM_DOCKERFILE"
fi
environment:
PARAM_DEBUG: <<parameters.debug>>
PARAM_DOCKERFILE: <<parameters.dockerfile>>
PARAM_TREAT_WARNING_AS_ERRORS: <<parameters.treat-warnings-as-errors>>
SCRIPT_UTILS: |
#!/usr/bin/env bash
# Public: Expand the value from environment variables with given prefix.
#
# Takes a prefix as an argument and expands the value of the environment variables
# starting with the prefix. The expansion is done by using the eval command.
#
# $1 - Prefix used to filter the envinronment variables.
#
# Examples
#
# expand_env_vars_with_prefix "ORB_PARAM_"
# expand_env_vars_with_prefix "PARAM_"
#
# Returns 1 if no argument is provided or no environment variables were found with prefix.
# Returns 0 if the expansion was successful.
expand_env_vars_with_prefix() {
if [ "$#" -eq 0 ]; then
>&2 printf '%s\n' "Please provide a prefix to filter the envinronment variables."
return 1
fi
# Fetch parameters from the environment variables.
local prefix="$1"
local env_vars
env_vars="$(printenv | grep "^$prefix")"
if [ -z "$env_vars" ]; then
>&2 printf '%s\n' "No environment variables found with the prefix: \"$prefix\"."
return 1
fi
while IFS= read -ra line; do
# Split the line into key and value.
local var_value="${line#*=}"
local var_name="${line%="$var_value"}"
# Expand the value.
local expanded_value
expanded_value="$(eval echo "$var_value")"
# The -v option assignes the output to a variable rather than printing it.
printf -v "$var_name" "%s" "$expanded_value"
done \<<< "$env_vars"
return 0
}
name: Lint Dockerfile at <<parameters.dockerfile>>
hadolint:
description: |
Lint a given Dockerfile using hadolint. If the hadolint docker image is not used, hadolint will be installed.
parameters:
dockerfiles:
default: Dockerfile
description: |
Relative or absolute path, including name, to Dockerfile(s) to be linted, e.g., `~/project/app/deploy.Dockerfile`, defaults to a Dockerfile named `Dockerfile` in the working directory. To lint multiple Dockerfiles, pass a colon-separated string, e.g., `~/project/app/deploy.Dockerfile:~/project/app/test.Dockerfile`.
type: string
failure-threshold:
default: info
description: |
Hadolint threshold level to fail on. Exit with failure code only when rules with a severity equal to or above THRESHOLD are violated
enum:
- error
- warning
- info
- style
- ignore
- none
type: enum
ignore-rules:
default: ""
description: |
Comma-separated string list of rules to ignore (e.g., `DL3000,SC1010`): https://github.com/hadolint/hadolint#rules
type: string
trusted-registries:
default: ""
description: |
Comma-separated list of trusted registries (e.g., `docker.io,my-company.com:5000`); if set, return an error if Dockerfiles use any images from registries not included in this list
type: string
steps:
- run:
command: "# Import \"utils.sh\".\neval \"$SCRIPT_UTILS\"\nexpand_env_vars_with_prefix \"PARAM_\"\n\nif [[ $EUID == 0 ]]; then export SUDO=\"\"; else export SUDO=\"sudo\"; fi\n\nInstall_Hadolint() {\n if uname -a | grep \"Darwin\"; then\n SYS_ENV_PLATFORM=\"Darwin\"\n brew install hadolint\n elif uname -a | grep \"x86_64 GNU/Linux\"; then\n export SYS_ENV_PLATFORM=Linux-x86_64\n elif uname -a | grep \"aarch64 GNU/Linux\"; then\n export SYS_ENV_PLATFORM=Linux-arm64\n\telse \n\t\techo \"This platform appears to be unsupported.\"\n uname -a\n exit 1\n\tfi\n\t\n if [ \"${SYS_ENV_PLATFORM}\" != \"Darwin\" ]; then\n $SUDO wget -O /bin/hadolint \"https://github.com/hadolint/hadolint/releases/latest/download/hadolint-${SYS_ENV_PLATFORM}\"\n $SUDO chmod +x /bin/hadolint\n fi\n}\n\nif ! command -v hadolint &> /dev/null; then\n\tInstall_Hadolint\nfi \n\nif [ -n \"$PARAM_IGNORE_RULES\" ]; then\n ignore_rules=$(printf '%s' \"--ignore ${PARAM_IGNORE_RULES//,/ --ignore }\")\n readonly ignore_rules\nfi\n\n\nif [ -n \"$PARAM_TRUSTED_REGISTRIES\" ]; then\n trusted_registries=$(printf '%s' \"--trusted-registry ${PARAM_TRUSTED_REGISTRIES//,/ --trusted-registry }\")\n readonly trusted_registries\nfi\n\nfailure_threshold=$(printf '%s' \"--failure-threshold ${PARAM_FAILURE_THRESHOLD}\")\nreadonly failure_threshold\n\nprintf '%s\\n' \"Running hadolint with the following options...\"\nprintf '%s\\n' \"$ignore_rules\"\nprintf '%s\\n' \"$trusted_registries\"\nprintf '%s\\n' \"$failure_threshold\"\n\n# use colon delimiters to create array\nreadonly old_ifs=\"$IFS\"\nIFS=\":\"\n\nread -ra dockerfiles \\<<< \"$PARAM_DOCKERFILES\"\nIFS=\"$old_ifs\"\n\nfor dockerfile in \"${dockerfiles[@]}\"; do\n set -x\n hadolint \\\n ${PARAM_FAILURE_THRESHOLD:+$failure_threshold} \\\n ${PARAM_IGNORE_RULES:+$ignore_rules} \\\n ${PARAM_TRUSTED_REGISTRIES:+$trusted_registries} \\\n $dockerfile\n set +x\n printf '%s\\n' \"Success! $dockerfile linted; no issues found\"\ndone\n"
environment:
PARAM_DOCKERFILES: <<parameters.dockerfiles>>
PARAM_FAILURE_THRESHOLD: <<parameters.failure-threshold>>
PARAM_IGNORE_RULES: <<parameters.ignore-rules>>
PARAM_TRUSTED_REGISTRIES: <<parameters.trusted-registries>>
SCRIPT_UTILS: |
#!/usr/bin/env bash
# Public: Expand the value from environment variables with given prefix.
#
# Takes a prefix as an argument and expands the value of the environment variables
# starting with the prefix. The expansion is done by using the eval command.
#
# $1 - Prefix used to filter the envinronment variables.
#
# Examples
#
# expand_env_vars_with_prefix "ORB_PARAM_"
# expand_env_vars_with_prefix "PARAM_"
#
# Returns 1 if no argument is provided or no environment variables were found with prefix.
# Returns 0 if the expansion was successful.
expand_env_vars_with_prefix() {
if [ "$#" -eq 0 ]; then
>&2 printf '%s\n' "Please provide a prefix to filter the envinronment variables."
return 1
fi
# Fetch parameters from the environment variables.
local prefix="$1"
local env_vars
env_vars="$(printenv | grep "^$prefix")"
if [ -z "$env_vars" ]; then
>&2 printf '%s\n' "No environment variables found with the prefix: \"$prefix\"."
return 1
fi
while IFS= read -ra line; do
# Split the line into key and value.
local var_value="${line#*=}"
local var_name="${line%="$var_value"}"
# Expand the value.
local expanded_value
expanded_value="$(eval echo "$var_value")"
# The -v option assignes the output to a variable rather than printing it.
printf -v "$var_name" "%s" "$expanded_value"
done \<<< "$env_vars"
return 0
}
name: Lint <<parameters.dockerfiles>> with hadolint
install-docker:
description: |
Install the Docker CLI. Supports stable versions `v17.06.0-ce` and newer, on all platforms (Linux, macOS). Requirements: curl, grep, jq, tar
parameters:
install-dir:
default: /usr/local/bin
description: |
Directory in which to install Docker binaries
type: string
version:
default: latest
description: |
Version of Docker to install, defaults to the latest stable release. If specifying a version other than latest, provide a full release tag, as listed at https://api.github.com/repos/docker/cli/tags, e.g., `v18.09.4`.
type: string
steps:
- run:
command: |
#!/usr/bin/env bash
# Import "utils.sh".
eval "$SCRIPT_UTILS"
expand_env_vars_with_prefix "PARAM_"
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
# grab Docker version
if [[ "$PARAM_VERSION" == "latest" ]]; then
# extract latest version from GitHub releases API
declare -i INDEX=0
while :
do
INDEX_VERSION=$(curl --silent --show-error --location --fail --retry 3 \
https://api.github.com/repos/docker/cli/tags | \
jq --argjson index "$INDEX" '.[$index].name')
# filter out betas & release candidates
# shellcheck disable=SC2143 # Doesn't apply to this case.
if [[ $(echo "$INDEX_VERSION" | grep -v beta | grep -v rc) ]]; then
# can't use substring expression < 0 on macOS
DOCKER_VERSION="${INDEX_VERSION:1:$((${#INDEX_VERSION} - 1 - 1))}"
echo "Latest stable version of Docker is $DOCKER_VERSION"
break
else
INDEX=$((INDEX+1))
fi
done
else
DOCKER_VERSION="$PARAM_VERSION"
echo "Selected version of Docker is $DOCKER_VERSION"
fi
# check if Docker needs to be installed
DOCKER_VERSION_NUMBER="${DOCKER_VERSION:1}"
if command -v docker >> /dev/null 2>&1; then
if docker --version | grep "$DOCKER_VERSION_NUMBER" >> /dev/null 2>&1; then
echo "Docker $DOCKER_VERSION is already installed"
exit 0
else
echo "A different version of Docker is installed ($(docker --version)); removing it"
$SUDO rm -f "$(command -v docker)"
fi
fi
# get binary download URL for specified version
if uname -a | grep Darwin >> /dev/null 2>&1; then
PLATFORM=mac
else
PLATFORM=linux
fi
SYS_ARCH=$(uname -m)
if [ "$SYS_ARCH" == "arm64" ]; then
SYS_ARCH="aarch64"
fi
DOCKER_BINARY_URL="https://download.docker.com/$PLATFORM/static/stable/$SYS_ARCH/docker-$DOCKER_VERSION_NUMBER.tgz"
# download binary tarball
DOWNLOAD_DIR="$(mktemp -d)"
DOWNLOAD_FILE="${DOWNLOAD_DIR}/docker.tgz"
curl --output "$DOWNLOAD_FILE" \
--silent --show-error --location --fail --retry 3 \
"$DOCKER_BINARY_URL"
tar xf "$DOWNLOAD_FILE" -C "$DOWNLOAD_DIR" && rm -f "$DOWNLOAD_FILE"
# install Docker binaries
BINARIES=$(ls "${DOWNLOAD_DIR}/docker")
$SUDO mv "$DOWNLOAD_DIR"/docker/* "$PARAM_INSTALL_DIR"
$SUDO rm -rf "$DOWNLOAD_DIR"
for binary in $BINARIES
do
$SUDO chmod +x "$PARAM_INSTALL_DIR/$binary"
done
# verify version
echo "$(docker --version) has been installed to $(command -v docker)"
environment:
PARAM_INSTALL_DIR: << parameters.install-dir >>
PARAM_VERSION: << parameters.version >>
SCRIPT_UTILS: |
#!/usr/bin/env bash
# Public: Expand the value from environment variables with given prefix.
#
# Takes a prefix as an argument and expands the value of the environment variables
# starting with the prefix. The expansion is done by using the eval command.
#
# $1 - Prefix used to filter the envinronment variables.
#
# Examples
#
# expand_env_vars_with_prefix "ORB_PARAM_"
# expand_env_vars_with_prefix "PARAM_"
#
# Returns 1 if no argument is provided or no environment variables were found with prefix.
# Returns 0 if the expansion was successful.
expand_env_vars_with_prefix() {
if [ "$#" -eq 0 ]; then
>&2 printf '%s\n' "Please provide a prefix to filter the envinronment variables."
return 1
fi
# Fetch parameters from the environment variables.
local prefix="$1"
local env_vars
env_vars="$(printenv | grep "^$prefix")"
if [ -z "$env_vars" ]; then
>&2 printf '%s\n' "No environment variables found with the prefix: \"$prefix\"."
return 1
fi
while IFS= read -ra line; do
# Split the line into key and value.
local var_value="${line#*=}"
local var_name="${line%="$var_value"}"
# Expand the value.
local expanded_value
expanded_value="$(eval echo "$var_value")"
# The -v option assignes the output to a variable rather than printing it.
printf -v "$var_name" "%s" "$expanded_value"
done \<<< "$env_vars"
return 0
}
name: Install Docker CLI
install-docker-compose:
description: |
Install the `docker-compose` CLI. Supports stable versions. Requirements: curl, Docker, grep, jq, sha256sum,
parameters:
install-dir:
default: /usr/local/bin
description: |
Directory in which to install `docker-compose`
type: string
version:
default: latest
description: |
Version of `docker-compose` to install, defaults to the latest stable release. If specifying a version other than latest, provide a full release tag, as listed at https://github.com/docker/compose/releases or https://api.github.com/repos/docker/compose/releases, e.g., `v2.10.0`. Only versions equal or above v2.0.1 are supported.
type: string
steps:
- run:
command: |
#!/usr/bin/env bash
# Import "utils.sh".
eval "$SCRIPT_UTILS"
expand_env_vars_with_prefix "PARAM_"
trap_exit() {
# clean-up
printf '%s\n' "Cleaning up..."
[ -f "$DOCKER_SHASUM_FILENAME" ] && rm -f "$DOCKER_SHASUM_FILENAME"
}
trap trap_exit EXIT
# checking for root user
if [[ $(id -u) -eq 0 ]]; then
SUDO=""
else
SUDO="sudo"
fi
# installing curl if linux distribution is Alpine
if cat /etc/issue | grep Alpine &> /dev/null; then
$SUDO apk update
$SUDO apk add curl
fi
# grab docker-compose version
if [[ "$PARAM_DOCKER_COMPOSER_VERSION" == "latest" ]]; then
DOCKER_COMPOSE_VERSION="$(curl -Ls --fail --retry 3 -o /dev/null -w '%{url_effective}' "https://github.com/docker/compose/releases/latest" | sed 's:.*/::')"
echo "Latest stable version of docker-compose is $DOCKER_COMPOSE_VERSION"
else
DOCKER_COMPOSE_VERSION="$PARAM_DOCKER_COMPOSER_VERSION"
echo "Selected version of docker-compose is $DOCKER_COMPOSE_VERSION"
fi
# check if docker-compose needs to be installed
if command -v docker-compose &> /dev/null; then
if docker-compose --version | grep "$DOCKER_COMPOSE_VERSION" &> /dev/null; then
echo "docker-compose $DOCKER_COMPOSE_VERSION is already installed"
exit 0
else
echo "A different version of docker-compose is installed ($(docker-compose --version)); removing it"
$SUDO rm -f "$(command -v docker-compose)"
fi
fi
# get binary/shasum download URL for specified version
if uname -a | grep Darwin &> /dev/null; then
PLATFORM=darwin
HOMEBREW_NO_AUTO_UPDATE=1 brew install coreutils
else
PLATFORM=linux
fi
SYS_ARCH=$(uname -m)
if [ "$SYS_ARCH" == "arm64" ]; then
SYS_ARCH="aarch64"
fi
DOCKER_COMPOSE_BASE_URL="https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION"
DOCKER_COMPOSE_RELEASES_HTML="$(curl -Ls --fail --retry 3 "https://github.com/docker/compose/releases/tag/$DOCKER_COMPOSE_VERSION")"
DOCKER_COMPOSE_RELEASE="docker-compose-$PLATFORM-$SYS_ARCH"
DOCKER_SHASUM_FILENAME="checksum.txt"
# since v2.10.0, docker-compose doesn't have a ".sha256" file
# so we need to use the "checksums.txt" file instead
if grep --quiet "checksums.txt" \<<< "$DOCKER_COMPOSE_RELEASES_HTML"; then
printf '%s\n' "Downloading \"checksums.txt\" to verify the binary's integrity."
curl -o "$DOCKER_SHASUM_FILENAME" \
--silent --location --retry 3 \
"$DOCKER_COMPOSE_BASE_URL/checksums.txt"
else
printf '%s\n' "Downloading \"$DOCKER_COMPOSE_RELEASE.sha256\" to verify the binary's integrity."
curl -o "$DOCKER_SHASUM_FILENAME" \
--silent --location --retry 3 \
"$DOCKER_COMPOSE_BASE_URL/$DOCKER_COMPOSE_RELEASE.sha256"
fi
# download docker-compose binary
curl -o "$DOCKER_COMPOSE_RELEASE" \
--location --retry 3 \
"$DOCKER_COMPOSE_BASE_URL/$DOCKER_COMPOSE_RELEASE"
# verify binary integrity using SHA-256 checksum
set +e
grep "$DOCKER_COMPOSE_RELEASE" "$DOCKER_SHASUM_FILENAME" | sha256sum -c -
SHASUM_SUCCESS=$?
set -e
if [[ "$SHASUM_SUCCESS" -ne 0 ]]; then
echo "Checksum validation failed for $DOCKER_COMPOSE_RELEASE"
exit 1
fi
# install docker-compose
$SUDO mv "$DOCKER_COMPOSE_RELEASE" "$PARAM_INSTALL_DIR"/docker-compose
$SUDO chmod +x "$PARAM_INSTALL_DIR"/docker-compose
# verify version
echo "$(docker-compose --version) has been installed to $(command -v docker-compose)"
environment:
PARAM_DOCKER_COMPOSER_VERSION: << parameters.version >>
PARAM_INSTALL_DIR: <<parameters.install-dir>>
SCRIPT_UTILS: |
#!/usr/bin/env bash
# Public: Expand the value from environment variables with given prefix.
#
# Takes a prefix as an argument and expands the value of the environment variables
# starting with the prefix. The expansion is done by using the eval command.
#
# $1 - Prefix used to filter the envinronment variables.
#
# Examples
#
# expand_env_vars_with_prefix "ORB_PARAM_"
# expand_env_vars_with_prefix "PARAM_"
#
# Returns 1 if no argument is provided or no environment variables were found with prefix.
# Returns 0 if the expansion was successful.
expand_env_vars_with_prefix() {
if [ "$#" -eq 0 ]; then
>&2 printf '%s\n' "Please provide a prefix to filter the envinronment variables."
return 1
fi
# Fetch parameters from the environment variables.
local prefix="$1"
local env_vars
env_vars="$(printenv | grep "^$prefix")"
if [ -z "$env_vars" ]; then
>&2 printf '%s\n' "No environment variables found with the prefix: \"$prefix\"."
return 1
fi
while IFS= read -ra line; do
# Split the line into key and value.
local var_value="${line#*=}"
local var_name="${line%="$var_value"}"
# Expand the value.
local expanded_value
expanded_value="$(eval echo "$var_value")"
# The -v option assignes the output to a variable rather than printing it.
printf -v "$var_name" "%s" "$expanded_value"
done \<<< "$env_vars"
return 0
}
name: Install docker-compose
install-docker-credential-helper:
description: |
Install a credential helper for Docker, automatically chosen based on platform detection. See: https://docs.docker.com/engine/reference/commandline/login/#credentials-store#credential-helpers Supported platforms: Ubuntu/Debian and macOS.
parameters:
arch:
default: amd64
description: |
Which architecture is being used.
Values accepted are amd64 and arm64. Defaults to amd64.
When running on MacOS arm64 will be used.
enum:
- amd64
- arm64
type: enum
helper-name:
default: ""
description: |
Name of the credential helper to be installed, e.g. "pass". If left blank, the orb will attempt to choose one based on the platform.
enum:
- ""
- pass
- osxkeychain
type: enum
release-tag:
default: ""
description: |
Use this to specify a tag to select which published release of the docker credential helper, as listed on https://github.com/docker/docker-credential-helpers/releases, to install. If no value is specified, the latest release will be installed. Note: Pre or alpha releases cannot be specified.
type: string
steps:
- run:
command: "#!/usr/bin/env bash\n\n# Import \"utils.sh\".\neval \"$SCRIPT_UTILS\"\nexpand_env_vars_with_prefix \"PARAM_\"\n\nHELPER_NAME=\"$PARAM_HELPER_NAME\"\n\nif uname | grep -q \"Darwin\"; then \n platform=\"darwin\"\n arch=\"arm64\"\nelse \n platform=\"linux\"\n arch=\"$PARAM_ARCH\"\nfi\n\n# Infer helper name from the platform\nif [ -z \"${HELPER_NAME}\" ]; then\n if [ \"$platform\" = \"darwin\" ]; then HELPER_NAME=\"osxkeychain\"\n else HELPER_NAME=\"pass\"\n fi\nfi\n\nHELPER_FILENAME=\"docker-credential-${HELPER_NAME}\"\n\nif command -v \"$HELPER_FILENAME\" &> /dev/null; then\n echo \"$HELPER_FILENAME is already installed\"\n exit 0\nfi\n\nSUDO=\"\"\nif [ \"$(id -u)\" -ne 0 ] && command -v sudo &> /dev/null; then\n SUDO=\"sudo\"\nfi\n\n# Create heredoc template here due to tab indentation issue\nGPG_TEMPLATE=$(mktemp gpg_template.XXXXXX)\ncat > $GPG_TEMPLATE \\<< EOF\n Key-Type: RSA\n Key-Length: 2048\n Name-Real: CircleCI Orb User\n Name-Email: circleci-orbs@circleci.com\n Expire-Date: 0\n %no-protection\n %no-ask-passphrase\n %commit\nEOF\n\nif [ \"$HELPER_FILENAME\" = \"docker-credential-pass\" ]; then\n # Install pass which is needed for docker-credential-pass to work\n $SUDO apt-get update --yes && $SUDO apt-get install gnupg2 pass --yes\n\n # Initialize pass with a gpg key\n gpg2 --batch --gen-key \"$GPG_TEMPLATE\"\n\n FINGERPRINT_STRING=$(gpg2 \\\n --list-keys --with-fingerprint --with-colons \\\n circleci-orbs@circleci.com | \\\n grep fpr)\n FINGERPRINT=\"$(grep -oP '(?<=:)([A-Za-z0-9].*)(?=:)' \\<<< $FINGERPRINT_STRING)\"\n pass init $FINGERPRINT\nfi\nrm \"$GPG_TEMPLATE\"\n\necho \"Downloading credential helper $HELPER_FILENAME\"\nBIN_PATH=\"/usr/local/bin\"\nmkdir -p \"$BIN_PATH\"\nRELEASE_TAG=\"$PARAM_RELEASE_TAG\"\nbase_url=\"https://github.com/docker/docker-credential-helpers/releases\"\nRELEASE_VERSION=$(curl -Ls --fail --retry 3 -o /dev/null -w '%{url_effective}' \"$base_url/latest\" | sed 's:.*/::')\nif [ -n \"${RELEASE_TAG}\" ]; then\n RELEASE_VERSION=\"${RELEASE_TAG}\"\nfi\n\n# Starting from v0.7.0, the release file name is changed to docker-credential-<helper-name>-<version>.<os>-<arch><variant>\n# At the moment of writing, the amd64 binary does not have a variant suffix. But this might change in the future.\n# https://github.com/CircleCI-Public/docker-orb/pull/156#discussion_r977920812\nminor_version=\"$(echo \"$RELEASE_VERSION\" | cut -d. -f2)\"\ndownload_base_url=\"$base_url/download/${RELEASE_VERSION}/${HELPER_FILENAME}-${RELEASE_VERSION}\"\n\nif [ \"$minor_version\" -gt 6 ]; then\n DOWNLOAD_URL=\"$download_base_url.$platform-$arch\"\n echo \"Downloading from url: $DOWNLOAD_URL\"\n curl -L -o \"${HELPER_FILENAME}\" \"$DOWNLOAD_URL\"\nelse\n DOWNLOAD_URL=\"$download_base_url-$arch.tar.gz\"\n echo \"Downloading from url: $DOWNLOAD_URL\"\n curl -L -o \"${HELPER_FILENAME}_archive\" \"$DOWNLOAD_URL\"\n tar xvf \"./${HELPER_FILENAME}_archive\"\n rm \"./${HELPER_FILENAME}_archive\"\nfi\n\nchmod +x \"./$HELPER_FILENAME\"\n$SUDO mv \"./$HELPER_FILENAME\" \"$BIN_PATH/$HELPER_FILENAME\"\n\"$BIN_PATH/$HELPER_FILENAME\" version\n"
environment:
PARAM_ARCH: << parameters.arch >>
PARAM_HELPER_NAME: << parameters.helper-name >>
PARAM_RELEASE_TAG: << parameters.release-tag >>
SCRIPT_UTILS: |
#!/usr/bin/env bash
# Public: Expand the value from environment variables with given prefix.
#
# Takes a prefix as an argument and expands the value of the environment variables
# starting with the prefix. The expansion is done by using the eval command.
#
# $1 - Prefix used to filter the envinronment variables.
#
# Examples
#
# expand_env_vars_with_prefix "ORB_PARAM_"
# expand_env_vars_with_prefix "PARAM_"
#
# Returns 1 if no argument is provided or no environment variables were found with prefix.
# Returns 0 if the expansion was successful.
expand_env_vars_with_prefix() {
if [ "$#" -eq 0 ]; then
>&2 printf '%s\n' "Please provide a prefix to filter the envinronment variables."
return 1
fi
# Fetch parameters from the environment variables.
local prefix="$1"
local env_vars
env_vars="$(printenv | grep "^$prefix")"
if [ -z "$env_vars" ]; then
>&2 printf '%s\n' "No environment variables found with the prefix: \"$prefix\"."
return 1
fi
while IFS= read -ra line; do
# Split the line into key and value.
local var_value="${line#*=}"
local var_name="${line%="$var_value"}"
# Expand the value.
local expanded_value
expanded_value="$(eval echo "$var_value")"
# The -v option assignes the output to a variable rather than printing it.
printf -v "$var_name" "%s" "$expanded_value"
done \<<< "$env_vars"
return 0
}
name: Install Docker credential helper
install-docker-tools:
description: |
Install commonly used Docker tools (Docker, `docker-compose`, `dockerize`). Requirements: curl, grep, jq, sha256sum, tar
parameters:
debug:
default: false
description: |
Extra output for orb developers
type: boolean
docker-compose-install-dir:
default: /usr/local/bin
description: |
Directory in which to install `docker-compose`
type: string
docker-compose-version:
default: latest
description: |
Version of `docker-compose` to install, defaults to the latest stable release. If specifying a version other than latest, provide a full release tag, as listed at https://github.com/docker/compose/releases or https://api.github.com/repos/docker/compose/releases, e.g., `1.23.1`.
type: string
docker-install-dir:
default: /usr/local/bin
description: |
Directory in which to install Docker binaries
type: string
docker-version:
default: latest
description: |
Version of Docker to install, defaults to the latest stable release. If specifying a version other than latest, provide a full release tag, as listed at https://api.github.com/repos/docker/cli/tags, e.g., `v18.09.4`.
type: string
dockerize-install-dir:
default: /usr/local/bin
description: |
Directory in which to install `dockerize`
type: string
dockerize-version:
default: latest
description: |
Version of `dockerize` to install, defaults to the latest release. If specifying a version other than latest, provide a full release tag, as listed at https://github.com/jwilder/dockerize/releases, e.g., `v0.5.0`. Supports versions `v.0.4.0` and later.
type: string
goss-architecture:
default: amd64
description: |
Which Goss architecture to use. Supports `arm64` architecture from `v0.3.18` and newer.
enum:
- amd64
- arm64
type: enum
goss-install-dir:
default: /usr/local/bin
description: |
Directory in which to install Goss and `dgoss`
type: string
goss-version:
default: latest
description: |
Version of Goss and `dgoss` to install, defaults to the latest stable release. If specifying a version other than latest, provide a full release tag, as listed at https://github.com/aelsabbahy/goss/releases or https://api.github.com/repos/aelsabbahy/goss/releases, e.g., `v0.3.7`.
type: string
install-docker:
default: true
description: |
Install the Docker CLI? Supports stable versions `v17.06.0-ce` and newer, on all platforms (Linux, macOS). Requirements: curl, grep, jq, tar
type: boolean
install-docker-compose:
default: true
description: |
Install the `docker-compose` CLI? Supports stable versions. Requirements: curl, Docker, grep, jq, sha256sum
type: boolean
install-dockerize:
default: true
description: |
Install `dockerize`? Supports versions `v.0.4.0` and later. Requirements: curl, Docker
type: boolean
install-goss-dgoss:
default: true
description: |
Install Goss and `dgoss`?
type: boolean
steps:
- when:
condition: <<parameters.install-docker>>
steps:
- install-docker:
install-dir: <<parameters.docker-install-dir>>
version: <<parameters.docker-version>>
- when:
condition: <<parameters.install-docker-compose>>
steps:
- install-docker-compose:
install-dir: <<parameters.docker-compose-install-dir>>
version: <<parameters.docker-compose-version>>
- when:
condition: <<parameters.install-dockerize>>
steps:
- install-dockerize:
install-dir: <<parameters.dockerize-install-dir>>
version: <<parameters.dockerize-version>>
- when:
condition: <<parameters.install-goss-dgoss>>
steps:
- install-goss:
architecture: <<parameters.goss-architecture>>
debug: <<parameters.debug>>
install-dir: <<parameters.goss-install-dir>>
version: <<parameters.goss-version>>
install-dockerize:
description: |
Install `dockerize`. Supports versions `v.0.4.0` and later. Requirements: curl, Docker
parameters:
install-dir:
default: /usr/local/bin
description: |
Directory in which to install `dockerize`
type: string
version:
default: latest
description: |
Version of `dockerize` to install, defaults to the latest release. If specifying a version other than latest, provide a full release tag, as listed at https://github.com/jwilder/dockerize/releases, e.g., `v0.5.0`. Supports versions `v.0.4.0` and later.
type: string
steps:
- run:
command: |
#!/usr/bin/env bash
# Import "utils.sh".
eval "$SCRIPT_UTILS"
expand_env_vars_with_prefix "PARAM_"
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
# grab dockerize version
if [[ "$PARAM_VERSION" == "latest" ]]; then
DOCKERIZE_VERSION=$(curl --fail --retry 3 -Ls -o /dev/null -w '%{url_effective}' "https://github.com/jwilder/dockerize/releases/latest" | sed 's:.*/::')
echo "Latest version of dockerize is $DOCKERIZE_VERSION"
else
DOCKERIZE_VERSION="$PARAM_VERSION"
echo "Selected version of dockerize is $DOCKERIZE_VERSION"
fi
# check if dockerize needs to be installed
if command -v dockerize &> /dev/null; then
if dockerize --version | grep "$DOCKERIZE_VERSION" &> /dev/null; then
echo "dockerize $DOCKERIZE_VERSION is already installed"
exit 0
else
echo "A different version of dockerize is installed ($(dockerize --version)); removing it"
$SUDO rm -f "$(command -v dockerize)"
fi
fi
# construct binary download URL
if uname -a | grep Darwin &> /dev/null; then
PLATFORM=darwin-amd64
elif cat /etc/issue | grep Alpine &> /dev/null; then
PLATFORM=alpine-linux-amd64
apk add --no-cache openssl
else
SYS_ARCH=$(uname -m)
if [[ $SYS_ARCH == "x86_64" ]]; then
SYS_ARCH="amd64"
elif [[ $SYS_ARCH == "aarch64" ]]; then
SYS_ARCH="arm64"
fi
PLATFORM=linux-$SYS_ARCH
fi
DOCKERIZE_BINARY_URL="https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-$PLATFORM-$DOCKERIZE_VERSION.tar.gz"
# download & install binary
curl -O --silent --show-error --location --fail --retry 3 \
"$DOCKERIZE_BINARY_URL"
tar xf "dockerize-$PLATFORM-$DOCKERIZE_VERSION.tar.gz"
rm -f "dockerize-$PLATFORM-$DOCKERIZE_VERSION.tar.gz"
$SUDO mv dockerize "$PARAM_INSTALL_DIR"
$SUDO chmod +x "$PARAM_INSTALL_DIR"/dockerize
# verify version
echo "dockerize $(dockerize --version) has been installed to $(command -v dockerize)"
environment:
PARAM_INSTALL_DIR: << parameters.install-dir >>
PARAM_VERSION: << parameters.version >>
SCRIPT_UTILS: |
#!/usr/bin/env bash
# Public: Expand the value from environment variables with given prefix.
#
# Takes a prefix as an argument and expands the value of the environment variables
# starting with the prefix. The expansion is done by using the eval command.
#
# $1 - Prefix used to filter the envinronment variables.
#
# Examples
#
# expand_env_vars_with_prefix "ORB_PARAM_"
# expand_env_vars_with_prefix "PARAM_"
#
# Returns 1 if no argument is provided or no environment variables were found with prefix.
# Returns 0 if the expansion was successful.
expand_env_vars_with_prefix() {
if [ "$#" -eq 0 ]; then
>&2 printf '%s\n' "Please provide a prefix to filter the envinronment variables."
return 1
fi
# Fetch parameters from the environment variables.
local prefix="$1"
local env_vars
env_vars="$(printenv | grep "^$prefix")"
if [ -z "$env_vars" ]; then
>&2 printf '%s\n' "No environment variables found with the prefix: \"$prefix\"."
return 1
fi
while IFS= read -ra line; do
# Split the line into key and value.
local var_value="${line#*=}"
local var_name="${line%="$var_value"}"
# Expand the value.
local expanded_value
expanded_value="$(eval echo "$var_value")"
# The -v option assignes the output to a variable rather than printing it.
printf -v "$var_name" "%s" "$expanded_value"
done \<<< "$env_vars"
return 0
}
name: Install dockerize
install-goss:
description: |
Install the Goss and `dgoss` CLI tools, commonly using for testing Docker containers. Only compatible with Linux-based execution environments. More info: https://github.com/aelsabbahy/goss https://github.com/aelsabbahy/goss/tree/master/extras/dgoss
parameters:
architecture:
default: amd64
description: |
Which Goss architecture to use. Supports `arm64` architecture from `v0.3.18` and newer.
enum:
- amd64
- arm64
type: enum
debug:
default: false
description: |
Extra output for orb developers
type: boolean
install-dir:
default: /usr/local/bin
description: |
Directory in which to install Goss and `dgoss`
type: string
version:
default: latest
description: |
Version of Goss and `dgoss` to install, defaults to the latest stable release. If specifying a version other than latest, provide a full release tag, as listed at https://github.com/aelsabbahy/goss/releases or https://api.github.com/repos/aelsabbahy/goss/releases, e.g., `v0.3.7`. Supports versions `v0.3.1` and newer.
type: string
steps:
- run:
command: |
#!/usr/bin/env bash
# Import "utils.sh".
eval "$SCRIPT_UTILS"
expand_env_vars_with_prefix "PARAM_"
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
# determine specified version
if [[ "$PARAM_VERSION" == latest ]]; then
VERSION=$(curl -Ls --fail --retry 3 -o /dev/null -w '%{url_effective}' \
"https://github.com/aelsabbahy/goss/releases/latest" | sed 's:.*/::')
echo "Latest version of Goss is $VERSION"
else
VERSION="$PARAM_VERSION"
echo "Selected version of Goss is $VERSION"
fi
# installation check
if [[ "$PARAM_DEBUG" -eq 1 ]]; then
set -x
fi
if command -v goss &> /dev/null; then
if goss --version | \
grep "$VERSION" &> /dev/null && \
command -v dgoss &> /dev/null; then
echo "Goss and dgoss $VERSION are already installed"
exit 0
else
echo "A different version of Goss is installed ($(goss --version)); removing it"
$SUDO rm -rf "$(command -v goss)" &> /dev/null
$SUDO rm -rf "$(command -v dgoss)" &> /dev/null
fi
fi
# download/install
# goss
curl -O --silent --show-error --location --fail --retry 3 \
"https://github.com/aelsabbahy/goss/releases/download/$VERSION/goss-linux-$PARAM_ARCHITECTURE"
$SUDO mv goss-linux-$PARAM_ARCHITECTURE "$PARAM_INSTALL_DIR"/goss
$SUDO chmod +rx /usr/local/bin/goss
# test/verify goss
if goss --version | grep "$VERSION" &> /dev/null; then
echo "$(goss --version) has been installed to $(command -v goss)"
else
echo "Something went wrong; the specified version of Goss could not be installed"
exit 1
fi
# dgoss
DGOSS_URL="https://raw.githubusercontent.com/aelsabbahy/goss/$VERSION/extras/dgoss/dgoss"
if curl --output /dev/null --silent --head --fail "$DGOSS_URL"; then
curl -O --silent --show-error --location --fail --retry 3 "$DGOSS_URL"
$SUDO mv dgoss "$PARAM_INSTALL_DIR"
$SUDO chmod +rx /usr/local/bin/dgoss
# test/verify dgoss
if command -v dgoss &> /dev/null; then
echo "dgoss has been installed to $(command -v dgoss)"
else
echo "Something went wrong; the dgoss wrapper for the specified version of Goss could not be installed"
exit 1
fi
else
echo "No dgoss wrapper found for the selected version of Goss ($VERSION)..."
echo "Goss installation will proceed, but to use dgoss, please try again with a newer version"
fi
environment:
PARAM_ARCHITECTURE: <<parameters.architecture>>
PARAM_DEBUG: <<parameters.debug>>
PARAM_INSTALL_DIR: <<parameters.install-dir>>
PARAM_VERSION: <<parameters.version>>
SCRIPT_UTILS: |
#!/usr/bin/env bash
# Public: Expand the value from environment variables with given prefix.
#
# Takes a prefix as an argument and expands the value of the environment variables
# starting with the prefix. The expansion is done by using the eval command.
#
# $1 - Prefix used to filter the envinronment variables.
#
# Examples
#
# expand_env_vars_with_prefix "ORB_PARAM_"
# expand_env_vars_with_prefix "PARAM_"
#
# Returns 1 if no argument is provided or no environment variables were found with prefix.
# Returns 0 if the expansion was successful.
expand_env_vars_with_prefix() {
if [ "$#" -eq 0 ]; then
>&2 printf '%s\n' "Please provide a prefix to filter the envinronment variables."
return 1
fi
# Fetch parameters from the environment variables.
local prefix="$1"
local env_vars
env_vars="$(printenv | grep "^$prefix")"
if [ -z "$env_vars" ]; then
>&2 printf '%s\n' "No environment variables found with the prefix: \"$prefix\"."
return 1
fi
while IFS= read -ra line; do
# Split the line into key and value.
local var_value="${line#*=}"
local var_name="${line%="$var_value"}"
# Expand the value.
local expanded_value
expanded_value="$(eval echo "$var_value")"
# The -v option assignes the output to a variable rather than printing it.
printf -v "$var_name" "%s" "$expanded_value"
done \<<< "$env_vars"
return 0
}
name: Install Goss and dgoss
pull:
description: Pull one or more Docker images from a registry
parameters:
ignore-docker-pull-error:
default: false
description: Ignores errors from docker pull command
type: boolean
images:
default: ""
description: Comma-separated list of images to pull
type: string
steps:
- when:
condition: <<parameters.images>>
steps:
- run:
command: |
#!/usr/bin/env bash
# Import "utils.sh".
eval "$SCRIPT_UTILS"
expand_env_vars_with_prefix "PARAM_"
echo "$PARAM_IMAGES" | sed -n 1'p' | tr ',' '\n' | while read -r image; do
echo "Pulling ${image}";
if [ "$PARAM_IGNORE_DOCKER_PULL_ERROR" -eq 1 ]; then
docker pull "${image}" || true;
else
docker pull "${image}";
fi
done
environment:
PARAM_IGNORE_DOCKER_PULL_ERROR: <<parameters.ignore-docker-pull-error>>
PARAM_IMAGES: <<parameters.images>>
SCRIPT_UTILS: |
#!/usr/bin/env bash
# Public: Expand the value from environment variables with given prefix.
#
# Takes a prefix as an argument and expands the value of the environment variables
# starting with the prefix. The expansion is done by using the eval command.
#
# $1 - Prefix used to filter the envinronment variables.
#
# Examples
#
# expand_env_vars_with_prefix "ORB_PARAM_"
# expand_env_vars_with_prefix "PARAM_"
#
# Returns 1 if no argument is provided or no environment variables were found with prefix.
# Returns 0 if the expansion was successful.
expand_env_vars_with_prefix() {
if [ "$#" -eq 0 ]; then
>&2 printf '%s\n' "Please provide a prefix to filter the envinronment variables."
return 1
fi
# Fetch parameters from the environment variables.
local prefix="$1"
local env_vars
env_vars="$(printenv | grep "^$prefix")"
if [ -z "$env_vars" ]; then
>&2 printf '%s\n' "No environment variables found with the prefix: \"$prefix\"."
return 1
fi
while IFS= read -ra line; do
# Split the line into key and value.
local var_value="${line#*=}"
local var_name="${line%="$var_value"}"
# Expand the value.
local expanded_value
expanded_value="$(eval echo "$var_value")"
# The -v option assignes the output to a variable rather than printing it.
printf -v "$var_name" "%s" "$expanded_value"
done \<<< "$env_vars"
return 0
}
name: Docker pull
push:
description: Push a Docker image to a registry
parameters:
digest-path:
default: ""
description: The path to save the RepoDigest of the pushed image
type: string
image:
description: Name of image to push
type: string
registry:
default: docker.io
description: |
Name of registry to use, defaults to docker.io
type: string
step-name:
default: Docker push
description: Specify a custom step name for this command, if desired
type: string
tag:
default: $CIRCLE_SHA1
description: Comma-separated list of image tag, defaults to the value of $CIRCLE_SHA1
type: string
steps:
- run:
command: |
#!/usr/bin/env bash
# Import "utils.sh".
eval "$SCRIPT_UTILS"
expand_env_vars_with_prefix "PARAM_"
IFS="," read -ra DOCKER_TAGS \<<< "$PARAM_TAG"
image="$(eval echo "$PARAM_IMAGE")"
for docker_tag in "${DOCKER_TAGS[@]}"; do
tag=$(eval echo "$docker_tag")
set -x
docker push "$PARAM_REGISTRY"/"$image":"$tag"
set +x
done
if [ -n "$PARAM_DIGEST_PATH" ]; then
mkdir -p "$(dirname "$PARAM_DIGEST_PATH")"
IFS="," read -ra DOCKER_TAGS \<<< "$PARAM_TAG"
tag=$(eval echo "${DOCKER_TAGS[0]}")
docker image inspect --format="{{index .RepoDigests 0}}" "$PARAM_REGISTRY"/"$image":"$tag" > "$PARAM_DIGEST_PATH"
fi
environment:
PARAM_DIGEST_PATH: <<parameters.digest-path>>
PARAM_IMAGE: <<parameters.image>>
PARAM_REGISTRY: <<parameters.registry>>
PARAM_TAG: <<parameters.tag>>
SCRIPT_UTILS: |
#!/usr/bin/env bash
# Public: Expand the value from environment variables with given prefix.
#
# Takes a prefix as an argument and expands the value of the environment variables
# starting with the prefix. The expansion is done by using the eval command.
#
# $1 - Prefix used to filter the envinronment variables.
#
# Examples
#
# expand_env_vars_with_prefix "ORB_PARAM_"
# expand_env_vars_with_prefix "PARAM_"
#
# Returns 1 if no argument is provided or no environment variables were found with prefix.
# Returns 0 if the expansion was successful.
expand_env_vars_with_prefix() {
if [ "$#" -eq 0 ]; then
>&2 printf '%s\n' "Please provide a prefix to filter the envinronment variables."
return 1
fi
# Fetch parameters from the environment variables.
local prefix="$1"
local env_vars
env_vars="$(printenv | grep "^$prefix")"
if [ -z "$env_vars" ]; then
>&2 printf '%s\n' "No environment variables found with the prefix: \"$prefix\"."
return 1
fi
while IFS= read -ra line; do
# Split the line into key and value.
local var_value="${line#*=}"
local var_name="${line%="$var_value"}"
# Expand the value.
local expanded_value
expanded_value="$(eval echo "$var_value")"
# The -v option assignes the output to a variable rather than printing it.
printf -v "$var_name" "%s" "$expanded_value"
done \<<< "$env_vars"
return 0
}
name: <<parameters.step-name>>
update-description:
description: Update a Docker image's description on Docker Hub
parameters:
docker-password:
default: DOCKER_PASSWORD
description: |
Name of environment variable storing your Docker password
type: env_var_name
docker-username:
default: DOCKER_LOGIN
description: |
Name of environment variable storing your Docker username
type: env_var_name
image:
description: Name of image to push
type: string
path:
default: .
description: |
Path to the directory containing your Dockerfile, defaults to . (working directory)
type: string
readme:
default: README.md
description: Name of the file containing the image description to update, defaults to README.md
type: string
registry:
default: docker.io
description: |
Name of registry to use, defaults to docker.io
type: string
steps:
- jq/install
- run:
command: |
#!/usr/bin/env bash
# Import "utils.sh".
eval "$SCRIPT_UTILS"
expand_env_vars_with_prefix "PARAM_"
if [ "$PARAM_REGISTRY" != "docker.io" ]; then
echo "Registry is not set to Docker Hub. Exiting"
exit 1
fi
USERNAME=${!PARAM_DOCKER_USERNAME}
PASSWORD=${!PARAM_DOCKER_PASSWORD}
IMAGE="$(eval echo "$PARAM_IMAGE")"
DESCRIPTION="$PARAM_PATH/$PARAM_README"
PAYLOAD="username=$USERNAME&password=$PASSWORD"
JWT=$(curl -s -d "$PAYLOAD" https://hub.docker.com/v2/users/login/ | jq -r .token)
HEADER="Authorization: JWT $JWT"
URL="https://hub.docker.com/v2/repositories/$IMAGE/"
STATUS=$(curl -s -o /dev/null -w '%{http_code}' -X PATCH -H "$HEADER" -H 'Content-type: application/json' --data "{\"full_description\": $(jq -Rs '.' $DESCRIPTION)}" $URL)
if [ $STATUS -ne 200 ]; then
echo "Could not update image description"
echo "Error code: $STATUS"
exit 1
fi
environment:
PARAM_DOCKER_PASSWORD: <<parameters.docker-password>>
PARAM_DOCKER_USERNAME: <<parameters.docker-username>>
PARAM_IMAGE: <<parameters.image>>
PARAM_PATH: <<parameters.path>>
PARAM_README: <<parameters.readme>>
PARAM_REGISTRY: <<parameters.registry>>
SCRIPT_UTILS: |
#!/usr/bin/env bash
# Public: Expand the value from environment variables with given prefix.
#
# Takes a prefix as an argument and expands the value of the environment variables
# starting with the prefix. The expansion is done by using the eval command.
#
# $1 - Prefix used to filter the envinronment variables.
#
# Examples
#
# expand_env_vars_with_prefix "ORB_PARAM_"
# expand_env_vars_with_prefix "PARAM_"
#
# Returns 1 if no argument is provided or no environment variables were found with prefix.
# Returns 0 if the expansion was successful.
expand_env_vars_with_prefix() {
if [ "$#" -eq 0 ]; then
>&2 printf '%s\n' "Please provide a prefix to filter the envinronment variables."
return 1
fi
# Fetch parameters from the environment variables.
local prefix="$1"
local env_vars
env_vars="$(printenv | grep "^$prefix")"
if [ -z "$env_vars" ]; then
>&2 printf '%s\n' "No environment variables found with the prefix: \"$prefix\"."
return 1
fi
while IFS= read -ra line; do
# Split the line into key and value.
local var_value="${line#*=}"
local var_name="${line%="$var_value"}"
# Expand the value.
local expanded_value
expanded_value="$(eval echo "$var_value")"
# The -v option assignes the output to a variable rather than printing it.
printf -v "$var_name" "%s" "$expanded_value"
done \<<< "$env_vars"
return 0
}
name: Update description
executors:
docker:
description: |
The docker container to use when running this orb's jobs
docker:
- image: <<parameters.image>>:<<parameters.tag>>
parameters:
image:
default: cimg/python
description: Docker image name
type: string
tag:
default: "3.8"
description: Image tag
type: string
hadolint:
description: Hadolint Docker image
docker:
- image: hadolint/hadolint:<<parameters.tag>>
parameters:
resource-class:
default: small
enum:
- small
- medium
- medium+
- large
- xlarge
type: enum
tag:
default: latest-debian
description: |
Specific Hadolint image (make sure to use a `debian` tag, otherwise image will not be usable on CircleCI): https://hub.docker.com/r/hadolint/hadolint/tags
type: string
resource_class: <<parameters.resource-class>>
machine:
description: |
CircleCI's Ubuntu-based machine executor VM: https://circleci.com/docs/2.0/executor-types/#using-machine
machine:
docker_layer_caching: <<parameters.dlc>>
image: <<parameters.image>>
parameters:
dlc:
default: false
description: Enable Docker Layer Caching?
type: boolean
image:
default: ubuntu-2204:current
type: string
resource-class:
default: medium
description: Resource class.
enum:
- medium
- large
- xlarge
- 2xlarge
- arm.medium
- arm.large
- arm.xlarge
- arm.2xlarge
type: enum
resource_class: <<parameters.resource-class>>
jobs:
hadolint:
description: |
Lint a given Dockerfile using a hadolint Docker image: https://hub.docker.com/r/hadolint/hadolint
executor:
name: hadolint
resource-class: <<parameters.executor-class>>
tag: <<parameters.hadolint-tag>>
parameters:
attach-workspace:
default: false
description: |
Boolean for whether or not to attach to an existing workspace, default is false
type: boolean
checkout:
default: true
description: Checkout as a first step? Default is true
type: boolean
dockerfiles:
default: Dockerfile
description: |
Relative or absolute path, including name, to Dockerfile(s) to be linted, e.g., `~/project/app/deploy.Dockerfile`, defaults to a Dockerfile named `Dockerfile` in the working directory. To lint multiple Dockerfiles, pass a colon-separated string, e.g., `~/project/app/deploy.Dockerfile:~/project/app/test.Dockerfile`.
type: string
executor-class:
default: small
description: Resource class to use for the hadolint executor
enum:
- small
- medium
- medium+
- large
- xlarge
type: enum
failure-threshold:
default: info
description: |
Hadolint threshold level to fail on. Exit with failure code only when rules with a severity equal to or above THRESHOLD are violated
enum:
- error
- warning
- info
- style
- ignore
- none
type: enum
hadolint-tag:
default: latest-debian
description: |
Specific Hadolint image (make sure to use a `debian` tag, otherwise image will not be usable on CircleCI): https://hub.docker.com/r/hadolint/hadolint/tags
type: string
ignore-rules:
default: ""
description: |
Comma-separated string list of rules to ignore (e.g., `DL3000,SC1010`): https://github.com/hadolint/hadolint#rules
type: string
trusted-registries:
default: ""
description: |
Comma-separated list of trusted registries (e.g., `docker.io,my-company.com:5000`); if set, return an error if Dockerfiles use any images from registries not included in this list
type: string
workspace-root:
default: workspace
description: |
Workspace root path that is either an absolute path or a path relative to the working directory
type: string
steps:
- bt/install-ci-tools
- when:
condition: <<parameters.checkout>>
steps:
- checkout
- when:
condition: <<parameters.attach-workspace>>
steps:
- attach_workspace:
at: <<parameters.workspace-root>>
- hadolint:
dockerfiles: <<parameters.dockerfiles>>
failure-threshold: <<parameters.failure-threshold>>
ignore-rules: <<parameters.ignore-rules>>
trusted-registries: <<parameters.trusted-registries>>
publish:
description: Build and optionally deploy a Docker image
executor: <<parameters.executor>>
parameters:
after_build:
default: []
description: Optional steps to run after building the Docker image
type: steps
after_checkout:
default: []
description: Optional steps to run after checking out the code
type: steps
attach-at:
default: ""
description: |
Provide a path if you wish to attach a workspace. Use `./` for the working directory. `attach_workspace` attached location - where to mount folder/files that were `persist_to_workspace` in a previous step. https://circleci.com/docs/2.0/configuration-reference/#attach_workspace
type: string
before_build:
default: []
description: Optional steps to run before building the Docker image
type: steps
cache_from:
default: ""
description: |
Comma-separated list of images to pull before build for --cache-from This parameter only support registry type, the accepted syntax is: cache_from: user/app:cache,user/app2:cache2
type: string
cache_to:
default: ""
description: |
Comman-separated list of images where cache will be pushed to. This parameter only support registry type, the accepted syntax is: cache_to: user/app:cache,user/app2:cache2
type: string
deploy:
default: true
description: Push the image to a registry?
type: boolean
docker-context:
default: .
description: |
Path to the directory containing your build context, defaults to . (working directory)
type: string
docker-password:
default: DOCKER_PASSWORD
description: |
Name of environment variable storing your Docker password
type: env_var_name
docker-username:
default: DOCKER_LOGIN
description: |
Name of environment variable storing your Docker username
type: env_var_name
dockerfile:
default: Dockerfile
description: Name of dockerfile to use, defaults to Dockerfile
type: string
executor:
default: machine
description: |
Executor to use for this job, defaults to this orb's `machine` executor
type: executor
extra_build_args:
default: ""
description: |
Extra flags to pass to docker build. For examples, see https://docs.docker.com/engine/reference/commandline/build Pass the desired args using an equal sign (=) instead of an space. For example, --build-arg=ARG1=value, instead of --build-arg ARG1=vallue.
type: string
image:
description: Name of image to build
type: string
lint-dockerfile:
default: false
description: |
Lint Dockerfile before building?
type: boolean
path:
default: .
description: |
Path to the directory containing your Dockerfile, defaults to . (working directory)
type: string
readme:
default: README.md
description: Name of the file containing the image description to update, defaults to README.md
type: string
registry:
default: docker.io
description: |
Name of registry to use, defaults to docker.io
type: string
remote-docker-dlc:
default: false
description: |
Enable docker layer caching if using remote Docker engine. Defaults to false.
type: boolean
remote-docker-version:
default: default
description: |
Pick remote Docker engine version. Available versions can be found at: https://circleci.com/docs/2.0/building-docker-images/#docker-version. Must be >= 18.09 for BuildKit support.
type: string
tag:
default: $CIRCLE_SHA1
description: Comma-separated list of image tags, defaults to the value of $CIRCLE_SHA1
type: string
treat-warnings-as-errors:
default: false
description: |
If linting Dockerfile, treat linting warnings as errors (would trigger an exist code and fail the CircleCI job)?
type: boolean
update-description:
default: false
description: Update the image description on Docker Hub?
type: boolean
use-buildkit:
default: false
description: |
Use buildkit to build the image. Available on Docker >= 18.09.0 https://docs.docker.com/develop/develop-images/build_enhancements/
type: boolean
use-docker-credentials-store:
default: false
description: |
Configure Docker to use a credentials store. This option is only supported on Ubuntu/Debian platforms.
type: boolean
use-remote-docker:
default: false
description: |
Setup a remote Docker engine for Docker commands? Only required if using a Docker-based executor
type: boolean
steps:
- checkout
- when:
condition: <<parameters.after_checkout>>
steps: <<parameters.after_checkout>>
- when:
condition: <<parameters.use-remote-docker>>
steps:
- setup_remote_docker:
docker_layer_caching: <<parameters.remote-docker-dlc>>
version: <<parameters.remote-docker-version>>
- when:
condition: <<parameters.attach-at>>
steps:
- attach_workspace:
at: <<parameters.attach-at>>
- when:
condition: <<parameters.deploy>>
steps:
- check:
docker-password: <<parameters.docker-password>>
docker-username: <<parameters.docker-username>>
registry: <<parameters.registry>>
use-docker-credentials-store: <<parameters.use-docker-credentials-store>>
- when:
condition: <<parameters.before_build>>
steps: <<parameters.before_build>>
- build:
cache_from: <<parameters.cache_from>>
cache_to: <<parameters.cache_to>>
docker-context: <<parameters.docker-context>>
dockerfile: <<parameters.dockerfile>>
extra_build_args: <<parameters.extra_build_args>>
image: <<parameters.image>>
lint-dockerfile: <<parameters.lint-dockerfile>>
path: <<parameters.path>>
registry: <<parameters.registry>>
tag: <<parameters.tag>>
treat-warnings-as-errors: <<parameters.treat-warnings-as-errors>>
use-buildkit: <<parameters.use-buildkit>>
- when:
condition: <<parameters.after_build>>
steps: <<parameters.after_build>>
- when:
condition: <<parameters.deploy>>
steps:
- push:
image: <<parameters.image>>
registry: <<parameters.registry>>
tag: <<parameters.tag>>
- when:
condition: <<parameters.update-description>>
steps:
- update-description:
docker-password: <<parameters.docker-password>>
docker-username: <<parameters.docker-username>>
image: <<parameters.image>>
path: <<parameters.path>>
readme: <<parameters.readme>>
registry: <<parameters.registry>>
examples:
build-and-update:
description: |
Build and publish, and update the description of an image using the publish job
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
update-description: true
build-docker-image-only-with-buildkit:
jobs:
- docker/publish:
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
remote-docker-version: 20.10.12
update-description: true
use-buildkit: true
use-remote-docker: true
build-push-digest:
description: |
Build and push an image, save the digest to a file and echo the file.
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
jobs:
build-and-push:
executor: docker/docker
steps:
- setup_remote_docker
- checkout
- docker/check
- docker/build:
image: my_repo/orb-test
- docker/push:
digest-path: /tmp/digest.txt
image: my_repo/orb-test
- run:
command: |
echo "Digest is: $(</tmp/digest.txt)"
workflows:
commit:
jobs:
- build-and-push
build-without-publishing:
description: |
Build, but don't publish, an image using the publish job
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
deploy: false
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
build-without-publishing-commands:
description: |
Build, but don't publish, an image using the check and build commands
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
jobs:
check-and-build-only:
executor: docker/machine
steps:
- checkout
- docker/check
- docker/build:
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
workflows:
build-docker-image-only:
jobs:
- check-and-build-only
custom-name-tag-executor:
description: |
Build and Deploy docker image with a custom name and tag, using a non-default executor with custom parameter values (note: when using a Docker-based excecutor, the `use-remote-docker` parameter must be set to true in order for Docker commands to run successfully).
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
build-and-publish-docker-image:
jobs:
- docker/publish:
executor:
image: circleci/node
name: docker/docker
tag: boron-browsers
image: my/image
remote-docker-dlc: true
tag: my-tag
use-remote-docker: true
custom-pull:
description: |
Use the pull command to pull one or more Docker images
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
jobs:
pull:
executor: docker/machine
steps:
- checkout
- docker/pull:
images: ubuntu:16.04,ubuntu:18.04
workflows:
pull-images:
jobs:
- pull
custom-readme-file:
description: |
Build, deploy, and update the description of a Docker image with a non-standard description file
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
build-and-publish-docker-image:
jobs:
- docker/publish:
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
path: path/to/Docker/build/context
readme: my.README.md
custom-registry-and-dockerfile:
description: |
Build and deploy a Docker image with a non-standard Dockerfile to a custom registry
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
build-and-publish-docker-image:
jobs:
- docker/publish:
dockerfile: my.Dockerfile
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
path: path/to/Docker/build/context
registry: my.docker.registry
hadolint:
description: |
Use hadolint to lint a Dockerfile
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
lint:
jobs:
- docker/hadolint:
dockerfiles: path/to/Dockerfile
executor-class: medium
hadolint-tag: 2.2.0-debian
ignore-rules: DL4005,DL3008
trusted-registries: docker.io,my-company.com:5000
install-docker-tools:
description: |
Quickly install Docker, docker-compose, and dockerize in any CircleCI job environment where they are missing
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
jobs:
your-job:
executor:
name: docker/docker
tag: "3.6"
steps:
- checkout
- docker/install-docker-tools
workflows:
your-workflow:
jobs:
- your-job
lifecycle-hooks:
description: |
Build and deploy a Docker image with custom lifecycle hooks: after checking out the code from the VCS repository, before building the Docker image, and after building the Docker image
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
build-and-publish-docker-image:
jobs:
- docker/publish:
after_build:
- run:
command: echo "Did this after the build"
name: Do this after the build
after_checkout:
- run:
command: echo "Did this after checkout"
name: Do this after checkout
before_build:
- run:
command: echo "Did this before the build"
name: Do this before the build
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
lint-dockerfile:
description: |
Use the `dockerlint` command to install Dockerlint and lint a Dockerfile
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
jobs:
lint:
executor: docker/machine
steps:
- checkout
- docker/dockerlint:
dockerfile: path/to/and/name/of/Dockerfile
treat-warnings-as-errors: true
workflows:
lint-dockerfile:
jobs:
- lint
login-with-credentials-store:
description: |
This demonstrates performing docker login with a credentials store configured, and then building an image with a Dockerfile in the root of your repository, naming the image to be the same name as your repository, and then pushing to the default docker registry (at docker.io)
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
build-and-publish-docker-image:
jobs:
- docker/publish:
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
use-docker-credentials-store: true
standard-build-and-push:
description: |
A standard Docker workflow, where you are building an image with a Dockerfile in the root of your repository, naming the image to be the same name as your repository, pushing to the default docker registry (at docker.io), and then updating the image description
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
build-and-publish-docker-image:
jobs:
- docker/publish:
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
with-bash-substitution:
description: |
Build/publish a Docker image bash substitution
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
image: ${CIRCLE_PROJECT_USERNAME,,}/${CIRCLE_PROJECT_REPONAME/_/-}
tag: ${CIRCLE_SHA1:0:10}
with-cache-from:
description: |
Build/publish a Docker image using --cache-from
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
cache_from: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME:latest
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
tag: latest
with-cache-to:
description: |
Build/publish a Docker image using --cache-to
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
cache_to: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME:cache
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
tag: latest
with-extra-build-args:
description: |
Build/publish a Docker image with extra build arguments
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
extra_build_args: --build-arg=FOO=bar --build-arg=BAZ=qux
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
with-multiple-tags:
description: |
Build/publish a Docker image with extra build arguments
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
tag: tag1,tag2,tag3
with-nested-dockerfile:
description: |
Build/publish a Docker image building from a nested Dockerfile
usage:
version: "2.1"
orbs:
docker: circleci/docker@x.y.z
workflows:
build-docker-image-only:
jobs:
- docker/publish:
docker-context: .
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
path: dockerfiles/prod