-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (29 loc) · 1.31 KB
/
Copy pathDockerfile
File metadata and controls
40 lines (29 loc) · 1.31 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
# ── Build stage ──────────────────────────────────────────────
# No --platform override: BuildKit runs this stage natively for each target
# platform (via QEMU for arm64). CGO_ENABLED=0 keeps it pure-Go so QEMU
# emulation is the only requirement — no cross-toolchain needed.
FROM golang:1.26-alpine AS builder
WORKDIR /src
# Cache dependencies
COPY go.mod go.sum ./
RUN go mod download
# Build (CGO_ENABLED=0 for pure-Go serial library)
COPY . .
RUN CGO_ENABLED=0 \
go build -ldflags="-s -w" -o /out/serialmonitor ./cmd/serialmonitor
# ── Runtime stage ─────────────────────────────────────────────
FROM alpine:3
# ca-certificates for any future TLS work
RUN apk add --no-cache ca-certificates
# Run as non-root — serial ports typically require dialout group
RUN addgroup -S dialout 2>/dev/null || true \
&& adduser -S -G dialout -s /sbin/nologin serialmonitor
WORKDIR /app
COPY --from=builder /out/serialmonitor .
# Config file mount point — override with a volume/configmap in k8s
RUN mkdir -p /data
VOLUME ["/data"]
USER serialmonitor
EXPOSE 8080
ENTRYPOINT ["/app/serialmonitor"]
CMD ["--config", "/data/config.yaml"]