Files
oma-memorial/Dockerfile
T
denshooter 70ac6c132f 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>
2026-02-18 13:26:27 +01:00

38 lines
1010 B
Docker

FROM node:22-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# ---- Runner ----
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 nextjs
# Standalone output
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
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
# 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 ["/app/entrypoint.sh"]