Files
boilerplate-be/Dockerfile
Fahri Can Seçer d52abd9b86
Some checks failed
Backend Deploy 🚀 / build-and-deploy (push) Failing after 35s
main
2026-01-27 00:17:11 +03:00

56 lines
1.3 KiB
Docker
Raw Permalink 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
# Paket dosyalarını kopyala
COPY package*.json ./
RUN npm ci
# Kaynak kodları kopyala
COPY . .
# Prisma client üret (Database şeman için şart)
RUN npx prisma generate
# Build al (NestJS/Backend için)
RUN npm run 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
WORKDIR /app
COPY package*.json ./
# Sadece production (canlıda lazım olan) paketleri kur
RUN npm ci --only=production
# Prisma şemasını taşı ve client üret
COPY prisma ./prisma
RUN npx prisma generate
# Build edilen dosyaları taşı (Senin Dockerfile'ındaki yapıya sadık kaldım)
# 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"]