generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bb07f8
commit ae59088
Showing
1 changed file
with
11 additions
and
11 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,24 +1,24 @@ | ||
### build go executable | ||
FROM --platform=$BUILDPLATFORM golang:1.21.3 as build | ||
ARG TARGETOS TARGETARCH | ||
|
||
WORKDIR /go/src | ||
WORKDIR /workspace | ||
|
||
COPY go.mod go.sum /go/src/ | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
RUN go mod download | ||
|
||
COPY cmd /go/src/cmd | ||
COPY internal /go/src/internal | ||
|
||
RUN go test ./... | ||
COPY cmd/ cmd/ | ||
COPY internal/ internal/ | ||
COPY Makefile Makefile | ||
|
||
WORKDIR /go/src/cmd/webhook | ||
|
||
ARG TARGETOS TARGETARCH | ||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o /go/bin/webhook . | ||
RUN make envtest \ | ||
&& CGO_ENABLED=0 KUBEBUILDER_ASSETS="/workspace/bin/k8s/current" go test ./... \ | ||
&& CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o ./bin/webhook ./cmd/webhook | ||
|
||
### final image | ||
FROM scratch | ||
|
||
ENTRYPOINT ["/app/bin/webhook"] | ||
|
||
COPY --from=build /go/bin/webhook /app/bin/webhook | ||
COPY --from=build /workspace/bin/webhook /app/bin/webhook |