Fix container ownership for UID 1001

This commit is contained in:
MiTHRAL 2026-05-13 22:20:09 -04:00
parent 4008d9550e
commit fee04724ed
5 changed files with 9 additions and 14 deletions

View file

@ -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

View file

@ -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

View file

@ -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"]

View file

@ -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:

View file

@ -3,7 +3,6 @@ services:
build: .
container_name: archive-status-bot
restart: unless-stopped
user: "${PUID:-1001}:${PGID:-1000}"
env_file:
- .env
expose: