Files
boilerplate-fe/Dockerfile
Fahri Can Seçer dc7ed1c48c
Some checks failed
UI Deploy (Next-Auth Support) 🎨 / build-and-deploy (push) Failing after 2m42s
main
2026-01-27 23:24:17 +03:00

44 lines
1.2 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.
# --- 1. Bağımlılık Katmanı ---
FROM node:20-alpine AS deps
RUN apk add --no-cache libc6-compat
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
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"]