generated from fahricansecer/boilerplate-fe
main
All checks were successful
HarunCAN Studio FE Deploy 🎨 / build-and-deploy (push) Successful in 41s
All checks were successful
HarunCAN Studio FE Deploy 🎨 / build-and-deploy (push) Successful in 41s
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
name: UI Deploy (Next-Auth Support) 🎨
|
name: HarunCAN Studio FE Deploy 🎨
|
||||||
run-name: ${{ gitea.actor }} frontend güncelliyor...
|
run-name: ${{ gitea.actor }} frontend güncelliyor...
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -13,25 +13,18 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Docker Build
|
- name: Docker Build
|
||||||
# Tarayıcı tarafında (Client-side) lazım olanları build anında veriyoruz
|
|
||||||
run: |
|
run: |
|
||||||
docker build \
|
docker build \
|
||||||
--build-arg NEXT_PUBLIC_API_URL='${{ secrets.NEXT_PUBLIC_API_URL }}' \
|
--build-arg GEMINI_API_KEY='${{ secrets.GEMINI_API_KEY }}' \
|
||||||
--build-arg NEXT_PUBLIC_AUTH_REQUIRED='${{ secrets.NEXT_PUBLIC_AUTH_REQUIRED }}' \
|
-t haruncan-studio-fe:latest .
|
||||||
--build-arg NEXT_PUBLIC_GOOGLE_API_KEY='${{ secrets.NEXT_PUBLIC_GOOGLE_API_KEY }}' \
|
|
||||||
-t frontend-proje:latest .
|
|
||||||
|
|
||||||
- name: Eski Konteyneri Sil
|
- 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
|
- name: Yeni Versiyonu Başlat
|
||||||
# Sunucu tarafında (Server-side/Auth) lazım olanları run anında veriyoruz
|
|
||||||
run: |
|
run: |
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name frontend-container \
|
--name haruncan-studio-fe-container \
|
||||||
--restart always \
|
--restart always \
|
||||||
--network gitea-server_gitea \
|
-p 1509:80 \
|
||||||
-p 1800:3000 \
|
haruncan-studio-fe:latest
|
||||||
-e NEXTAUTH_SECRET='${{ secrets.NEXTAUTH_SECRET }}' \
|
|
||||||
-e NEXTAUTH_URL='${{ secrets.NEXTAUTH_URL }}' \
|
|
||||||
frontend-proje:latest
|
|
||||||
47
Dockerfile
47
Dockerfile
@@ -1,44 +1,19 @@
|
|||||||
# --- 1. Bağımlılık Katmanı ---
|
# --- 1. Build Katmanı ---
|
||||||
FROM node:20-alpine AS deps
|
FROM node:20-alpine AS builder
|
||||||
RUN apk add --no-cache libc6-compat
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
# --- 2. Build Katmanı ---
|
|
||||||
FROM node:20-alpine AS builder
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# [DİKKAT] Build anındaki env'leri buraya tanımlıyoruz
|
# Build-time env (vite.config.ts'de kullanılıyor)
|
||||||
ARG NEXT_PUBLIC_API_URL
|
ARG GEMINI_API_KEY
|
||||||
ARG NEXT_PUBLIC_AUTH_REQUIRED
|
ENV GEMINI_API_KEY=$GEMINI_API_KEY
|
||||||
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
|
RUN npm run build
|
||||||
|
|
||||||
# --- 3. Çalıştırma Katmanı (Runner) ---
|
# --- 2. Production Katmanı (Nginx ile statik serve) ---
|
||||||
FROM node:20-alpine AS runner
|
FROM nginx:alpine AS runner
|
||||||
WORKDIR /app
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
ENV NODE_ENV production
|
EXPOSE 80
|
||||||
# Güvenlik: Root kullanıcı kullanmıyoruz
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
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"]
|
|
||||||
21
nginx.conf
Normal file
21
nginx.conf
Normal file
@@ -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";
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user