add non-root user
This commit is contained in:
+14
-4
@@ -27,19 +27,29 @@ FROM python:3.13-slim-bookworm
|
|||||||
ARG PUID=1000
|
ARG PUID=1000
|
||||||
ARG PGID=1000
|
ARG PGID=1000
|
||||||
|
|
||||||
|
# 1. System-Pakete (inkl. gosu)
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends gosu \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# 2. User anlegen
|
||||||
RUN groupadd -g ${PGID} appgroup \
|
RUN groupadd -g ${PGID} appgroup \
|
||||||
&& useradd -u ${PUID} -g appgroup -m -d /home/appuser appuser
|
&& useradd -u ${PUID} -g appgroup -m -d /home/appuser appuser
|
||||||
|
|
||||||
|
# 3. Scalable CLI kopieren
|
||||||
COPY --from=builder /usr/local/bin/sc /usr/local/bin/sc
|
COPY --from=builder /usr/local/bin/sc /usr/local/bin/sc
|
||||||
|
|
||||||
|
# 4. App-Dateien
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
COPY scalable_sync.py .
|
COPY scalable_sync.py .
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
# 5. Env
|
||||||
ENV SC_CONFIG_DIR=/tmp/sc-config
|
ENV SC_CONFIG_DIR=/tmp/sc-config
|
||||||
|
ENV PUID=${PUID}
|
||||||
|
ENV PGID=${PGID}
|
||||||
|
|
||||||
USER ${PUID}:${PGID}
|
# 6. Entrypoint (wechselt intern auf appuser)
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
ENTRYPOINT ["python", "/app/scalable_sync.py"]
|
|
||||||
+5
-5
@@ -11,8 +11,8 @@ services:
|
|||||||
container_name: scalable-sync
|
container_name: scalable-sync
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
user: "${PUID}:${PGID}"
|
user: "${PUID}:${PGID}"
|
||||||
networks:
|
# networks:
|
||||||
- ext_net
|
# - ext_net
|
||||||
volumes:
|
volumes:
|
||||||
- scalable-sync-data:/app/data
|
- scalable-sync-data:/app/data
|
||||||
- scalable-sync-config:/tmp/sc-config
|
- scalable-sync-config:/tmp/sc-config
|
||||||
@@ -25,9 +25,9 @@ services:
|
|||||||
retries: 3
|
retries: 3
|
||||||
start_period: 30s
|
start_period: 30s
|
||||||
|
|
||||||
networks:
|
#networks:
|
||||||
ext_net:
|
# ext_net:
|
||||||
external: true
|
# external: true
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
scalable-sync-data:
|
scalable-sync-data:
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Berechtigungen für Volumes setzen (als root)
|
||||||
|
chown -R ${PUID:-1000}:${PGID:-1000} /app/data /tmp/sc-config 2>/dev/null || true
|
||||||
|
chmod 700 /tmp/sc-config 2>/dev/null || true
|
||||||
|
|
||||||
|
# Auf User wechseln und Python-Skript starten
|
||||||
|
exec gosu appuser python /app/scalable_sync.py "$@"
|
||||||
Reference in New Issue
Block a user