# Build-Phase
FROM node:20-slim AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install --legacy-peer-deps
COPY . .
RUN npm run build

# Production-Phase
FROM nginx:1.25

# Eigene Nginx-Konfiguration kopieren
COPY default.conf /etc/nginx/conf.d/default.conf

# Nginx konfigurieren für non-root Port 8080
RUN touch /var/run/nginx.pid && \
    chown -R nginx:nginx /var/run/nginx.pid /var/cache/nginx /var/log/nginx /etc/nginx/conf.d

USER nginx
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 8080
