Skip to content

Commit b5772cf

Browse files
committed
replace CACHE_BUST with DEXBUILD_NOCACHE
1 parent 3a78aa5 commit b5772cf

4 files changed

Lines changed: 16 additions & 11 deletions

File tree

docs/HOWTO.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,24 +151,29 @@ dex run --pull local/my-app
151151
```
152152

153153

154-
#### busting cache
154+
#### busting cache ( DEXBUILD_NOCACHE )
155155

156-
Often, images will use a git repository to install an application. E.g.
156+
Sometimes images will use a git repository to install an application. E.g.
157157

158158
```
159159
# ...
160160
RUN git clone my-repo/my-app.git /app
161161
# ...
162162
```
163163

164-
Docker will cache this, and use it's cache for subsequent builds -- no matter
165-
if the git repository and application code has been changed upstream. To get
166-
around this, dex builds images with a CACHE_BUST argument. Use this to introduce
167-
randomness and force the git clone command. E.g.
164+
The command is fingerprinted and its results cached in Docker's build-cache.
165+
On subsequent builds the command fingerprint maintains the same, so Docker
166+
returns the results from the build-cache. Your application code WILL NOT CHANGE
167+
no matter if changes have been made upstream.
168+
169+
Dex provides a convenient way around this cache. Invoke the `DEXBUILD_NOCACHE`
170+
build argument and _all_ subsequent commands will have a changed fingerprint --
171+
and thus execute.
168172

169173
```
170174
# ...
171-
ARG CACHE_BUST
175+
# bust the cache so git clone (and ALL subsequent commands) runs
176+
ARG DEXBUILD_NOCACHE
172177
RUN git clone my-repo/my-app.git /app
173178
# ...
174179
```

lib.d/dex-image.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ dex-image-build(){
4343
cd $image_dir
4444

4545
# add cachebusting argument if requested/used in Dockerfile
46-
grep -q "^ARG CACHE_BUST" $dockerfile && \
47-
cachebust="--build-arg CACHE_BUST=$random"
46+
grep -q "^ARG DEXBUILD_NOCACHE" $dockerfile && \
47+
cachebust="--build-arg DEXBUILD_NOCACHE=$random"
4848

4949
$__pull_flag && \
5050
pull="--pull"

tests/bats/05-image.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ setup(){
8989
[ "$first_sha" = "$second_sha" ]
9090
}
9191

92-
@test "image build uses CACHE_BUST argument to circumvent docker build cache" {
92+
@test "image build uses DEXBUILD_NOCACHE argument to circumvent docker build cache" {
9393
run $DEX image build imgtest/cachebust:nocache
9494
[ $status -eq 0 ]
9595
first_sha=$(docker inspect -f '{{ .Id }}' $DEX_NAMESPACE/cachebust:nocache)

tests/fixtures/dex-images/cachebust/Dockerfile-nocache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ LABEL org.dockerland.dex.api="v1"
44
CMD echo "ALPINE_RELEASE=$(cat /etc/alpine-release)" ; printenv
55

66
# bust some cache
7-
ARG CACHE_BUST
7+
ARG DEXBUILD_NOCACHE
88
RUN echo "I always execute"

0 commit comments

Comments
 (0)