53 lines
1.4 KiB
Docker
53 lines
1.4 KiB
Docker
# ==========================================
|
|
# dashboard/Dockerfile (Production)
|
|
# 🔧 OPTIMIERT: Multi-Stage-Build für ein minimales Produktions-Image
|
|
# ==========================================
|
|
|
|
# Stage 1: Build-Umgebung
|
|
FROM node:20-alpine AS build
|
|
|
|
WORKDIR /app
|
|
|
|
# Kopiere package.json und pnpm-lock.yaml
|
|
COPY package.json package-lock.json ./
|
|
|
|
# Installiere pnpm und dann die Abhängigkeiten
|
|
# --prod stellt sicher, dass nur Produktions-Abhängigkeiten installiert werden
|
|
RUN npm install --frozen-lockfile
|
|
|
|
# Kopiere den restlichen Quellcode
|
|
COPY . .
|
|
|
|
# Setze Build-Argumente als Umgebungsvariablen
|
|
ARG VITE_API_URL
|
|
ENV VITE_API_URL=${VITE_API_URL}
|
|
|
|
# Baue die Anwendung für die Produktion
|
|
RUN npm run build
|
|
|
|
# Stage 2: Produktions-Umgebung
|
|
FROM nginx:1.25-alpine
|
|
|
|
# Kopiere die gebauten statischen Dateien aus der Build-Stage
|
|
COPY --from=build /app/dist /usr/share/nginx/html
|
|
|
|
# Optional: Eine Nginx-Konfiguration für Single-Page-Applications (SPA)
|
|
# Diese leitet alle Anfragen, die keine Dateien sind, auf die index.html um.
|
|
# Erstelle eine Datei `nginx.prod.conf` mit folgendem Inhalt:
|
|
# server {
|
|
# listen 80;
|
|
# root /usr/share/nginx/html;
|
|
# index index.html;
|
|
# location / {
|
|
# try_files $uri $uri/ /index.html;
|
|
# }
|
|
# }
|
|
# COPY nginx.prod.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Exponiere Port 80 (Standard-HTTP-Port von Nginx)
|
|
EXPOSE 80
|
|
|
|
# Starte Nginx
|
|
CMD ["nginx", "-g", "daemon off;"]
|
|
|