# Stage 1: Vite SPA build FROM node:22-alpine AS build WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build # Stage 2: nginx (frontend) + node (canlı veri backend) tek container'da FROM node:22-alpine RUN apk add --no-cache nginx # Frontend COPY --from=build /app/dist /usr/share/nginx/html COPY --from=build /app/nginx.conf /etc/nginx/http.d/default.conf # Backend (yalnızca Node builtin'leri kullanır — npm bağımlılığı yok) WORKDIR /app COPY --from=build /app/server ./server # Başlangıç: Node backend'i (3001) arka planda + nginx ön planda RUN printf '#!/bin/sh\nset -e\nnode /app/server/index.js &\nexec nginx -g "daemon off;"\n' > /start.sh \ && chmod +x /start.sh EXPOSE 80 CMD ["/start.sh"]