-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.sentinel
More file actions
36 lines (33 loc) · 1.49 KB
/
Copy pathDockerfile.sentinel
File metadata and controls
36 lines (33 loc) · 1.49 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
# ─── Stage 1: Builder ────────────────────────────────────────────────────────
FROM golang:1.24.5-alpine3.21 AS builder
ARG VERSION=dev
ARG COMMIT=unknown
WORKDIR /app
RUN apk add --no-cache ca-certificates git
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
WORKDIR /app/sentinel
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build \
-ldflags="-s -w -X main.Version=${VERSION} -X main.Commit=${COMMIT}" \
-trimpath \
-o /out/sentinel \
.
# ─── Stage 2: Runtime ────────────────────────────────────────────────────────
FROM alpine:3.21
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
WORKDIR /app
RUN addgroup -g 1001 -S gophergroup && \
adduser -u 1001 -S gopheruser -G gophergroup
COPY --from=builder /out/sentinel ./sentinel
RUN chown gopheruser:gophergroup /app/sentinel
USER gopheruser
EXPOSE 2113
# Sentinel is a background agent with no inbound HTTP port.
# HEALTHCHECK uses kill -0 1: succeeds as long as PID 1 (the entrypoint)
# is alive. Avoids pgrep -x name-matching issues on BusyBox/Alpine where
# the full command path (/app/sentinel) doesn't match the bare name.
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD kill -0 1 || exit 1
ENTRYPOINT ["/app/sentinel"]