Skip to content

Commit c165467

Browse files
committed
Make development builds faster by putting GOCACHE outside the container
1 parent 10c66c7 commit c165467

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
build
2+
gocache
23
Dockerfile

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
build
2+
gocache/
23
debian/changelog
34
pkg/
45
.vscode/

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ GOTEST = $(GOCMD) test -v
1313
# Environment
1414
WORKDIR := $(shell pwd)
1515
BUILD_PATH := $(WORKDIR)/build
16+
GOCACHE_PATH = $(WORKDIR)/gocache
1617
DOCKER_IMAGE_BUILD = mcuadros/octoprint-tft-build
1718

1819
DEBIAN_PACKAGES = BUSTER
@@ -53,6 +54,7 @@ export
5354

5455
build-environment:
5556
mkdir -p ${BUILD_PATH}
57+
mkdir -p ${GOCACHE_PATH}
5658

5759
build: | build-environment $(DEBIAN_PACKAGES)
5860

@@ -65,14 +67,15 @@ $(DEBIAN_PACKAGES):
6567
&& \
6668
docker run --rm \
6769
-e TARGET_ARCH=${ARCH} \
68-
-v ${BUILD_PATH}/${${@}_NAME}:/build \
70+
-v ${BUILD_PATH}/${${@}_NAME}-${ARCH}:/build \
71+
-v ${GOCACHE_PATH}/${${@}_NAME}-${ARCH}:/gocache \
6972
${DOCKER_IMAGE_BUILD}:${${@}_NAME}-${ARCH} \
7073
make build-internal
7174

7275
build-internal: prepare-internal
7376
#go build --tags ${GO_TAGS} -v -o /build/bin/${BINARY_NAME} main.go
7477
cd $(WORKDIR); \
75-
debuild --prepend-path=/usr/local/go/bin/ --preserve-env -us -uc -a${TARGET_ARCH}; \
78+
GOCACHE=/gocache debuild --prepend-path=/usr/local/go/bin/ --preserve-env -us -uc -a${TARGET_ARCH}; \
7679
cp ../*.deb /build/;
7780

7881
prepare-internal:

debian/rules

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export DH_GOPKG := github.com/Z-Bolt/OctoScreen
77
export DH_GOLANG_BUILDPKG := github.com/Z-Bolt/OctoScreen
88
export DH_GOLANG_INSTALL_ALL := 1
99

10-
export GOCACHE := $(GOPATH)/pkg
1110
export GOPROXY := https://proxy.golang.org
1211
export GO111MODULE := on
1312

@@ -29,7 +28,6 @@ ifeq ($(_DH_GOLANG_WITH_CROSSBUILD_SUPPORT),0)
2928
export PKG_CONFIG_PATH := /usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig
3029
endif
3130

32-
3331
%:
3432
dh $@ --buildsystem=golang --with=golang,systemd
3533

0 commit comments

Comments
 (0)