Skip to content

Commit 7488c69

Browse files
authored
feat: add build-arg into the golang dockerfile template (#13)
Co-authored-by: rick <[email protected]>
1 parent 359c008 commit 7488c69

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

runtime/golang.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ WORKDIR /go/src/app
102102
ARG TARGETOS=linux
103103
ARG TARGETARCH=arm64
104104
ARG CGO_ENABLED=0
105+
ARG GOPROXY=direct
105106
106107
COPY . .
108+
ENV GOPROXY=${GOPROXY}
107109
RUN if [ -f go.mod ]; then go mod download; fi
108110
109111
FROM base AS build
@@ -112,9 +114,11 @@ ARG TARGETOS=linux
112114
ARG TARGETARCH=arm64
113115
ARG CGO_ENABLED=0
114116
ARG PACKAGE={{.Package}}
117+
ARG GOPROXY=direct
115118
# -trimpath removes the absolute path to the source code in the binary
116119
# -ldflags="-s -w" removes the symbol table and debug information from the binary
117120
# CGO_ENABLED=0 disables the use of cgo
121+
ENV GOPROXY=${GOPROXY}
118122
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -ldflags="-s -w" -o /go/bin/app "${PACKAGE}"
119123
120124
FROM debian:stable-slim

0 commit comments

Comments
 (0)