Files
Dota-Zombie-Invasion/backend/Dockerfile
T
achmad 84bbf5ac4b fix: fix SQLite database permission error on volume mounts
Entrypoint now runs as root, fixes ownership of /app/data to nextjs:nodejs
(uid 1001), then drops privileges via su before starting the app.
This fixes 'unable to open database file' when the host data/ directory
is created by Docker as root and is not writable by the nextjs user.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 19:01:11 +07:00

40 lines
890 B
Docker

FROM node:20-alpine AS base
# Stage 1: Install deps
FROM base AS deps
RUN apk add --no-cache python3 make g++ gcc
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci
# Stage 2: Build
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# Stage 3: Production runner
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV DB_PATH=/app/data/zombie_invasion.db
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/docker-entrypoint.sh ./
RUN chmod +x docker-entrypoint.sh
RUN mkdir -p /app/data && chown -R nextjs:nodejs /app/data
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
ENTRYPOINT ["/bin/sh", "docker-entrypoint.sh"]