36 lines
747 B
Docker
36 lines
747 B
Docker
# ---- Build stage ----
|
|
FROM node:22-slim AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Native module build tools (better-sqlite3, bcrypt)
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
python3 make g++ \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
|
|
COPY . .
|
|
RUN npm run build && npm prune --production
|
|
|
|
# ---- Production stage ----
|
|
FROM node:22-slim AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /app/build ./build
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY package.json ./
|
|
|
|
# Directories that will be bind-mounted at runtime
|
|
RUN mkdir -p /data /games/public /games/private
|
|
|
|
EXPOSE 3000
|
|
|
|
ENV NODE_ENV=production \
|
|
GAMES_PATH=/games \
|
|
DB_PATH=/data/game-grid.db
|
|
|
|
CMD ["node", "build/index.js"]
|