From df0b60c97a9c222e2ae611a63b1f0f5a5e5d8b8b Mon Sep 17 00:00:00 2001 From: Fahri Can Date: Tue, 17 Mar 2026 14:00:23 +0300 Subject: [PATCH] main --- .gitea/workflows/deploy-ui.yml | 21 +++++---------- Dockerfile | 47 ++++++++-------------------------- nginx.conf | 21 +++++++++++++++ 3 files changed, 39 insertions(+), 50 deletions(-) create mode 100644 nginx.conf diff --git a/.gitea/workflows/deploy-ui.yml b/.gitea/workflows/deploy-ui.yml index 103d659..7efdb97 100644 --- a/.gitea/workflows/deploy-ui.yml +++ b/.gitea/workflows/deploy-ui.yml @@ -1,4 +1,4 @@ -name: UI Deploy (Next-Auth Support) 🎨 +name: HarunCAN Studio FE Deploy 🎨 run-name: ${{ gitea.actor }} frontend güncelliyor... on: @@ -13,25 +13,18 @@ jobs: uses: actions/checkout@v3 - name: Docker Build - # Tarayıcı tarafında (Client-side) lazım olanları build anında veriyoruz run: | docker build \ - --build-arg NEXT_PUBLIC_API_URL='${{ secrets.NEXT_PUBLIC_API_URL }}' \ - --build-arg NEXT_PUBLIC_AUTH_REQUIRED='${{ secrets.NEXT_PUBLIC_AUTH_REQUIRED }}' \ - --build-arg NEXT_PUBLIC_GOOGLE_API_KEY='${{ secrets.NEXT_PUBLIC_GOOGLE_API_KEY }}' \ - -t frontend-proje:latest . + --build-arg GEMINI_API_KEY='${{ secrets.GEMINI_API_KEY }}' \ + -t haruncan-studio-fe:latest . - name: Eski Konteyneri Sil - run: docker rm -f frontend-container || true + run: docker rm -f haruncan-studio-fe-container || true - name: Yeni Versiyonu Başlat - # Sunucu tarafında (Server-side/Auth) lazım olanları run anında veriyoruz run: | docker run -d \ - --name frontend-container \ + --name haruncan-studio-fe-container \ --restart always \ - --network gitea-server_gitea \ - -p 1800:3000 \ - -e NEXTAUTH_SECRET='${{ secrets.NEXTAUTH_SECRET }}' \ - -e NEXTAUTH_URL='${{ secrets.NEXTAUTH_URL }}' \ - frontend-proje:latest \ No newline at end of file + -p 1509:80 \ + haruncan-studio-fe:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 629195e..2c705d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,44 +1,19 @@ -# --- 1. Bağı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"] \ No newline at end of file +# --- 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;"] \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..3f0f0a5 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,21 @@ +server { + listen 80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + # Gzip sıkıştırma + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml; + + # SPA routing — tüm yolları index.html'e yönlendir + location / { + try_files $uri $uri/ /index.html; + } + + # Statik dosya cache (JS, CSS, images, fonts) + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } +}