Skip to content

Commit ced7d8b

Browse files
authored
Merge pull request #38 from seek-oss/more-env-vars
Export additional env vars for programmatic usage
2 parents 058047e + a424337 commit ced7d8b

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,39 @@ steps:
105105
- docker#v3.8.0
106106
```
107107

108+
### Building on the resulting image
109+
110+
The resulting image are exported as environment variables:
111+
112+
- `BUILDKITE_PLUGIN_DOCKER_IMAGE` (or whatever is specified per [changing the name of exported variable](#changing-the-name-of-exported-variable)) for the combined `image:tag` value
113+
- `BUILDKITE_PLUGIN_DOCKER_ECR_CACHE_EXPORT_IMAGE` for the `image` by itself
114+
- `BUILDKITE_PLUGIN_DOCKER_ECR_CACHE_EXPORT_TAG` for the `tag` by itself
115+
116+
These variables can be used by subsequent plugins and commands in the same build step.
117+
For example, you may have a command that propagates these variables to another Docker build command:
118+
119+
```yaml
120+
steps:
121+
- command: >-
122+
docker build
123+
--build-arg BUILDKITE_PLUGIN_DOCKER_ECR_CACHE_EXPORT_IMAGE
124+
--build-arg BUILDKITE_PLUGIN_DOCKER_ECR_CACHE_EXPORT_TAG
125+
--file Dockerfile.secondary
126+
plugins:
127+
- seek-oss/docker-ecr-cache#v1.10.0
128+
```
129+
130+
Your `Dockerfile.secondary` can then [dynamically use these args](https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact):
131+
132+
```dockerfile
133+
ARG BUILDKITE_PLUGIN_DOCKER_ECR_CACHE_EXPORT_IMAGE
134+
ARG BUILDKITE_PLUGIN_DOCKER_ECR_CACHE_EXPORT_TAG
135+
136+
FROM ${BUILDKITE_PLUGIN_DOCKER_ECR_CACHE_EXPORT_IMAGE}:${BUILDKITE_PLUGIN_DOCKER_ECR_CACHE_EXPORT_TAG}
137+
138+
RUN echo wow
139+
```
140+
108141
### Specifying a target step
109142

110143
A [multi-stage Docker build] can be used to reduce an application container to

hooks/pre-command

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,7 @@ fi || echo "Not found"
8282

8383
# Support using https://github.com/buildkite-plugins/docker-buildkite-plugin without an image by default
8484
export ${export_env_variable}="${image}:${tag}"
85+
86+
# Support programmatic use of cache image and tag values
87+
export BUILDKITE_PLUGIN_DOCKER_ECR_CACHE_EXPORT_IMAGE="${image}"
88+
export BUILDKITE_PLUGIN_DOCKER_ECR_CACHE_EXPORT_TAG="${tag}"

0 commit comments

Comments
 (0)