# Build stage FROM node:20-alpine as build WORKDIR /app # Tambahkan dependensi yang mungkin dibutuhkan RUN apk add --no-cache python3 make g++ git # Copy package files dan install dependencies COPY package.json package-lock.json* ./ # Gunakan --legacy-peer-deps untuk mengatasi masalah kompatibilitas RUN npm ci --legacy-peer-deps || npm install --legacy-peer-deps # Copy kode aplikasi COPY . . # Build aplikasi RUN npm run build # Production stage FROM nginx:alpine # Copy file hasil build ke nginx COPY --from=build /app/dist /usr/share/nginx/html # Buat konfigurasi nginx untuk SPA routing RUN echo 'server { \ listen 80; \ server_name _; \ root /usr/share/nginx/html; \ index index.html; \ location / { \ try_files $uri $uri/ /index.html; \ } \ }' > /etc/nginx/conf.d/default.conf # Expose port 80 EXPOSE 80 # Start nginx CMD ["nginx", "-g", "daemon off;"]