update docker file

This commit is contained in:
2025-09-09 15:07:53 -04:00
parent 679d2facae
commit f8f5f95a34
2 changed files with 22 additions and 19 deletions
+17 -19
View File
@@ -21,25 +21,23 @@ COPY VERSION .
RUN mkdir -p /app/data && chown -R appuser:appuser /app
# Root-aware entrypoint
RUN cat > /entrypoint.sh << 'EOF'
#!/bin/bash
set -euo pipefail
PUID=${PUID:-1000}
PGID=${PGID:-1000}
if [ "$(id -u)" -eq 0 ]; then
# running as root: we can adjust IDs and drop privileges
groupmod -o -g "$PGID" appuser 2>/dev/null || groupadd -o -g "$PGID" appuser
id appuser &>/dev/null || useradd -o -u "$PUID" -g "$PGID" -m appuser
usermod -o -u "$PUID" -g "$PGID" appuser 2>/dev/null || true
chown -R "$PUID:$PGID" /app || true
exec gosu appuser "$@"
else
# not root (e.g., compose set user: 1000:1000) — just run
exec "$@"
fi
EOF
RUN echo '#!/bin/bash' > /entrypoint.sh && \
echo 'set -euo pipefail' >> /entrypoint.sh && \
echo '' >> /entrypoint.sh && \
echo 'PUID=${PUID:-1000}' >> /entrypoint.sh && \
echo 'PGID=${PGID:-1000}' >> /entrypoint.sh && \
echo '' >> /entrypoint.sh && \
echo 'if [ "$(id -u)" -eq 0 ]; then' >> /entrypoint.sh && \
echo ' # running as root: we can adjust IDs and drop privileges' >> /entrypoint.sh && \
echo ' groupmod -o -g "$PGID" appuser 2>/dev/null || groupadd -o -g "$PGID" appuser' >> /entrypoint.sh && \
echo ' id appuser &>/dev/null || useradd -o -u "$PUID" -g "$PGID" -m appuser' >> /entrypoint.sh && \
echo ' usermod -o -u "$PUID" -g "$PGID" appuser 2>/dev/null || true' >> /entrypoint.sh && \
echo ' chown -R "$PUID:$PGID" /app || true' >> /entrypoint.sh && \
echo ' exec gosu appuser "$@"' >> /entrypoint.sh && \
echo 'else' >> /entrypoint.sh && \
echo ' # not root (e.g., compose set user: 1000:1000) — just run' >> /entrypoint.sh && \
echo ' exec "$@"' >> /entrypoint.sh && \
echo 'fi' >> /entrypoint.sh
RUN chmod +x /entrypoint.sh
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \