fix(docker): fix EACCES on runtime data dir
Docker Build and Publish / pr-build (push) Skipped
Docker Build and Publish / publish (push) Canceled after 0s

- add docker-entrypoint.sh that creates and chowns /app/data at startup
- run as nextjs via su-exec after fixing directory ownership
- handle root-owned named volumes created by earlier images
This commit is contained in:
siujamo committed 2026-08-31 14:58:50 +08:00
1 parent 595b384150
commit 0caf1cdbee
3 files changed
+29 -1

No files matched your search

+9 -1
View File
@@ -32,7 +32,15 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
RUN mkdir -p /app/data/prototypes \
&& chown -R nextjs:nodejs /app/data
USER nextjs
# The entrypoint runs as root at startup so it can fix ownership of
# /app/data even when it is a volume created by an earlier image,
# then drops to the unprivileged `nextjs` user via su-exec.
RUN apk add --no-cache su-exec
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN sed -i 's/\r$//' /usr/local/bin/docker-entrypoint.sh \
&& chmod +x /usr/local/bin/docker-entrypoint.sh
EXPOSE 3000
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["node", "server.js"]