mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
The golang builder images move to the 1.27.2 digests of their 1.27 tags, and the one image pinned to golang:1.27.1 moves to golang:1.27.2. Builds that reproduce an upstream release keep the Go that upstream uses. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la>
28 lines
884 B
Docker
28 lines
884 B
Docker
FROM --platform=$BUILDPLATFORM golang:1.27-alpine@sha256:f92b6ef800e499660581efdabdf25d9d817a9d124eaf900924f0504e7e27e12d AS builder
|
|
ARG GOPROXY
|
|
|
|
ARG TARGETOS
|
|
ARG TARGETARCH
|
|
ARG VERSION=dev
|
|
|
|
WORKDIR /workspace
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN for attempt in 1 2 3; do GOOS=$TARGETOS GOARCH=$TARGETARCH go mod download && break; [ "$attempt" = 3 ] && exit 1; sleep $((attempt * 10)); done
|
|
|
|
COPY api api/
|
|
COPY pkg pkg/
|
|
COPY cmd cmd/
|
|
COPY internal internal/
|
|
|
|
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build \
|
|
-ldflags="-extldflags=-static -X github.com/cozystack/cozystack/pkg/version.Version=${VERSION}" \
|
|
-o /cozystack-controller cmd/cozystack-controller/main.go
|
|
|
|
FROM scratch
|
|
|
|
COPY --from=builder /cozystack-controller /cozystack-controller
|
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
|
|
|
ENTRYPOINT ["/cozystack-controller"]
|