Skip to content

Instantly share code, notes, and snippets.

@jwendell
Created January 5, 2018 15:18
Show Gist options
  • Save jwendell/64bfbd9ae69a77409e0a23aee562cd91 to your computer and use it in GitHub Desktop.
Save jwendell/64bfbd9ae69a77409e0a23aee562cd91 to your computer and use it in GitHub Desktop.
diff --git a/Makefile b/Makefile
index c42f3da5..c1447d6b 100644
--- a/Makefile
+++ b/Makefile
@@ -23,12 +23,13 @@ VERSION ?= "0.5.0"
# Make sure GOPATH is set based on the executing Makefile and workspace. Will override
# GOPATH from the env.
-export GOPATH= $(shell cd ../../..; pwd)
+GOPATH ?= $(shell cd ../../..; pwd)
+GOPATH1 := $(shell echo ${GOPATH} | cut -d ':' -f1)
export CGO_ENABLE=0
# OUT is the directory where dist artifacts and temp files will be created.
-OUT=${GOPATH}/out
+OUT=${GOPATH1}/out
GO ?= go
@@ -47,7 +48,7 @@ GO_FILES := $(shell find . -name '*.go' | grep -v -E '$(GO_EXCLUDE)')
# Environment for tests, the directory containing istio and deps binaries.
# Typically same as GOPATH/bin, so tests work seemlessly with IDEs.
-export ISTIO_BIN=${GOPATH}/bin
+export ISTIO_BIN=${GOPATH1}/bin
hub = ""
tag = ""
@@ -96,16 +97,16 @@ depend.ensure: init
# Target to update the Gopkg.lock with latest versions.
# Should be run when adding any new dependency and periodically.
-depend.update: ${GOPATH}/bin/dep; $(info $(H) ensuring dependencies are up to date...)
+depend.update: ${GOPATH1}/bin/dep; $(info $(H) ensuring dependencies are up to date...)
dep ensure
dep ensure -update
cp Gopkg.lock vendor/Gopkg.lock
-${GOPATH}/bin/dep:
+${GOPATH1}/bin/dep:
go get -u github.com/golang/dep/cmd/dep
-Gopkg.lock: Gopkg.toml | ${GOPATH}/bin/dep ; $(info $(H) generating) @
- $(Q) ${GOPATH}/bin/dep ensure -update
+Gopkg.lock: Gopkg.toml | ${GOPATH1}/bin/dep ; $(info $(H) generating) @
+ $(Q) ${GOPATH1}/bin/dep ensure -update
depend.status: Gopkg.lock
$(Q) dep status > vendor/dep.txt
@@ -172,36 +173,36 @@ build: setup go-build
# Params: OUT VERSION_PKG SRC
.PHONY: pilot
-pilot: vendor
- bin/gobuild.sh ${GOPATH}/bin/pilot-discovery istio.io/istio/pilot/tools/version ./pilot/cmd/pilot-discovery
+pilot:
+ bin/gobuild.sh ${GOPATH1}/bin/pilot-discovery istio.io/istio/pilot/tools/version ./pilot/cmd/pilot-discovery
.PHONY: pilot-agent
-pilot-agent: vendor
- bin/gobuild.sh ${GOPATH}/bin/pilot-agent istio.io/istio/pilot/tools/version ./pilot/cmd/pilot-agent
+pilot-agent:
+ bin/gobuild.sh ${GOPATH1}/bin/pilot-agent istio.io/istio/pilot/tools/version ./pilot/cmd/pilot-agent
.PHONY: istioctl
-istioctl: vendor
- bin/gobuild.sh ${GOPATH}/bin/istioctl istio.io/istio/pilot/tools/version ./pilot/cmd/istioctl
+istioctl:
+ bin/gobuild.sh ${GOPATH1}/bin/istioctl istio.io/istio/pilot/tools/version ./pilot/cmd/istioctl
.PHONY: sidecar-initializer
-sidecar-initializer: vendor
- bin/gobuild.sh ${GOPATH}/bin/sidecar-initializer istio.io/istio/pilot/tools/version ./pilot/cmd/sidecar-initializer
+sidecar-initializer:
+ bin/gobuild.sh ${GOPATH1}/bin/sidecar-initializer istio.io/istio/pilot/tools/version ./pilot/cmd/sidecar-initializer
.PHONY: mixs
-mixs: vendor
- bin/gobuild.sh ${GOPATH}/bin/mixs istio.io/istio/mixer/pkg/version ./mixer/cmd/mixs
+mixs:
+ bin/gobuild.sh ${GOPATH1}/bin/mixs istio.io/istio/mixer/pkg/version ./mixer/cmd/mixs
.PHONY: mixc
-mixc: vendor
- CGO_ENABLED=0 go build ${GOSTATIC} -o ${GOPATH}/bin/mixc istio.io/istio/mixer/cmd/mixc
+mixc:
+ CGO_ENABLED=0 go build ${GOSTATIC} -o ${GOPATH1}/bin/mixc istio.io/istio/mixer/cmd/mixc
.PHONY: node-agent
-node-agent: vendor
- bin/gobuild.sh ${GOPATH}/bin/node_agent istio.io/istio/security/cmd/istio_ca/version ./security/cmd/node_agent
+node-agent:
+ bin/gobuild.sh ${GOPATH1}/bin/node_agent istio.io/istio/security/cmd/istio_ca/version ./security/cmd/node_agent
.PHONY: istio-ca
-istio-ca: vendor
- bin/gobuild.sh ${GOPATH}/bin/istio_ca istio.io/istio/security/cmd/istio_ca/version ./security/cmd/istio_ca
+istio-ca:
+ bin/gobuild.sh ${GOPATH1}/bin/istio_ca istio.io/istio/security/cmd/istio_ca/version ./security/cmd/istio_ca
go-build: pilot istioctl pilot-agent sidecar-initializer mixs mixc node-agent istio-ca
@@ -216,9 +217,9 @@ GOTEST_P ?= -p 1
GOSTATIC = -ldflags '-extldflags "-static"'
testApps:
- CGO_ENABLED=0 go build ${GOSTATIC} -o ${GOPATH}/bin/server istio.io/istio/pilot/test/server
- CGO_ENABLED=0 go build ${GOSTATIC} -o ${GOPATH}/bin/client istio.io/istio/pilot/test/client
- CGO_ENABLED=0 go build ${GOSTATIC} -o ${GOPATH}/bin/eurekamirror istio.io/istio/pilot/test/eurekamirror
+ CGO_ENABLED=0 go build ${GOSTATIC} -o ${GOPATH1}/bin/server istio.io/istio/pilot/test/server
+ CGO_ENABLED=0 go build ${GOSTATIC} -o ${GOPATH1}/bin/client istio.io/istio/pilot/test/client
+ CGO_ENABLED=0 go build ${GOSTATIC} -o ${GOPATH1}/bin/eurekamirror istio.io/istio/pilot/test/eurekamirror
localTestEnv: testApps
bin/testEnvLocalK8S.sh ensure
@@ -294,7 +295,7 @@ docker:
# Build docker images for pilot
docker.pilot-debug: pilot pilot-agent sidecar-initializer
- cp ${GOPATH}/bin/{pilot-discovery,pilot-agent,sidecar-initializer} pilot/docker
+ cp ${GOPATH1}/bin/{pilot-discovery,pilot-agent,sidecar-initializer} pilot/docker
time (cd pilot/docker && docker build -t ${HUB}/proxy_debug:${TAG} -f Dockerfile.proxy_debug .)
time (cd pilot/docker && docker build -t ${HUB}/proxy_init:${TAG} -f Dockerfile.proxy_init .)
time (cd pilot/docker && docker build -t ${HUB}/sidecar_initializer:${TAG} -f Dockerfile.sidecar_initializer .)
@@ -302,23 +303,23 @@ docker.pilot-debug: pilot pilot-agent sidecar-initializer
# Build all docker debug images
docker.debug: docker.pilot-debug mixs mixc node-agent istio-ca
- cp ${GOPATH}/bin/mixs mixer/docker
+ cp ${GOPATH1}/bin/mixs mixer/docker
cp docker/ca-certificates.tgz mixer/docker
time (cd mixer/docker && docker build -t ${HUB}/mixer_debug:${TAG} -f Dockerfile.debug .)
- cp ${GOPATH}/bin/{istio_ca,node_agent} security/docker
+ cp ${GOPATH1}/bin/{istio_ca,node_agent} security/docker
cp docker/ca-certificates.tgz security/docker/
time (cd security/docker && docker build -t ${HUB}/istio-ca:${TAG} -f Dockerfile.istio-ca .)
docker.pilot-test: testApps
- cp ${GOPATH}/bin/{client,server,eurekamirror} pilot/docker
+ cp ${GOPATH1}/bin/{client,server,eurekamirror} pilot/docker
time (cd pilot/docker && docker build -t ${HUB}/app:${TAG} -f Dockerfile.app .)
time (cd pilot/docker && docker build -t ${HUB}/eurekamirror:${TAG} -f Dockerfile.eurekamirror .)
# Build extra docker debug images (examples, etc)
docker.test: docker.pilot-test
cp -a mixer/example/servicegraph/js/viz mixer/example/servicegraph/docker
- bin/gobuild.sh ${GOPATH}/bin/servicegraph istio.io/istio/mixer/pkg/version ./mixer/example/servicegraph/cmd/server
- cp ${GOPATH}/bin/servicegraph mixer/example/servicegraph/docker
+ bin/gobuild.sh ${GOPATH1}/bin/servicegraph istio.io/istio/mixer/pkg/version ./mixer/example/servicegraph/cmd/server
+ cp ${GOPATH1}/bin/servicegraph mixer/example/servicegraph/docker
time (cd mixer/example/servicegraph/docker && docker build -t ${HUB}/servicegraph_debug:${TAG} -f Dockerfile.debug .)
# TODO: generate or checkin test CA and keys
security/bin/gen-keys.sh
@@ -377,7 +378,7 @@ include .circleci/Makefile
# Make the deb image using the CI/CD image and docker.
docker.sidecar.deb:
(cd ${TOP}; docker run --rm -u $(shell id -u) -it \
- -v ${GOPATH}:${GOPATH} \
+ -v ${GOPATH1}:${GOPATH1} \
-w ${PWD} \
-e USER=${USER} \
--entrypoint /usr/bin/make ${CI_HUB}/ci:${CI_VERSION} \
@@ -392,7 +393,7 @@ sidecar.deb: ${OUT}/istio-sidecar.deb
${OUT}/istio-sidecar.deb:
mkdir -p ${OUT}
- fpm -s dir -t deb -n istio-sidecar -p ${OUT}/istio-sidecar.deb --version ${VERSION} --iteration 1 -C ${GOPATH} -f \
+ fpm -s dir -t deb -n istio-sidecar -p ${OUT}/istio-sidecar.deb --version ${VERSION} --iteration 1 -C ${GOPATH1} -f \
--url http://istio.io \
--license Apache \
--vendor istio.io \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment