-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (25 loc) · 966 Bytes
/
Dockerfile
File metadata and controls
36 lines (25 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS builder
WORKDIR /workspace
# Copy go mod files (cached layer - only invalidated if deps change)
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
# Copy source code
COPY cmd/ cmd/
COPY internal/ internal/
ARG TARGETOS
ARG TARGETARCH
ARG VERSION=dev
# Build with cache mounts for faster incremental builds
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -a -mod=readonly -ldflags="-w -s -X main.version=${VERSION}" \
-o binarylane-cloud-controller-manager ./cmd/binarylane-cloud-controller-manager
FROM alpine:3.23.2
RUN apk add --update --no-cache ca-certificates
WORKDIR /
COPY --from=builder /workspace/binarylane-cloud-controller-manager .
USER 65534:65534
ENTRYPOINT ["/binarylane-cloud-controller-manager"]