From fee04724ed436ad6b6577d6713e71daca9dbae4a Mon Sep 17 00:00:00 2001 From: MiTHRAL Date: Wed, 13 May 2026 22:20:09 -0400 Subject: [PATCH] Fix container ownership for UID 1001 --- .env.deploy.example | 2 -- .env.example | 2 -- Dockerfile | 11 ++++------- README.md | 7 +++++-- compose.yaml | 1 - 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.env.deploy.example b/.env.deploy.example index ae2b259..6d140a6 100644 --- a/.env.deploy.example +++ b/.env.deploy.example @@ -1,7 +1,5 @@ DISCORD_BOT_TOKEN=replace-with-your-discord-bot-token DISCORD_CHANNEL_ID=1504278732070981683 -PUID=1001 -PGID=1000 ARCHIVE_STATUS_CONFIG=services.json ARCHIVE_STATUS_STATE=state/status-message.json CHECK_INTERVAL_SECONDS=60 diff --git a/.env.example b/.env.example index 1b7111d..c351831 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,5 @@ DISCORD_BOT_TOKEN=replace-with-your-discord-bot-token DISCORD_CHANNEL_ID=1504278732070981683 -PUID=1001 -PGID=1000 ARCHIVE_STATUS_CONFIG=services.json ARCHIVE_STATUS_STATE=state/status-message.json CHECK_INTERVAL_SECONDS=60 diff --git a/Dockerfile b/Dockerfile index 75c6b18..5031c53 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,10 @@ FROM python:3.12-alpine WORKDIR /app -COPY status_bot.py /app/status_bot.py -COPY dashboard.html /app/dashboard.html -COPY services.example.json /app/services.json +COPY --chown=1001:1000 status_bot.py /app/status_bot.py +COPY --chown=1001:1000 dashboard.html /app/dashboard.html +COPY --chown=1001:1000 services.example.json /app/services.json -RUN adduser -D -u 1000 -h /app archive-status -RUN mkdir -p /app/state && chown -R archive-status:archive-status /app - -USER archive-status +RUN adduser -D -u 1001 -g "" -h /app archive-status CMD ["python", "/app/status_bot.py"] diff --git a/README.md b/README.md index b37c1a8..38be10d 100644 --- a/README.md +++ b/README.md @@ -106,14 +106,17 @@ Paste the generated password hash into `.env` before starting the container. Make sure Docker can read the service config and write runtime state: ```sh -printf 'PUID=%s\nPGID=%s\n' "$(id -u)" "$(id -g)" >> .env chmod 600 .env chmod 644 services.json mkdir -p state chmod 755 state ``` -If your host user is `1001`, that is the UID the container should run as. `1000` is only the default fallback here. +The container runs as UID `1001` inside the image. If the mounted `services.json` or `state/` were created by another user, fix ownership once: + +```sh +sudo chown -R 1001:1000 services.json state +``` If `state/` or `services.json` were created by a previous container as another user, fix ownership once: diff --git a/compose.yaml b/compose.yaml index f800a4c..a87e171 100644 --- a/compose.yaml +++ b/compose.yaml @@ -3,7 +3,6 @@ services: build: . container_name: archive-status-bot restart: unless-stopped - user: "${PUID:-1001}:${PGID:-1000}" env_file: - .env expose: