2026-04-03 14:26:26 +02:00
|
|
|
# syntax=docker/dockerfile:1
|
|
|
|
|
|
|
|
|
|
# ─── Build stage ────────────────────────────────────────────────────────────
|
2026-07-30 18:41:22 +02:00
|
|
|
FROM golang:1.26-bookworm AS builder
|
2026-04-03 14:26:26 +02:00
|
|
|
|
|
|
|
|
ARG VERSION=dev
|
|
|
|
|
|
|
|
|
|
WORKDIR /src
|
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
|
RUN go mod download
|
|
|
|
|
|
|
|
|
|
COPY . .
|
|
|
|
|
RUN CGO_ENABLED=0 GOOS=linux go build \
|
|
|
|
|
-o /chatserver \
|
|
|
|
|
-ldflags "-s -w -X main.version=${VERSION}" \
|
|
|
|
|
.
|
|
|
|
|
|
|
|
|
|
# ─── Final stage ─────────────────────────────────────────────────────────────
|
|
|
|
|
# gcr.io/distroless/static-debian12: no shell, includes CA certs (needed for
|
|
|
|
|
# TLS/ACME) and timezone data. Attack surface is minimal.
|
|
|
|
|
FROM gcr.io/distroless/static-debian12
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
COPY --from=builder /chatserver /chatserver
|
|
|
|
|
|
|
|
|
|
# /app/data is the default data_dir (SQLite DB + uploads).
|
|
|
|
|
# Mount a named volume here to persist data across container restarts.
|
|
|
|
|
VOLUME ["/app/data"]
|
|
|
|
|
|
|
|
|
|
# Server listens on this port by default (configurable via config.yaml).
|
|
|
|
|
EXPOSE 8443
|
|
|
|
|
|
2026-08-07 21:20:48 +02:00
|
|
|
# Refuses the in-place self-update endpoint (the binary is image content;
|
|
|
|
|
# upgrades are image pulls). See Server/updater/container.go.
|
|
|
|
|
ENV OWNCORD_CONTAINER=1
|
|
|
|
|
|
2026-04-03 14:26:26 +02:00
|
|
|
# Run as non-root (distroless provides uid 65532 = "nonroot").
|
|
|
|
|
USER 65532:65532
|
|
|
|
|
|
|
|
|
|
ENTRYPOINT ["/chatserver"]
|