File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ ARG VERSION
66RUN test -n "${VERSION}" || (echo "Error: VERSION is not set" && exit 1)
77ARG ARCH
88RUN test -n "${ARCH}" || (echo "Error: ARCH is not set" && exit 1)
9+ ARG RELEASE
910
1011# Download dependencies first (this layer will be cached by docker for quicker image builds).
1112# This will be recomputed only when these two files change, instead of every build.
@@ -22,7 +23,8 @@ ADD pkg ./pkg
2223RUN --mount=type=cache,target=/go/pkg/mod,sharing=locked \
2324 --mount=type=cache,target=/root/.cache/go-build,sharing=locked \
2425 export VERSION=$(echo "${VERSION}" | sed -e "s/^v\( .*\) /\1 /" ) \
25- && GOOS=linux GOARCH=${ARCH} go build -ldflags "-X 'main.Version=${VERSION}'" -o ${BINARY_NAME} ./cmd/${BINARY_NAME}
26+ export LDFLAGS=$([ -n "$RELEASE" ] && echo "-s -w" || echo "" ) \
27+ && GOOS=linux GOARCH=${ARCH} go build -ldflags "${LDFLAGS} -X 'main.Version=${VERSION}'" -o ${BINARY_NAME} ./cmd/${BINARY_NAME}
2628
2729FROM debian:bookworm AS debian
2830
You can’t perform that action at this time.
0 commit comments