From 4f7a49ed78b89bfcf4871c43cd972d0bdb7e1ca5 Mon Sep 17 00:00:00 2001 From: Doug Davis <dug@us.ibm.com> Date: Fri, 24 Jun 2016 08:41:11 -0700 Subject: [PATCH] Build binary in a docker container So that people don't need to install all dependencies just to build. Make it so that "make binary" does nothing if nothing changed. Remove ${DEST} Signed-off-by: Doug Davis <dug@us.ibm.com> --- Dockerfile.build | 5 +++++ Makefile | 14 ++++++++++++-- hack/make/test-integration | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 Dockerfile.build diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 00000000..a26c621d --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,5 @@ +FROM ubuntu:16.04 +RUN apt-get update +RUN apt-get install -y golang git-core libgpgme11-dev +ENV GOPATH=/ +WORKDIR /src/github.com/projectatomic/skopeo diff --git a/Makefile b/Makefile index 1c53fc1a..f2650467 100644 --- a/Makefile +++ b/Makefile @@ -25,8 +25,18 @@ GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null || true) all: binary -binary: - go build -ldflags "-X main.gitCommit=${GIT_COMMIT}" -o ${DEST}skopeo ./cmd/skopeo +binary: skopeo + +# Build a docker image (skopeobuild) that has everything we need to build. +# Then do the build and the output (skopeo) should appear in current dir +skopeo: cmd/skopeo + docker build ${DOCKER_BUILD_ARGS} -f Dockerfile.build -t skopeobuildimage . + docker run --rm -v ${PWD}:/src/github.com/projectatomic/skopeo \ + skopeobuildimage make binary-local + +# Build w/o using Docker containers +binary-local: + go build -ldflags "-X main.gitCommit=${GIT_COMMIT}" -o skopeo ./cmd/skopeo build-container: docker build ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" . diff --git a/hack/make/test-integration b/hack/make/test-integration index cb3b6c71..ac9704d4 100755 --- a/hack/make/test-integration +++ b/hack/make/test-integration @@ -8,7 +8,7 @@ bundle_test_integration() { # subshell so that we can export PATH without breaking other things ( - make binary + make binary-local make install-binary export GO15VENDOREXPERIMENT=1 bundle_test_integration