Skip to content

Commit

Permalink
make envtest work in docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
cbarbian-sap committed Oct 16, 2023
1 parent 7bb07f8 commit ae59088
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions Dockerfile
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

0 comments on commit ae59088

Please sign in to comment.