11# Builder stage
2- FROM docker.io/library/golang:1.22-alpine as builder
3-
2+ FROM --platform=${BUILDPLATFORM} docker.io/library/golang:1.24-alpine as builder
43
54# Install make
65RUN apk update && apk add make
76
8- # Copy the source code from the host to the container
9- COPY pkg /workdir/app/pkg
10- COPY tools /workdir/app/tools
11- COPY staging /workdir/app/staging
12- COPY cmd /workdir/app/cmd
13- COPY vendor /workdir/app/vendor
14- COPY go.mod /workdir/app/go.mod
15- COPY go.sum /workdir/app/go.sum
16- COPY Makefile /workdir/app/Makefile
17-
187WORKDIR /workdir/app
198
20- RUN make aaq_operator
21- RUN make csv-generator
22-
23- # Final stage
24- FROM docker.io/library/golang:1.22-alpine
9+ # Copy the source code from the host to the container
10+ COPY cmd ./cmd
11+ COPY go.mod go.sum Makefile ./
12+ COPY pkg ./pkg
13+ COPY staging ./staging
14+ COPY vendor ./vendor
15+ COPY tools ./tools
2516
17+ ARG TARGETARCH
18+ RUN GOOS=linux GOARCH=${TARGETARCH} make aaq_operator
19+ RUN GOOS=linux GOARCH=${TARGETARCH} make csv-generator
2620
27- # Copy the binary from the builder stage to the final image
28- COPY --from=builder /workdir/app/aaq_operator /app/aaq_operator
29- COPY --from=builder /workdir/app/bin/csv-generator /usr/bin/csv-generator
21+ # Final stage
22+ FROM docker.io/alpine:3.22.1
3023
3124# Set the working directory to /app
3225WORKDIR /app
33-
34- RUN adduser -u 1001 -D -s /bin/sh -h /app/aaq_operator aaq_operator
26+ RUN adduser -u 1001 -D -s /bin/sh -h /app aaq_operator
3527USER 1001
3628
3729# Set the entrypoint to the binary
38- ENTRYPOINT ["/app/aaq_operator"]
30+ ENTRYPOINT ["/app/aaq_operator"]
31+
32+ # Copy the binary from the builder stage to the final image
33+ COPY --from=builder --chown=1001 /workdir/app/aaq_operator /app/
34+ COPY --from=builder --chown=1001 /workdir/app/bin/csv-generator /usr/bin/
35+
36+ ARG git_url=https://github.com/kubevirt/application-aware-quota.git
37+ ARG git_sha=unknown
38+
39+ # this line is used to prevent the caching of the multi.GIT_SHA label
40+ RUN echo "git_sha=${git_sha}"
41+
42+ LABEL multi.GIT_URL=${git_url} \
43+ multi.GIT_SHA=${git_sha} \
44+ app=aaq-operator
0 commit comments