43 lines
1.1 KiB
Docker
43 lines
1.1 KiB
Docker
# ---------- Angular Frontend Build ----------
|
|
FROM node:20-alpine AS frontend-builder
|
|
WORKDIR /costly-client
|
|
COPY costly-client/package*.json ./
|
|
RUN npm install
|
|
COPY costly-client/ .
|
|
RUN npm run build
|
|
|
|
# ---------- NestJS Backend Build ----------
|
|
FROM node:20-alpine AS backend-builder
|
|
WORKDIR /costly-api
|
|
COPY costly-api/package*.json ./
|
|
RUN npm install
|
|
COPY costly-api/ .
|
|
RUN npm run build
|
|
|
|
# ---------- Final Container mit Nginx + Node ----------
|
|
FROM nginx:alpine
|
|
RUN apk add --no-cache nginx nodejs npm
|
|
|
|
# Setup Arbeitsverzeichnis
|
|
WORKDIR /app
|
|
|
|
# Copy Angular Output nach Nginx Webroot
|
|
COPY --from=frontend-builder /costly-client/dist/costly-client/browser /usr/share/nginx/html
|
|
|
|
# Copy NestJS Backend
|
|
COPY --from=backend-builder /costly-api/dist ./dist
|
|
COPY --from=backend-builder /costly-api/package*.json ./
|
|
COPY --from=backend-builder /costly-api/node_modules ./node_modules
|
|
|
|
# Copy Nginx Config
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Copy .env wenn du willst
|
|
# COPY backend/.env .env
|
|
|
|
# Expose Port
|
|
EXPOSE 80
|
|
|
|
# Starte sowohl Backend als auch Nginx (via script)
|
|
CMD ["sh", "-c", "node dist/main.js & nginx -g 'daemon off;'"]
|