This repository has been archived on 2026-05-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
tippspiel/Dockerfile
T
Ronny 7bd22b53e9 feat: add Docker containerization (Dockerfile, compose, dockerignore)
Multi-stage build: frontend (Vite) + backend (TypeScript) in one container.
Production image based on node:20-alpine with health check.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 10:05:10 +02:00

54 lines
1.5 KiB
Docker

# ============================================================
# Stage 1: Build Frontend (React + Vite)
# ============================================================
FROM node:20-alpine AS build-frontend
WORKDIR /app/frontend
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
# Output: /app/frontend/../backend/public → /app/backend/public
# ============================================================
# Stage 2: Build Backend (TypeScript → JavaScript)
# ============================================================
FROM node:20-alpine AS build-backend
WORKDIR /app/backend
COPY backend/package.json backend/package-lock.json ./
RUN npm ci
COPY backend/ ./
RUN npx tsc
# ============================================================
# Stage 3: Production Image
# ============================================================
FROM node:20-alpine AS production
WORKDIR /app
# Nur Production-Dependencies installieren
COPY backend/package.json backend/package-lock.json ./
RUN npm ci --omit=dev && npm cache clean --force
# Compiled Backend
COPY --from=build-backend /app/backend/dist ./dist
# Frontend Build (statische Dateien)
COPY --from=build-frontend /app/backend/public ./public
# Non-root User
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser
ENV NODE_ENV=production
ENV PORT=3001
EXPOSE 3001
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -qO- http://localhost:3001/health || exit 1
CMD ["node", "dist/index.js"]