-
Notifications
You must be signed in to change notification settings - Fork 12
UPSTREAM: <carry>: Add support for optional prebuilt Go binaries in Dockerfiles #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,8 +36,16 @@ RUN GO111MODULE=on go mod download | |
# Copy the source | ||
COPY ${SOURCE_CODE}/ ./ | ||
|
||
RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags netgo -ldflags '-extldflags "-static"' -o /bin/launcher-v2 ./backend/src/v2/cmd/launcher-v2/*.go | ||
RUN GO111MODULE=on CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GOEXPERIMENT=strictfipsruntime go build -tags 'netgo strictfipsruntime' -o /bin/launcher-v2-fips ./backend/src/v2/cmd/launcher-v2/*.go | ||
# Accept an optional prebuilt Go binary | ||
ARG PREBUILT_BINARY=unset | ||
|
||
RUN if [ "$PREBUILT_BINARY" = "unset" ]; then \ | ||
GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags netgo -ldflags '-extldflags "-static"' -o /bin/launcher-v2 ./backend/src/v2/cmd/launcher-v2/*.go && \ | ||
GO111MODULE=on CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GOEXPERIMENT=strictfipsruntime go build -tags 'netgo strictfipsruntime' -o /bin/launcher-v2-fips ./backend/src/v2/cmd/launcher-v2/*.go ;\ | ||
else \ | ||
cp "${PREBUILT_BINARY}" /bin/launcher-v2 && \ | ||
cp "${PREBUILT_BINARY}" /bin/launcher-v2-fips ;\ | ||
fi | ||
Comment on lines
+42
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add explicit existence check and clear error for the prebuilt binary if [ -f "$PREBUILT_BINARY" ]; then \
cp "$PREBUILT_BINARY" /bin/launcher-v2 && cp "$PREBUILT_BINARY" /bin/launcher-v2-fips; \
else \
echo "Error: PREBUILT_BINARY '$PREBUILT_BINARY' not found" >&2; exit 1; \
fi 🤖 Prompt for AI Agents
|
||
|
||
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.5 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,15 @@ RUN GO111MODULE=on go mod download | |
# Copy the source | ||
COPY ${SOURCE_CODE}/ ./ | ||
|
||
RUN GO111MODULE=on CGO_ENABLED=1 GOEXPERIMENT=strictfipsruntime go build -tags strictfipsruntime -o /bin/persistence_agent backend/src/agent/persistence/*.go | ||
# Accept an optional prebuilt Go binary | ||
ARG PREBUILT_BINARY=unset | ||
|
||
# If PREBUILT_BINARY is set, use it; otherwise, build from source | ||
RUN if [ "$PREBUILT_BINARY" = "unset" ]; then \ | ||
GO111MODULE=on CGO_ENABLED=1 GOEXPERIMENT=strictfipsruntime go build -tags strictfipsruntime -o /bin/persistence_agent backend/src/agent/persistence/*.go; \ | ||
else \ | ||
cp ${PREBUILT_BINARY} /bin/persistence_agent; \ | ||
fi | ||
|
||
Comment on lines
+41
to
47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Robustify the prebuilt-binary copy step
🤖 Prompt for AI Agents
|
||
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.5 | ||
WORKDIR /bin | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,15 @@ RUN GO111MODULE=on go mod download | |
# Copy the source | ||
COPY ${SOURCE_CODE}/ ./ | ||
|
||
RUN GO111MODULE=on CGO_ENABLED=1 GOEXPERIMENT=strictfipsruntime go build -tags strictfipsruntime -o /bin/controller backend/src/crd/controller/scheduledworkflow/*.go | ||
# Accept an optional prebuilt Go binary | ||
ARG PREBUILT_BINARY=unset | ||
|
||
# If PREBUILT_BINARY is set, use it; otherwise, build from source | ||
RUN if [ "$PREBUILT_BINARY" = "unset" ]; then \ | ||
GO111MODULE=on CGO_ENABLED=1 GOEXPERIMENT=strictfipsruntime go build -tags strictfipsruntime -o /bin/controller backend/src/crd/controller/scheduledworkflow/*.go; \ | ||
else \ | ||
cp ${PREBUILT_BINARY} /bin/controller; \ | ||
fi | ||
|
||
Comment on lines
+47
to
52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Strengthen the prebuilt-binary copy step
🤖 Prompt for AI Agents
|
||
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.5 | ||
WORKDIR /bin | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve prebuilt-binary copy logic
cp "${PREBUILT_BINARY}" /bin/driver
[ -f "$PREBUILT_BINARY" ]
to fail fast with a clear error if missing.🤖 Prompt for AI Agents