Files
dickendock/Dockerfile

34 lines
1.7 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: React bauen ─────────────────────────────────────────────────────
FROM node:20-alpine AS builder
WORKDIR /build
COPY frontend/package.json ./
RUN npm install
COPY frontend/ ./
# version.txt VOR dem Build generieren Unix-Timestamp (Sekunden)
# Dieser Wert wird von vite.config.js als __BUILD_TIME__ ins Bundle gebacken
# UND vom Backend als /api/build-time ausgeliefert → exakt derselbe Wert
RUN date -u +"%s" > ./version.txt
# Build-Version in sw.js einsetzen damit der Browser bei jedem Deploy einen neuen SW erkennt
RUN BUILD_V=$(cat ./version.txt) && sed -i "s/__BUILD_VERSION__/${BUILD_V}/g" ./public/sw.js
RUN npm run build
# ── Stage 2: Express liefert API + React in einem Container ──────────────────
FROM node:20-alpine
# Puppeteer/Chromium für KöPi Web-Scraping
RUN apk add --no-cache tzdata python3 make g++ chromium nss freetype harfbuzz ca-certificates ttf-freefont
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
# Zeitzone fest auf Europe/Berlin setzen, damit Server und Browser (DE) immer
# dieselbe lokale Zeit berechnen inkl. automatischer Sommer-/Winterzeit-Umstellung
ENV TZ=Europe/Berlin
RUN cp /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /app
COPY backend/package.json ./
RUN npm install --production
COPY backend/ ./
# version.txt aus dem Build-Stage kopieren (selber Wert wie im JS-Bundle)
COPY --from=builder /build/version.txt ./version.txt
COPY --from=builder /build/dist ./public
EXPOSE 4000
CMD ["node", "src/index.js"]