-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (32 loc) · 1.08 KB
/
Dockerfile
File metadata and controls
44 lines (32 loc) · 1.08 KB
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
37
38
39
40
41
42
43
44
# Build the manager binary
FROM golang:1.25.8-trixie AS builder
ARG VERSION=dev
ARG TARGETOS
ARG TARGETARCH
ARG GOPS_VERSION=v0.3.29
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.sum ./
# Cache dependencies before copying the source to avoid re-downloading
RUN go mod download
# Copy the Go source
COPY cmd/main.go cmd/main.go
COPY internal/controller/ internal/controller/
COPY internal/pkg/ internal/pkg/
COPY internal/version/ internal/version/
COPY api/ api/
# Build the Go binary
RUN CGO_ENABLED=0 go build -ldflags="-X 'github.com/illumio/cloud-operator/internal/version.version=${VERSION}'" -a -o manager cmd/main.go
# Install gops for troubleshooting
RUN CGO_ENABLED=0 go install github.com/google/gops@${GOPS_VERSION}
# Use distroless as minimal base image to package the manager binary
FROM gcr.io/distroless/static:nonroot
# Copy binaries
WORKDIR /
COPY --from=builder /workspace/manager .
COPY --from=builder /go/bin/gops /sbin/gops
USER 65532:65532
# Configure gops
ENV GOPS_CONFIG_DIR="/var/run/gops"
# Set the entrypoint for your app
ENTRYPOINT ["/manager"]