fix: entrypoint script fixes data dir permissions at runtime
Container starts as root, creates data dirs, chowns to nextjs, then drops to nextjs user via su-exec. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+5
-2
@@ -28,7 +28,10 @@ COPY --from=builder /app/public ./public
|
||||
RUN mkdir -p /app/data/uploads/photos /app/data/uploads/videos /app/data/uploads/music \
|
||||
&& chown -R nextjs:nodejs /app/data
|
||||
|
||||
USER nextjs
|
||||
# Entrypoint fixes data dir permissions at runtime (volume mount overrides)
|
||||
RUN apk add --no-cache su-exec \
|
||||
&& printf '#!/bin/sh\nmkdir -p /app/data/uploads/photos /app/data/uploads/videos /app/data/uploads/music\nchown -R nextjs:nodejs /app/data 2>/dev/null || true\nexec su-exec nextjs node server.js\n' > /app/entrypoint.sh \
|
||||
&& chmod +x /app/entrypoint.sh
|
||||
|
||||
EXPOSE 3000
|
||||
CMD ["node", "server.js"]
|
||||
CMD ["/app/entrypoint.sh"]
|
||||
|
||||
Reference in New Issue
Block a user