Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse the proxy's build stage across CI runs #891

Merged
merged 5 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
cache:
directories:
- "$HOME/google-cloud-sdk/"
- "$HOME/.cache"

before_install:
- docker version
Expand Down Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions bin/docker-build-proxy
Original file line number Diff line number Diff line change
Expand Up @@ -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