change to production server for frontend

This commit is contained in:
Michi 2025-05-07 10:21:29 +02:00
parent ba8c1eba86
commit 5cdeb2b897
2 changed files with 26 additions and 7 deletions

View file

@ -29,7 +29,7 @@ services:
context: /app/frontend context: /app/frontend
restart: unless-stopped restart: unless-stopped
ports: ports:
- 5173:5173 - 5173:3000
grafana-inp21b: grafana-inp21b:
image: grafana/grafana:latest image: grafana/grafana:latest

View file

@ -1,16 +1,35 @@
FROM node:22-alpine # Stage 1: Build
FROM node:22-alpine as build
RUN mkdir app # Setze den Arbeitsordner
WORKDIR /app/ WORKDIR /app/
# Installiere git, um das Repository klonen zu können
RUN apk update && apk add git RUN apk update && apk add git
RUN git clone https://github.com/bjgedeon/Frontend-M241-245.git
WORKDIR /app/Frontend-M241-245 # Klone das GitHub-Repository
RUN git clone https://github.com/bjgedeon/Frontend-M241-245.git .
# Installiere Abhängigkeiten
RUN npm install RUN npm install
EXPOSE 5173 # Erstelle die Produktionsversion
RUN npm run build
CMD [ "npm", "run", "dev", "--", "--host", "0.0.0.0" ] # Stage 2: Serve
FROM node:22-alpine as serve
# Installiere Serve um statische Dateien zu bedienen
RUN npm install -g serve
# Setze den Arbeitsordner
WORKDIR /app/
# Kopiere die gebauten Dateien vom vorherigen Build
COPY --from=build /app/dist ./dist
# Exponiere den Port
EXPOSE 3000
# Kommando zum Ausführen des Servers
CMD ["serve", "-s", "dist", "-l", "3000"]