Run the sync server image as a numeric UID/GID; explain unwritable /data

The image now runs as USER 10001:10001 with a matching group, so
Kubernetes can verify runAsNonRoot and fsGroup: 10001 grants it a mounted
volume. When the database can't be opened because its directory isn't
writable, the server says so and how to fix it, instead of SQLite's bare
"unable to open database file". The README covers the pod securityContext.
This commit is contained in:
2026-10-13 21:21:36 -05:00
parent 3a72780027
commit cec61b886e
3 changed files with 46 additions and 6 deletions

View File

@@ -13,10 +13,13 @@ FROM debian:bookworm-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& useradd --system --uid 10001 --home /data mtgc \
&& mkdir /data && chown mtgc /data
&& groupadd --system --gid 10001 mtgc \
&& useradd --system --uid 10001 --gid 10001 --home /data mtgc \
&& mkdir /data && chown 10001:10001 /data
COPY --from=build /mtgc-server /usr/local/bin/mtgc-server
USER mtgc
# Numeric, so Kubernetes can verify `runAsNonRoot` (it can't resolve names),
# and with a fixed group so `fsGroup: 10001` grants a mounted volume to it.
USER 10001:10001
VOLUME /data
ENV MTGC_DB=/data/mtgc-server.db \
MTGC_BIND=0.0.0.0:8080