Add Docker setup with multi-stage build and Compose deploy config

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-03 18:29:58 +02:00
parent c65c9f1751
commit 34cfcecc1e
3 changed files with 68 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
# ── Stage 1: Dependencies (mit Compiler für better-sqlite3) ──────────────────
FROM node:20.19.2-slim AS deps
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 make g++ \
&& rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
# ── Stage 2: Runtime ──────────────────────────────────────────────────────────
FROM node:20.19.2-slim AS runtime
WORKDIR /app
RUN groupadd --system --gid 1001 nodejs \
&& useradd --system --uid 1001 --gid nodejs --no-create-home appuser
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN mkdir -p data && chown -R appuser:nodejs data
VOLUME ["/app/data"]
USER appuser
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/',r=>process.exit(r.statusCode===200?0:1)).on('error',()=>process.exit(1))"
CMD ["node", "server.js"]