-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dmitry Kharitonov <[email protected]>
- Loading branch information
Showing
2 changed files
with
16 additions
and
23 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
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 |
---|---|---|
|
@@ -3,38 +3,28 @@ | |
# Copyright 2021 Authors of Cilium | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
ARG GOLANG_IMAGE=docker.io/library/golang:1.21-bullseye@sha256:31848c4f02b08469e159ea1ee664a3f29602418b13e7d67dfd4560d169e14d55 | ||
# skopeo inspect --override-os linux docker://docker.io/library/golang:1.21.6-bookworm | jq -r '.Digest' | ||
ARG GOLANG_IMAGE=docker.io/library/golang:1.21.6-bookworm@sha256:d26cc6bb9b582095098ef54c115ec9ff43647fa3cf157330c57f5aafb97de842 | ||
|
||
# BUILDPLATFORM is an automatic platform ARG enabled by Docker BuildKit. | ||
# Represents the plataform where the build is happening, do not mix with | ||
# TARGETARCH | ||
# $ skopeo inspect --override-os linux docker://gcr.io/distroless/static-debian12:nonroot | jq -r '.Digest' | ||
# distroless images are signed by cosign. You should verify the image with the | ||
# following commands: | ||
# $ docker pull gcr.io/distroless/static-debian12:nonroot | ||
# $ cosign verify gcr.io/distroless/static-debian12:nonroot --certificate-oidc-issuer https://accounts.google.com --certificate-identity [email protected] | ||
ARG BASE_IMAGE=gcr.io/distroless/static-debian12:nonroot@sha256:39ae7f0201fee13b777a3e4a5a9326a8889269172c8b4f4289d9f19c831f45f4 | ||
|
||
FROM --platform=${BUILDPLATFORM} ${GOLANG_IMAGE} as app-build | ||
WORKDIR /app | ||
|
||
COPY . . | ||
# TARGETARCH is an automatic platform ARG enabled by Docker BuildKit. | ||
ARG TARGETARCH | ||
RUN CGO_ENABLED=0 GOARCH=${TARGETARCH} go build -ldflags "-s -w" -o backend | ||
|
||
# BUILDPLATFORM is an automatic platform ARG enabled by Docker BuildKit. | ||
# Represents the plataform where the build is happening, do not mix with | ||
# TARGETARCH | ||
FROM --platform=${BUILDPLATFORM} ${GOLANG_IMAGE} as gops | ||
|
||
RUN apt-get update && apt-get install -y binutils-aarch64-linux-gnu | ||
COPY ./build-gops.sh . | ||
RUN --mount=target=/root/.cache,type=cache --mount=target=/go/pkg/mod,type=cache \ | ||
./build-gops.sh | ||
|
||
FROM docker.io/library/node:18-alpine3.18@sha256:435dcad253bb5b7f347ebc69c8cc52de7c912eb7241098b920f2fc2d7843183d | ||
FROM ${BASE_IMAGE} | ||
# TARGETOS is an automatic platform ARG enabled by Docker BuildKit. | ||
ARG TARGETOS | ||
# TARGETARCH is an automatic platform ARG enabled by Docker BuildKit. | ||
ARG TARGETARCH | ||
COPY --from=app-build /app/backend /usr/bin | ||
COPY --from=gops /out/${TARGETOS}/${TARGETARCH}/bin/gops /usr/bin/gops | ||
RUN mkdir -p /home/gops && chown 1001:1001 /home/gops | ||
|
||
ENV GOPS_CONFIG_DIR=/home/gops | ||
CMD ["/usr/bin/backend"] | ||
USER 65532:65532 | ||
CMD ["/usr/bin/backend"] |