-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cross-compile Go binaries outside docker builds (#247)
Co-authored-by: Paolo Ambrosio <[email protected]>
- Loading branch information
1 parent
c7d1e7c
commit f2a8ae8
Showing
13 changed files
with
30 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,9 @@ | ||
# Build the manager binary | ||
FROM golang:1.18 as builder | ||
|
||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
COPY go.work go.work | ||
COPY argo/ argo/ | ||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
RUN go mod download | ||
|
||
# Copy the go source | ||
COPY main.go main.go | ||
COPY apis/ apis/ | ||
COPY controllers/ controllers/ | ||
COPY external/ external/ | ||
|
||
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/static:nonroot | ||
|
||
WORKDIR / | ||
COPY --from=builder /workspace/manager . | ||
COPY bin/manager . | ||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/manager"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
FROM python:3.7.12 AS PYTHON37 | ||
|
||
ARG WHEEL_VERSION | ||
|
||
COPY argo/kfp-compiler/dist/*-${WHEEL_VERSION}-*.whl / | ||
COPY dist/*-${WHEEL_VERSION}-*.whl / | ||
RUN pip install /*-${WHEEL_VERSION}-*.whl --target=/kfp-compiler && \ | ||
rm /*-${WHEEL_VERSION}-*.whl | ||
|
||
FROM python:3.9.13 AS PYTHON39 | ||
ARG WHEEL_VERSION | ||
|
||
COPY argo/kfp-compiler/dist/*-${WHEEL_VERSION}-*.whl / | ||
COPY dist/*-${WHEEL_VERSION}-*.whl / | ||
RUN pip install /*-${WHEEL_VERSION}-*.whl --target=/kfp-compiler && \ | ||
rm /*-${WHEEL_VERSION}-*.whl | ||
|
||
FROM alpine:3.14.2 | ||
|
||
COPY --from=PYTHON37 /kfp-compiler /kfp-compiler/py3.7 | ||
COPY --from=PYTHON39 /kfp-compiler /kfp-compiler/py3.9 | ||
ADD argo/kfp-compiler/resources/compile.sh /kfp-compiler/compile.sh | ||
WORKDIR / | ||
COPY --from=PYTHON37 /kfp-compiler kfp-compiler/py3.7 | ||
COPY --from=PYTHON39 /kfp-compiler kfp-compiler/py3.9 | ||
ADD resources/compile.sh kfp-compiler/compile.sh | ||
|
||
ADD argo/kfp-compiler/resources/entrypoint.sh /entrypoint.sh | ||
ADD resources/entrypoint.sh entrypoint.sh | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,7 @@ | ||
FROM golang:1.18 as builder | ||
|
||
WORKDIR /workspace | ||
|
||
COPY argo argo | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
COPY apis apis | ||
|
||
WORKDIR /workspace/argo/providers | ||
|
||
RUN go mod download | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o provider ./kfp/cmd | ||
|
||
FROM gcr.io/distroless/static:nonroot | ||
|
||
WORKDIR / | ||
COPY --from=builder /workspace/argo/providers . | ||
COPY bin/provider . | ||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/provider"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,9 @@ | ||
FROM golang:1.18 as builder | ||
|
||
WORKDIR /workspace | ||
|
||
COPY argo argo | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
COPY apis apis | ||
|
||
WORKDIR /workspace/argo/providers | ||
|
||
RUN go mod download | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o provider ./stub/cmd | ||
|
||
FROM alpine:3.17.0 | ||
|
||
WORKDIR / | ||
COPY argo/providers/stub/inject.sh /inject.sh | ||
COPY argo/providers/stub/compile.sh /compile.sh | ||
COPY --from=builder /workspace/argo/providers . | ||
COPY inject.sh inject.sh | ||
COPY compile.sh compile.sh | ||
COPY bin/provider . | ||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/bin/sh", "/inject.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,7 @@ | ||
FROM golang:1.18 as builder | ||
|
||
WORKDIR /workspace | ||
|
||
COPY argo argo | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
COPY apis apis | ||
|
||
WORKDIR /workspace/argo/providers | ||
|
||
RUN go mod download | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o provider ./vai/cmd | ||
|
||
FROM gcr.io/distroless/static:nonroot | ||
|
||
WORKDIR / | ||
COPY --from=builder /workspace/argo/providers . | ||
COPY bin/provider . | ||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/provider"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,7 @@ | ||
FROM golang:1.18 as builder | ||
|
||
WORKDIR /workspace | ||
|
||
COPY argo argo | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
COPY apis apis | ||
|
||
WORKDIR /workspace/argo/run-completer | ||
|
||
RUN go mod download | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o run-completer ./cmd | ||
|
||
FROM gcr.io/distroless/static:nonroot | ||
|
||
WORKDIR / | ||
COPY --from=builder /workspace/argo/run-completer . | ||
COPY bin/run-completer . | ||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/run-completer"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters