-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile.controller
More file actions
47 lines (38 loc) · 1.77 KB
/
Copy pathDockerfile.controller
File metadata and controls
47 lines (38 loc) · 1.77 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
45
46
47
# Build stage for the rpingmesh controller.
# CGO_ENABLED=0 — no RDMA or Zig dependencies needed.
FROM golang:1.26.0-bookworm AS builder
# Install protoc and Go protobuf plugins for code generation. This layer
# only depends on apt/Go tool versions, not application source, so it stays
# cached across source-only rebuilds.
RUN apt-get update && apt-get install -y --no-install-recommends \
protobuf-compiler \
&& rm -rf /var/lib/apt/lists/* \
&& go install google.golang.org/protobuf/cmd/protoc-gen-go@latest \
&& go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
WORKDIR /app
# Copy module files first and resolve dependencies before copying the rest
# of the source tree, so `go mod download` is only re-run when go.mod/go.sum
# change (not on every source edit). go.sum is trusted as-is; it is expected
# to already be complete and committed (no `go mod tidy` in the container).
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
# Copy remaining source and generate protobuf bindings.
COPY . .
RUN cd proto/controller_agent && \
protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
controller_agent.proto
# Build the controller binary.
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux go build -o /app/bin/rpingmesh-controller ./cmd/controller/
# Runtime image — minimal footprint.
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
netcat-openbsd \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /app/bin/rpingmesh-controller ./rpingmesh-controller
EXPOSE 50051
ENTRYPOINT ["./rpingmesh-controller"]