30 lines
721 B
Docker
30 lines
721 B
Docker
# Nutze Node.js als Basis (LTS Version)
|
|
FROM node:20-alpine AS build
|
|
WORKDIR /app
|
|
|
|
# Kopiere package files und installiere Abhängigkeiten
|
|
COPY package*.json ./
|
|
RUN npm install
|
|
|
|
# Kopiere den restlichen Code
|
|
COPY . .
|
|
|
|
# Baue das Frontend (erzeugt den 'dist' Ordner)
|
|
RUN npm run build
|
|
|
|
# Finales Image
|
|
FROM node:20-alpine
|
|
WORKDIR /app
|
|
|
|
# Installiere nur Production-Abhängigkeiten
|
|
COPY package*.json ./
|
|
RUN npm install --production
|
|
|
|
# Kopiere das gebaute Frontend und das Backend
|
|
COPY --from=build /app/dist ./dist
|
|
COPY --from=build /app/server.cjs ./
|
|
# Die Zeile mit /app/public wurde entfernt, da Vite dies bereits in /dist integriert hat
|
|
|
|
# Der Express-Server läuft auf Port 3000
|
|
EXPOSE 3000
|
|
CMD ["node", "server.cjs"] |