Adaption of dashboard to Vite and React
This commit is contained in:
@@ -1,52 +1,25 @@
|
||||
# ==========================================
|
||||
# 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 ./
|
||||
# Kopiere package.json und Lockfile aus dem Build-Kontext (./dashboard)
|
||||
COPY package*.json ./
|
||||
|
||||
# Installiere pnpm und dann die Abhängigkeiten
|
||||
# --prod stellt sicher, dass nur Produktions-Abhängigkeiten installiert werden
|
||||
RUN npm install --frozen-lockfile
|
||||
# Produktions-Abhängigkeiten installieren
|
||||
ENV NODE_ENV=production
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
# Kopiere den restlichen Quellcode
|
||||
# Quellcode kopieren und builden
|
||||
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;"]
|
||||
CMD ["nginx", " -g", "daemon off;"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user