Files
spelljammer-ships/Dockerfile
Bas van Rossem 9ef1199324 chore: add Dockerfile and docker-compose with static file serving
Multi-stage Docker build (web → server → production). Fastify serves
React build in production with SPA fallback. Docker Compose with volume
for SQLite persistence.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 16:30:17 +01:00

44 lines
1.0 KiB
Docker

# ---- Stage 1: Build the React frontend ----
FROM node:18-alpine AS web-build
WORKDIR /app/web
COPY web/package.json web/package-lock.json ./
RUN npm ci
COPY web/ ./
RUN npm run build
# ---- Stage 2: Build the Node.js server ----
FROM node:18-alpine AS server-build
WORKDIR /app/server
COPY server/package.json server/package-lock.json ./
RUN npm ci
COPY server/ ./
RUN npm run build
# ---- Stage 3: Production image ----
FROM node:18-alpine AS production
WORKDIR /app
# Copy server package files and install production deps only
COPY server/package.json server/package-lock.json ./
RUN npm ci --omit=dev
# Copy compiled server
COPY --from=server-build /app/server/dist ./dist
# Copy server migration files (needed at runtime)
COPY --from=server-build /app/server/src/db/migrations ./dist/db/migrations
# Copy frontend build output
COPY --from=web-build /app/web/dist ./web-dist
# Create data directory for SQLite
RUN mkdir -p /data
ENV NODE_ENV=production
ENV PORT=3000
ENV DB_PATH=/data/spelljammer.sqlite
EXPOSE 3000
CMD ["node", "dist/index.js"]