This commit is contained in:
45
Dockerfile
45
Dockerfile
@@ -1,49 +1,56 @@
|
||||
# Build stage
|
||||
# --- Build Stage ---
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
# Raspberry Pi ve Prisma uyumluluğu için gerekli kütüphaneler
|
||||
RUN apk add --no-cache openssl libc6-compat
|
||||
|
||||
# Install dependencies
|
||||
# Paket dosyalarını kopyala
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Copy source code
|
||||
# Kaynak kodları kopyala
|
||||
COPY . .
|
||||
|
||||
# Generate Prisma client
|
||||
# Prisma client üret (Database şeman için şart)
|
||||
RUN npx prisma generate
|
||||
|
||||
# Build the application
|
||||
# Build al (NestJS/Backend için)
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
# --- 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 files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install production dependencies only
|
||||
# Sadece production (canlıda lazım olan) paketleri kur
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy Prisma schema and generate client
|
||||
# Prisma şemasını taşı ve client üret
|
||||
COPY prisma ./prisma
|
||||
RUN npx prisma generate
|
||||
|
||||
# Copy built application
|
||||
COPY --from=builder /app/dist ./dist
|
||||
# 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
|
||||
|
||||
# Copy i18n files
|
||||
COPY --from=builder /app/src/i18n ./dist/i18n
|
||||
# Eğer i18n varsa onu da taşı
|
||||
COPY --chown=node:node --from=builder /app/src/i18n ./dist/i18n
|
||||
|
||||
# Set environment
|
||||
# Ortam değişkeni
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Expose port
|
||||
# Portu aç
|
||||
EXPOSE 3000
|
||||
|
||||
# Start the application
|
||||
CMD ["node", "dist/main.js"]
|
||||
# Güvenlik: Root yerine 'node' kullanıcısına geç
|
||||
USER node
|
||||
|
||||
# Uygulamayı başlat
|
||||
CMD ["node", "dist/main.js"]
|
||||
Reference in New Issue
Block a user