Add non-root user support and entrypoint script for Docker setup

This commit is contained in:
2026-06-06 17:27:10 +02:00
parent 21620290e2
commit 5ad2ad691f
3 changed files with 27 additions and 6 deletions
+8 -5
View File
@@ -19,20 +19,23 @@ ENV NODE_ENV=production
# DATA_DIR is the single volume mount point for both SQLite and uploads
ENV DATA_DIR=/data
# Create a non-root user
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs && \
# Create a non-root user with default UID/GID (overridable at runtime via PUID/PGID)
RUN apk add --no-cache su-exec shadow && \
addgroup --gid 1001 nodejs && \
adduser --uid 1001 --ingroup nodejs --disabled-password --gecos "" nextjs && \
mkdir -p /data/uploads && chown -R nextjs:nodejs /data
# Copy standalone build output
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
USER nextjs
COPY --chmod=755 entrypoint.sh /entrypoint.sh
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
ENV PUID=1001
ENV PGID=1001
ENTRYPOINT ["/entrypoint.sh"]
CMD ["node", "server.js"]