fix: Stack-Umgebungsvariablen via environment: an Container weitergeben

feat: entrypoint.sh mit gosu für automatisches chown und Privilege-Drop
This commit is contained in:
Andre
2026-04-15 19:06:50 +02:00
parent 08be478587
commit 895e2e588f
3 changed files with 28 additions and 1 deletions
+6 -1
View File
@@ -4,6 +4,7 @@ FROM python:3.12-slim-bookworm
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
curl \
gosu \
&& rm -rf /var/lib/apt/lists/*
# Install yt-dlp (standalone binary, always up-to-date)
@@ -18,7 +19,7 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN mkdir -p /app/tmp
RUN mkdir -p /app/tmp /app/data
ENV APP_HOST=0.0.0.0
ENV APP_PORT=8000
@@ -26,5 +27,9 @@ ENV TMP_DIR=/app/tmp
EXPOSE 8000
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
# Single worker to stay within Pi 3's memory budget
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]
+11
View File
@@ -7,6 +7,17 @@ services:
env_file:
- path: .env
required: false
environment:
- OPENAI_API_KEY
- USDA_API_KEY
- TANDOOR_BASE_URL
- TANDOOR_API_TOKEN
- TMP_DIR
- APP_HOST
- APP_PORT
- FFMPEG_LOCATION
- APP_UID
- APP_GID
ports:
- "88:8000"
volumes:
+11
View File
@@ -0,0 +1,11 @@
#!/bin/sh
set -e
APP_UID=${APP_UID:-1000}
APP_GID=${APP_GID:-1000}
# Fix ownership of mounted volumes so the app user can write to them
chown "${APP_UID}:${APP_GID}" /app/tmp /app/data /app/data/images
# Drop from root to app user and run the actual command
exec gosu "${APP_UID}:${APP_GID}" "$@"