-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
24 lines (19 loc) · 843 Bytes
/
Copy pathDockerfile
File metadata and controls
24 lines (19 loc) · 843 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
# syntax=docker/dockerfile:1
FROM golang:1.25-alpine AS builder
WORKDIR /src
COPY go.mod ./
COPY TimeProtocol.go ./
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/timeprotocol .
# distroless "nonroot" runs as uid/gid 65532 with no shell and no package
# manager, keeping the runtime image's attack surface minimal.
FROM gcr.io/distroless/static-debian12:nonroot AS runtime
# Port 37 is a privileged port (<1024) and would require root or
# CAP_NET_BIND_SERVICE to bind directly. Listening on an unprivileged port
# here lets the container run fully unprivileged; map it to host port 37
# via Docker's port publishing instead (see docker-compose.yml).
ENV TIMEPROTOCOL_PORT=8037
EXPOSE 8037/tcp
EXPOSE 8037/udp
COPY --from=builder /out/timeprotocol /timeprotocol
USER nonroot:nonroot
ENTRYPOINT ["/timeprotocol"]