File tree Expand file tree Collapse file tree
fixtures/dex-images/cachebust Expand file tree Collapse file tree Original file line number Diff line number Diff 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# ...
160160RUN 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
172177RUN git clone my-repo/my-app.git /app
173178# ...
174179```
Original file line number Diff line number Diff 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"
Original file line number Diff line number Diff 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)
Original file line number Diff line number Diff line change @@ -4,5 +4,5 @@ LABEL org.dockerland.dex.api="v1"
44CMD echo "ALPINE_RELEASE=$(cat /etc/alpine-release)" ; printenv
55
66# bust some cache
7- ARG CACHE_BUST
7+ ARG DEXBUILD_NOCACHE
88RUN echo "I always execute"
You can’t perform that action at this time.
0 commit comments