Skip to content

Commit

Permalink
Allow the /root/go/src to be cached during docker build.
Browse files Browse the repository at this point in the history
The docker build is rather punishing on 4G bandwidth consumption.

Allow the user to cache the /root/go/src directory if they so choose, but
default to not using such a cache.

Signed-off-by: Jon Seymour <[email protected]>
  • Loading branch information
jonseymour committed Mar 17, 2016
1 parent 22b917b commit ea5422d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile_build_ubuntu64
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ RUN mkdir -p $PROJECT_DIR
WORKDIR $PROJECT_DIR

VOLUME $PROJECT_DIR
VOLUME /root/go/src

ENTRYPOINT [ "/root/go/src/github.com/influxdata/kapacitor/build.py" ]
11 changes: 10 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,23 @@ set -e
DIR=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)
cd $DIR


# Build new docker image
docker build -f Dockerfile_build_ubuntu64 -t influxdata/kapacitor-builder $DIR
if test "${KAPACITOR_USE_BUILD_CACHE}" = "true"; then
# create a container that owns the /root/go/src volume used as a cache of go dependency downloads
# ignore failures, since this usually means the container already exists.
docker run --entrypoint=/bin/true --name kapacitor-builder-cache influxdata/kapacitor-builder 2>/dev/null &&
VOLUME_OPTIONS=--volumes-from kapacitor-builder-cache || true
else
VOLUME_OPTIONS=
fi

echo "Running build.py"
# Run docker
docker run --rm \
-e AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" \
-e AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" \
${VOLUME_OPTIONS} \
-v $DIR:/root/go/src/github.com/influxdata/kapacitor \
influxdata/kapacitor-builder \
"$@"

0 comments on commit ea5422d

Please sign in to comment.