mirror of https://github.com/linkerd/linkerd2.git
Reuse the proxy's build stage across CI runs (#891)
The proxy's Dockerfile is split into stages: build and runtime. The build stage includes all of the intermdiate build information, and the runtime image discards these layers with a small production-ready image. In order to improve docker build times, we can save this build layer to be reused. This reduces the docker build of the proxy in CI from 15 minutes to about 7.5 minutes (when the proxy is not changed).
This commit is contained in:
parent
b48a26b0b7
commit
e5ad5de975
13
.travis.yml
13
.travis.yml
|
@ -84,6 +84,7 @@ jobs:
|
|||
cache:
|
||||
directories:
|
||||
- "$HOME/google-cloud-sdk/"
|
||||
- "$HOME/.cache"
|
||||
|
||||
before_install:
|
||||
- docker version
|
||||
|
@ -124,11 +125,19 @@ jobs:
|
|||
export CONDUIT_TAG=$(. bin/_tag.sh ; clean_head_root_tag)
|
||||
echo "CONDUIT_TAG=${CONDUIT_TAG}"
|
||||
- export BUILD_DEBUG=1 DOCKER_TRACE=1
|
||||
- export DOCKER_CACHE="$HOME/.cache/docker.tgz" PROXY_BUILD_CACHE_IMAGE="proxy-build:cache"
|
||||
- if [ -f "$DOCKER_CACHE" ]; then gunzip -c "$DOCKER_CACHE" | docker load ; docker image ls "$PROXY_BUILD_CACHE_IMAGE" ; fi
|
||||
|
||||
script:
|
||||
# We re-run the tests here in *release* (--release) mode since the
|
||||
# `test` stage only runs them in *debug* mode.
|
||||
- docker build . -f $rootdir/proxy/Dockerfile \
|
||||
--build-arg="PROXY_UNOPTIMIZED=${PROXY_UNOPTIMIZED:-}" \
|
||||
--cache-from="$PROXY_BUILD_CACHE_IMAGE" \
|
||||
--tag "$PROXY_BUILD_CACHE_IMAGE" \
|
||||
--target build
|
||||
# bin/docker-build-proxy uses PROXY_BUILD_CACHE_IMAGE.
|
||||
- bin/docker-build
|
||||
# The proxy's build cache is preserved so it can be reused on subsequent runs.
|
||||
- docker save gcr.io/runconduit/proxy-build:cache | gzip -9 >"$DOCKER_CACHE"
|
||||
|
||||
after_success:
|
||||
- bin/docker-push-deps
|
||||
|
|
|
@ -13,5 +13,14 @@ rootdir="$( cd $bindir/.. && pwd )"
|
|||
. $bindir/_docker.sh
|
||||
. $bindir/_tag.sh
|
||||
|
||||
docker_build proxy "$(head_root_tag)" $rootdir/proxy/Dockerfile \
|
||||
--build-arg="PROXY_UNOPTIMIZED=${PROXY_UNOPTIMIZED:-}"
|
||||
if [ -z "${PROXY_BUILD_CACHE_IMAGE:-}" ]; then
|
||||
# If a cache is not specified use the default docker cache.
|
||||
docker_build proxy "$(head_root_tag)" $rootdir/proxy/Dockerfile \
|
||||
--build-arg="PROXY_UNOPTIMIZED=${PROXY_UNOPTIMIZED:-}"
|
||||
|
||||
else
|
||||
# Otherwise, if a cache image is specified, use it.
|
||||
docker_build proxy "$(head_root_tag)" $rootdir/proxy/Dockerfile \
|
||||
--build-arg="PROXY_UNOPTIMIZED=${PROXY_UNOPTIMIZED:-}" \
|
||||
--cache-from="$PROXY_BUILD_CACHE_IMAGE"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue