-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from seek-oss/build-args
Support --build-arg options
- Loading branch information
Showing
3 changed files
with
131 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,127 @@ | ||
# Docker ECR Cache | ||
# Docker ECR Cache Buildkite Plugin | ||
|
||
A [Buildkite plugin](https://buildkite.com/docs/agent/v3/plugins) to build and cache entire docker images in ECR. | ||
[![GitHub Release](https://img.shields.io/github/release/seek-oss/docker-ecr-cache-buildkite-plugin.svg)](https://github.com/seek-oss/docker-ecr-cache-buildkite-plugin/releases) | ||
|
||
This allows you to define a Dockerfile for your build-time dependencies without worrying about the time it | ||
takes to build the image. It allows you to re-use entire docker images without worrying about layer caching, and/or pruning | ||
layers as changes are made to your containers. | ||
A [Buildkite plugin](https://buildkite.com/docs/agent/v3/plugins) to cache | ||
Docker images in Amazon ECR. | ||
|
||
An ECR repository to store the built docker image will be created for you, if one doesn't already exist. | ||
This allows you to define a Dockerfile for your build-time dependencies without | ||
worrying about the time it takes to build the image. It allows you to re-use | ||
entire Docker images without worrying about layer caching, and/or pruning layers | ||
as changes are made to your containers. | ||
|
||
# Example | ||
An ECR repository to store the built Docker image will be created for you, if | ||
one doesn't already exist. | ||
|
||
## Basic Usage | ||
## Example | ||
|
||
Dockerfile | ||
``` | ||
### Basic usage | ||
|
||
```dockerfile | ||
FROM bash | ||
|
||
RUN echo "my expensive build step" | ||
``` | ||
|
||
```yml | ||
```yaml | ||
steps: | ||
- command: 'echo wow' | ||
plugins: | ||
- seek-oss/docker-ecr-cache#v1.1.1 | ||
- docker#v2.0.0 | ||
- seek-oss/docker-ecr-cache#v1.1.3 | ||
- docker#v3.0.1 | ||
``` | ||
## Caching NPM Packages | ||
### Caching npm packages | ||
This plugin can be used to effectively cache `node_modules` between builds without worrying abbout | ||
docker layer cache invalidation. You do this by hinting when the image should be re-built. | ||
This plugin can be used to effectively cache `node_modules` between builds | ||
without worrying about Docker layer cache invalidation. You do this by hinting | ||
when the image should be re-built. | ||
|
||
```dockerfile | ||
FROM node:10-alpine | ||
Dockerfile | ||
``` | ||
FROM node:8 | ||
WORKDIR /workdir | ||
COPY package.json package-lock.json /workdir | ||
# this step downloads the internet | ||
RUN npm install | ||
``` | ||
|
||
```yml | ||
```yaml | ||
steps: | ||
- command: 'npm test' | ||
plugins: | ||
- seek-oss/docker-ecr-cache#v1.1.1: | ||
- seek-oss/docker-ecr-cache#v1.1.3: | ||
cache-on: | ||
- package-lock.json | ||
- docker#v2.0.0 | ||
- docker#v3.0.1: | ||
volumes: | ||
- /workdir/node_modules | ||
``` | ||
|
||
## Using Another Dockerfile | ||
### Using another Dockerfile | ||
|
||
It's possible to specify the Dockerfile to use by: | ||
|
||
```yml | ||
```yaml | ||
steps: | ||
- command: 'echo wow' | ||
plugins: | ||
- seek-oss/docker-ecr-cache#v1.1.1: | ||
- seek-oss/docker-ecr-cache#v1.1.3: | ||
dockerfile: my-dockerfile | ||
- docker#v2.0.0 | ||
- docker#v3.0.1 | ||
``` | ||
|
||
## Specifying a target step | ||
### Specifying a target step | ||
|
||
A [multi-stage Docker build](https://docs.docker.com/develop/develop-images/multistage-build/) can be used to reduce an application container to just its runtime dependencies. | ||
However, this stripped down container may not have the environment necessary for running CI commands such as tests or linting. | ||
Instead, the `target` property can be used to specify an intermediate build stage to run commands against: | ||
A [multi-stage Docker build] can be used to reduce an application container to | ||
just its runtime dependencies. However, this stripped down container may not | ||
have the environment necessary for running CI commands such as tests or linting. | ||
Instead, the `target` property can be used to specify an intermediate build | ||
stage to run commands against: | ||
|
||
```yml | ||
[multi-stage docker build]: https://docs.docker.com/develop/develop-images/multistage-build/ | ||
|
||
```yaml | ||
steps: | ||
- command: 'cargo test' | ||
plugins: | ||
- seek-oss/docker-ecr-cache#v1.1.1: | ||
- seek-oss/docker-ecr-cache#v1.1.3: | ||
target: build-deps | ||
- docker#v2.0.0 | ||
- docker#v3.0.1 | ||
``` | ||
|
||
# Tests | ||
### Specifying build args | ||
|
||
[Build-time variables] are supported, either with an explicit value, or without | ||
one to propagate an environment variable from the pipeline step: | ||
|
||
To run the tests of this plugin, run | ||
```sh | ||
docker-compose run --rm tests | ||
[build-time variables]: https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg | ||
|
||
```dockerfile | ||
FROM bash | ||
ARG ARG_1 | ||
ARG ARG_2 | ||
RUN echo "${ARG_1}" | ||
RUN echo "${ARG_2}" | ||
``` | ||
|
||
```yaml | ||
steps: | ||
- command: 'echo amaze' | ||
env: | ||
ARG_1: wow | ||
plugins: | ||
- seek-oss/docker-ecr-cache#v1.1.3: | ||
build-args: | ||
- ARG_1 | ||
- ARG_2=such | ||
- docker#v3.0.1 | ||
``` | ||
|
||
# License | ||
## License | ||
|
||
MIT (see [LICENSE](LICENSE)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters