Files
ihaleist/Dockerfile
T

29 lines
913 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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 (sabit 3001) arka planda + nginx (80) ön planda.
# Coolify container'a PORT=80 verir; backend'i 3001'e sabitleyip nginx ile
# çakışmasını önlüyoruz (nginx /api → 127.0.0.1:3001 proxy'ler).
RUN printf '#!/bin/sh\nset -e\nPORT=3001 node /app/server/index.js &\nexec nginx -g "daemon off;"\n' > /start.sh \
&& chmod +x /start.sh
EXPOSE 80
CMD ["/start.sh"]