From 12cc3a9cbf784bb033b6232ae2e8e05fbd060504 Mon Sep 17 00:00:00 2001 From: fightingdu Date: Thu, 3 Nov 2016 15:30:09 +0800 Subject: [PATCH] Add static compile target in Makefile. Add install `go-md2man` in Dockerfile.build Signed-off-by: Ye Yin --- Dockerfile.build | 2 +- Makefile | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Dockerfile.build b/Dockerfile.build index a26c621d..5c828e9e 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -1,5 +1,5 @@ FROM ubuntu:16.04 RUN apt-get update -RUN apt-get install -y golang git-core libgpgme11-dev +RUN apt-get install -y golang git-core libgpgme11-dev go-md2man ENV GOPATH=/ WORKDIR /src/github.com/projectatomic/skopeo diff --git a/Makefile b/Makefile index c2ff5fb4..3f853a33 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ MANPAGES_MD = $(wildcard docs/*.md) # Note: Uses the -N -l go compiler options to disable compiler optimizations # and inlining. Using these build options allows you to subsequently # use source debugging tools like delve. -all: binary docs +all: binary binary-static docs # 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 @@ -45,10 +45,17 @@ binary: cmd/skopeo docker run --rm --security-opt label:disable -v $$(pwd):/src/github.com/projectatomic/skopeo \ skopeobuildimage make binary-local $(if $(DEBUG),DEBUG=$(DEBUG)) +binary-static: cmd/skopeo + docker build ${DOCKER_BUILD_ARGS} -f Dockerfile.build -t skopeobuildimage . + docker run --rm --security-opt label:disable -v $$(pwd):/src/github.com/projectatomic/skopeo \ + skopeobuildimage make binary-local-static $(if $(DEBUG),DEBUG=$(DEBUG)) + # Build w/o using Docker containers binary-local: go build -ldflags "-X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -o skopeo ./cmd/skopeo +binary-local-static: + go build -ldflags "-extldflags \"-static\" -X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -o skopeo ./cmd/skopeo build-container: docker build ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" .