Skip to content

Commit 25c51c2

Browse files
committed
feat(Makefile): compress go binaries
1 parent cab1133 commit 25c51c2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootfs/opt/registry/sbin/registry
1+
rootfs/opt/

Makefile

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ REPO_PATH = github.com/deis/registry
1313
# and other build options
1414
DEV_ENV_IMAGE := quay.io/deis/go-dev:0.10.0
1515
DEV_ENV_WORK_DIR := /go/src/${REPO_PATH}
16-
DEV_ENV_CMD := docker run --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} ${DEV_ENV_IMAGE}
16+
DEV_ENV_PREFIX := docker run --rm -e GO15VENDOREXPERIMENT=1 -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR}
17+
DEV_ENV_CMD := ${DEV_ENV_PREFIX} ${DEV_ENV_IMAGE}
1718
LDFLAGS := "-s -X main.version=${VERSION}"
1819
BINDIR := ./rootfs/opt/registry/sbin
1920

@@ -34,7 +35,7 @@ all:
3435

3536
build: check-docker
3637
mkdir -p ${BINDIR}
37-
${DEV_ENV_CMD} make build-binary
38+
$(MAKE) build-binary
3839

3940
# For cases where we're building from local
4041
# We also alter the RC file to set the image name.
@@ -47,7 +48,9 @@ docker-push: check-docker check-registry
4748
docker push ${IMAGE}
4849

4950
build-binary:
50-
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags ${LDFLAGS} -o $(BINDIR)/${SHORT_NAME} main.go
51+
${DEV_ENV_PREFIX} -e CGO_ENABLED=0 ${DEV_ENV_IMAGE} go build -a -installsuffix cgo -ldflags ${LDFLAGS} -o $(BINDIR)/${SHORT_NAME} main.go
52+
$(call check-static-binary,$(BINDIR)/${SHORT_NAME})
53+
${DEV_ENV_PREFIX} ${DEV_ENV_IMAGE} goupx --strip-binary -9 --brute $(BINDIR)/${SHORT_NAME}
5154

5255
# Deploy is a Kubernetes-oriented target
5356
deploy: kube-secret kube-service kube-rc

0 commit comments

Comments
 (0)