From 6e6a1cbbb6cba94ff0c52012d8eca5a39166576c Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Fri, 9 Apr 2021 17:11:51 +0200 Subject: [PATCH] fix: adapt go proxy settings --- Dockerfile | 4 +++- Makefile | 32 ++++++++++++-------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index f3d11db..5e9cba0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,9 @@ ARG VERSION # ================================== FROM ${BUILD_IMAGE} AS build COPY . /workspace -RUN make ${EXECUTABLE_TARGET} VERSION=${VERSION} GOPROXY=${GOPROXY} GOPRIVATE=${GOPRIVATE} +ENV GOPROXY=${GOPROXY} +ENV GOPRIVATE=${GOPRIVATE} +RUN make ${EXECUTABLE_TARGET} VERSION=${VERSION} # TARGET # ================================== diff --git a/Makefile b/Makefile index aa60c6a..ebb3990 100644 --- a/Makefile +++ b/Makefile @@ -3,14 +3,6 @@ # value is taken. VERSION?=$(shell git describe --abbrev=0)+$(shell date +'%Y%m%d%H%I%S') -# GOPROXY settings -# If no GOPROXY environment variable available, the pre-defined GOPROXY from go -# env to download and validate go modules is used. Exclude downloading and -# validation of all private modules which are pre-defined in GOPRIVATE. If no -# GOPRIVATE variable defined, the variable of go env is used. -GOPROXY?=$(shell go env GOPROXY) -GOPRIVATE?=$(shell go env GOPRIVATE) - # CONTAINER_RUNTIME # The CONTAINER_RUNTIME variable will be used to specified the path to a # container runtime. This is needed to start and run a container images. @@ -34,8 +26,8 @@ bin/linux/amd64/${EXECUTABLE}: CGO_ENABLED=1 \ GOOS=linux \ GOARCH=amd64 \ - GOPROXY=${GOPROXY} \ - GOPRIVATE=${GOPRIVATE} \ + GOPROXY=$(shell go env GOPROXY) \ + GOPRIVATE=$(shell go env GOPRIVATE) \ go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@} bin/linux/arm/5/${EXECUTABLE}: @@ -43,8 +35,8 @@ bin/linux/arm/5/${EXECUTABLE}: GOOS=linux \ GOARCH=arm \ GOARM=5 \ - GOPROXY=${GOPROXY} \ - GOPRIVATE=${GOPRIVATE} \ + GOPROXY=$(shell go env GOPROXY) \ + GOPRIVATE=$(shell go env GOPRIVATE) \ go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@} bin/linux/arm/7/${EXECUTABLE}: @@ -53,14 +45,14 @@ bin/linux/arm/7/${EXECUTABLE}: GOOS=linux \ GOARCH=arm \ GOARM=7 \ - GOPROXY=${GOPROXY} \ - GOPRIVATE=${GOPRIVATE} \ + GOPROXY=$(shell go env GOPROXY) \ + GOPRIVATE=$(shell go env GOPRIVATE) \ go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@} bin/tmp/${EXECUTABLE}: CGO_ENABLED=1 \ - GOPROXY=${GOPROXY} \ - GOPRIVATE=${GOPRIVATE} \ + GOPROXY=$(shell go env GOPROXY) \ + GOPRIVATE=$(shell go env GOPRIVATE) \ go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@} # CLEAN @@ -87,8 +79,8 @@ container-image/build/amd64: --build-arg BUILD_IMAGE=docker.io/volkerraschek/build-image:latest \ --build-arg EXECUTABLE=${EXECUTABLE} \ --build-arg EXECUTABLE_TARGET=bin/linux/amd64/${EXECUTABLE} \ - --build-arg GOPROXY=${GOPROXY} \ - --build-arg GOPRIVATE=${GOPRIVATE} \ + --build-arg GOPROXY=$(shell go env GOPROXY) \ + --build-arg GOPRIVATE=$(shell go env GOPRIVATE) \ --build-arg VERSION=${VERSION} \ --file Dockerfile \ --no-cache \ @@ -136,13 +128,13 @@ container-run/test/unit: PHONY+=container-run container-run: ${CONTAINER_RUNTIME} run \ + --env GOPROXY=$(shell go env GOPROXY) \ + --env GOPRIVATE=$(shell go env GOPRIVATE) \ --rm \ --volume ${PWD}:/workspace \ --volume /var/run/docker.sock:/var/run/docker.sock \ docker.io/volkerraschek/build-image:latest \ make ${COMMAND} \ - GOPROXY=${GOPROXY} \ - GOPRIVATE=${GOPRIVATE} \ VERSION=${VERSION:v%=%} # REMOTE