feat(docker): add production Dockerfile, docker-compose setup and healthcheck API

This commit is contained in:
Daniel S
2026-08-09 21:28:10 +02:00
parent 03ceb3de7f
commit b021f9aaa7
4 changed files with 99 additions and 21 deletions

View File

@@ -1,25 +1,38 @@
# Build-Phase
FROM node:20-slim AS builder
# STAGE 1: Dependencies & Build
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install --legacy-peer-deps
RUN npm ci
COPY . .
ENV NODE_ENV=production
RUN npm run build
# Production-Phase (Node SSR Runner)
FROM node:20-slim AS runner
# STAGE 2: Production Runner
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=4321
ENV PORT=3000
ENV DATA_DIR=/app/data
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/data_template ./data_template
# Erstelle Kunden-Volume Ordner
RUN mkdir -p /app/data && chown -R node:node /app
EXPOSE 4321
COPY package*.json ./
RUN npm ci --only=production
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/public ./public
USER node
EXPOSE 3000
# Healthcheck für Docker / Nginx Proxy
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
CMD ["node", "./dist/server/entry.mjs"]