Files
windwiderstand/Dockerfile
T
Peter Meier 4dd17b7ac4
Deploy / verify (push) Successful in 57s
Deploy / deploy (push) Successful in 56s
fix(docker): add healthcheck and stop grace period
Watchtower waits for container to be healthy before stopping the old
one. Grace period allows in-flight requests to drain on shutdown.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 14:06:46 +02:00

42 lines
1.4 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ─────────────────────────────────────────────
# Stage 1: Build
# ─────────────────────────────────────────────
FROM node:22-alpine AS builder
WORKDIR /app
# Erst nur package*.json besseres Layer-Caching
COPY package*.json ./
# prepare läuft svelte-kit sync (|| true → unkritisch wenn Config fehlt)
RUN npm ci
COPY . .
RUN npm run build
# ─────────────────────────────────────────────
# Stage 2: Schlankes Production-Image
# ─────────────────────────────────────────────
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
# Nur Production-Deps, kein postinstall nötig
COPY package*.json ./
RUN npm ci --omit=dev --ignore-scripts
# Build-Artefakt aus Stage 1
COPY --from=builder /app/build ./build
# Non-root user
RUN addgroup -g 1001 -S nodejs \
&& adduser -S svelte -u 1001 -G nodejs \
&& chown -R svelte:nodejs /app
USER svelte
EXPOSE 3001
ENV PORT=3001
HEALTHCHECK --interval=5s --timeout=3s --start-period=15s --retries=3 \
CMD wget -qO- http://localhost:3001/ > /dev/null || exit 1
CMD ["node", "build"]