Fix media permissions inside app container

This commit is contained in:
2026-09-18 02:22:15 +02:00
parent 46a7cc23bd
commit 59d6daa2fe
2 changed files with 18 additions and 2 deletions
+6 -2
View File
@@ -5,10 +5,10 @@
# .env.example) - this image builds without a database connection.
FROM node:22-alpine AS base
RUN apk add --no-cache libc6-compat su-exec
# ---- deps: install once, cached as its own layer -------------------------
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
@@ -41,7 +41,11 @@ COPY --from=builder --chown=nextjs:nodejs /app /app
# Docker volumes mounted over these paths (see docker-compose.yml).
RUN mkdir -p media backups && chown -R nextjs:nodejs media backups
USER nextjs
COPY --from=builder --chown=root:root /app/docker/anouma-entrypoint.sh /usr/local/bin/anouma-entrypoint.sh
RUN chmod 755 /usr/local/bin/anouma-entrypoint.sh
USER root
ENTRYPOINT ["/usr/local/bin/anouma-entrypoint.sh"]
EXPOSE 3000
ENV PORT=3000
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
set -eu
# /app/media is a persistent host bind mount in production. Its host owner
# can differ from the unprivileged application user inside the image, so fix
# the mount ownership before dropping privileges for the actual app process.
if [ -d /app/media ]; then
chown -R nextjs:nodejs /app/media
chmod 775 /app/media
fi
exec su-exec nextjs "$@"