Files
cozystack/packages/system/cozystack-controller/images/cozystack-controller/Dockerfile
T
Aleksei Sviridkin 2a04bfd0db build(go): move the builder images to Go 1.27.2
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>
2026-11-16 01:07:37 +03:00

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"]