Compare commits
1 Commits
mai/sherlo
...
mai/picass
| Author | SHA1 | Date | |
|---|---|---|---|
| 78b37f442d |
14
Dockerfile
14
Dockerfile
@@ -20,17 +20,25 @@ RUN CGO_ENABLED=0 GOOS=linux go build \
|
|||||||
-o /out/mcables \
|
-o /out/mcables \
|
||||||
./cmd/mcables
|
./cmd/mcables
|
||||||
|
|
||||||
|
# Pre-create the runtime data dir with the right owner in the builder
|
||||||
|
# stage, then COPY it into the distroless final image. Distroless has
|
||||||
|
# no shell + no mkdir, so this is the canonical pattern for "writable
|
||||||
|
# subdir under a non-root user".
|
||||||
|
RUN mkdir -p /out/data && chown -R 1000:1000 /out/data
|
||||||
|
|
||||||
FROM gcr.io/distroless/static-debian12:nonroot
|
FROM gcr.io/distroless/static-debian12:nonroot
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /out/mcables /app/mcables
|
COPY --from=build /out/mcables /app/mcables
|
||||||
|
COPY --from=build --chown=1000:1000 /out/data /app/data
|
||||||
|
|
||||||
ENV MCABLES_ADDR=0.0.0.0:7777 \
|
ENV MCABLES_ADDR=0.0.0.0:7777 \
|
||||||
MCABLES_DB=/app/data/mcables.db
|
MCABLES_DB=/app/data/mcables.db
|
||||||
|
|
||||||
EXPOSE 7777
|
EXPOSE 7777
|
||||||
# Run as UID:GID 1000:1000 to match m on mDock — the bind-mounted
|
# Run as UID:GID 1000:1000 to match m on mDock — the bind-mounted
|
||||||
# /home/m/stacks/mcables/data is owned by m:m, so the container can write
|
# /home/m/stacks/mcables/data is owned by m:m, so the container can
|
||||||
# to it without chowning the host dir. distroless/static-debian12 accepts
|
# write to it without chowning the host dir. distroless/static-debian12
|
||||||
# arbitrary numeric UIDs; the Go binary doesn't need a /etc/passwd entry.
|
# accepts arbitrary numeric UIDs; the Go binary doesn't need a
|
||||||
|
# /etc/passwd entry.
|
||||||
USER 1000:1000
|
USER 1000:1000
|
||||||
ENTRYPOINT ["/app/mcables"]
|
ENTRYPOINT ["/app/mcables"]
|
||||||
|
|||||||
Reference in New Issue
Block a user