main
All checks were successful
HarunCAN Studio FE Deploy 🎨 / build-and-deploy (push) Successful in 41s

This commit is contained in:
2026-03-17 14:00:23 +03:00
parent c339cb1382
commit df0b60c97a
3 changed files with 39 additions and 50 deletions

View File

@@ -1,44 +1,19 @@
# --- 1. Bımlılık Katmanı ---
FROM node:20-alpine AS deps
RUN apk add --no-cache libc6-compat
# --- 1. Build Katmanı ---
FROM node:20-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
# --- 2. Build Katmanı ---
FROM node:20-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# [DİKKAT] Build anındaki env'leri buraya tanımlıyoruz
ARG NEXT_PUBLIC_API_URL
ARG NEXT_PUBLIC_AUTH_REQUIRED
ARG NEXT_PUBLIC_GOOGLE_API_KEY
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_AUTH_REQUIRED=$NEXT_PUBLIC_AUTH_REQUIRED
ENV NEXT_PUBLIC_GOOGLE_API_KEY=$NEXT_PUBLIC_GOOGLE_API_KEY
# Build-time env (vite.config.ts'de kullanılıyor)
ARG GEMINI_API_KEY
ENV GEMINI_API_KEY=$GEMINI_API_KEY
RUN npm run build
# --- 3. Çalıştırma Katmanı (Runner) ---
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV production
# Güvenlik: Root kullanıcı kullanmıyoruz
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
# Standalone mode çıktılarını alıyoruz
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT 3000
# Standalone modda server.js üzerinden çalışır
CMD ["node", "server.js"]
# --- 2. Production Katmanı (Nginx ile statik serve) ---
FROM nginx:alpine AS runner
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]