Skip to content

Commit 95e173f

Browse files
committed
Added support for optional prebuilt Go binaries in Dockerfile
Signed-off-by: Helber Belmiro <[email protected]>
1 parent fa3c0b5 commit 95e173f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ COPY controllers/ controllers/
2222
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
2323
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
2424
USER root
25-
RUN CGO_ENABLED=1 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} GO111MODULE=on GOEXPERIMENT=strictfipsruntime go build -tags strictfipsruntime -a -o manager main.go
25+
26+
# Accept an optional prebuilt Go binary
27+
ARG PREBUILT_BINARY=unset
28+
29+
# If PREBUILT_BINARY is set, use it; otherwise, build from source
30+
RUN if [ "$PREBUILT_BINARY" = "unset" ]; then \
31+
CGO_ENABLED=1 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} GO111MODULE=on GOEXPERIMENT=strictfipsruntime go build -tags strictfipsruntime -a -o manager main.go; \
32+
else \
33+
cp ${PREBUILT_BINARY} /workspace/manager; \
34+
fi
2635

2736
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
2837
WORKDIR /

0 commit comments

Comments
 (0)