Files
ContentGen_BE/Dockerfile
Harun CAN acb103657b
Some checks failed
Backend Deploy 🚀 / build-and-deploy (push) Has been cancelled
main
2026-03-30 00:21:32 +03:00

62 lines
1.5 KiB
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.
# --- Build Stage ---
FROM node:20-alpine AS builder
WORKDIR /app
# Raspberry Pi ve Prisma uyumluluğu için gerekli kütüphaneler
RUN apk add --no-cache openssl libc6-compat
# pnpm kurulumu (workspace kuralı gereği)
RUN corepack enable && corepack prepare pnpm@latest --activate
# Paket dosyalarını kopyala
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# Kaynak kodları kopyala
COPY . .
# Prisma client üret (Database şeması için şart)
RUN npx prisma generate
# Build al (NestJS/Backend için)
RUN pnpm build
# --- Production Stage (Canlı Sistem) ---
FROM node:20-alpine AS production
# Prisma için gerekli kütüphaneleri buraya da ekliyoruz
RUN apk add --no-cache openssl libc6-compat
# pnpm kurulumu
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
# Sadece production (canlıda lazım olan) paketleri kur
RUN pnpm install --frozen-lockfile --prod
# Prisma şemasını taşı ve client üret
COPY prisma ./prisma
RUN npx prisma generate
# Build edilen dosyaları taşı
# Güvenlik için dosyaları 'node' kullanıcısına zimmetliyoruz
COPY --chown=node:node --from=builder /app/dist ./dist
# Eğer i18n varsa onu da taşı
COPY --chown=node:node --from=builder /app/src/i18n ./dist/i18n
# Ortam değişkeni
ENV NODE_ENV=production
# Portu aç
EXPOSE 3000
# Güvenlik: Root yerine 'node' kullanıcısına geç
USER node
# Uygulamayı başlat
CMD ["node", "dist/main.js"]