From c2b81c19c53ff42977a570731683f96693d95799 Mon Sep 17 00:00:00 2001 From: Hyoseong Jo Date: Mon, 15 Dec 2025 14:41:47 +0900 Subject: [PATCH] init --- backend/Dockerfile | 5 +++-- frontend/.env | 5 ++++- frontend/.env.dev | 7 +++++-- frontend/.env.prod | 7 +++++-- frontend/.gitignore | 11 ++++++++++- frontend/Dockerfile | 4 +--- frontend/next.config.ts | 15 +++++++++------ frontend/next.config.ts.dev | 22 ---------------------- 8 files changed, 37 insertions(+), 39 deletions(-) delete mode 100644 frontend/next.config.ts.dev diff --git a/backend/Dockerfile b/backend/Dockerfile index af7c365..bd37eaf 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -7,12 +7,13 @@ RUN apk add --no-cache curl # 환경변수 설정 ENV NODE_ENV=production +ENV NODE_OPTIONS="--enable-source-maps" -# package.json만 먼저 복사 +# package.json 복사 COPY package*.json ./ # 의존성 설치 (devDependencies 포함 - nest CLI 필요) -RUN npm install +RUN npm install --include=dev # 소스 코드 복사 COPY . . diff --git a/frontend/.env b/frontend/.env index 31526d7..52fa998 100644 --- a/frontend/.env +++ b/frontend/.env @@ -3,9 +3,12 @@ # ============================================== NODE_ENV=development -# API 설정 - 로컬 백엔드 직접 호출 +# 클라이언트 API URL NEXT_PUBLIC_API_URL=http://localhost:4000 +# 서버사이드 프록시용 (next.config.ts rewrites) +BACKEND_INTERNAL_URL=http://localhost:4000 + # 앱 설정 NEXT_PUBLIC_APP_NAME=한우 유전능력 시스템 NEXT_TELEMETRY_DISABLED=1 diff --git a/frontend/.env.dev b/frontend/.env.dev index 6b252db..b38b0f7 100644 --- a/frontend/.env.dev +++ b/frontend/.env.dev @@ -3,8 +3,11 @@ # ============================================== NODE_ENV=development -# API 설정 - Nginx 프록시 경유 -NEXT_PUBLIC_API_URL=http://genome2025.turbosoft.kr:4000 +# 클라이언트 API URL (브라우저에서 호출) +NEXT_PUBLIC_API_URL=/backend/api + +# 서버사이드 프록시용 (next.config.ts rewrites) +BACKEND_INTERNAL_URL=http://host.docker.internal:4000 # 앱 설정 NEXT_PUBLIC_APP_NAME=한우 유전능력 시스템 diff --git a/frontend/.env.prod b/frontend/.env.prod index 1984e6d..1451306 100644 --- a/frontend/.env.prod +++ b/frontend/.env.prod @@ -3,8 +3,11 @@ # ============================================== NODE_ENV=production -# API 설정 - Nginx 프록시 경유 -NEXT_PUBLIC_API_URL=http://genome2025.turbosoft.kr:4000 +# 클라이언트 API URL (브라우저에서 호출) +NEXT_PUBLIC_API_URL=/backend/api + +# 서버사이드 프록시용 (next.config.ts rewrites) +BACKEND_INTERNAL_URL=http://host.docker.internal:4000 # 앱 설정 NEXT_PUBLIC_APP_NAME=한우 유전능력 시스템 diff --git a/frontend/.gitignore b/frontend/.gitignore index 3b5b366..211cf54 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -9,7 +9,6 @@ !.yarn/plugins !.yarn/releases !.yarn/versions -package-lock.json # ============================================== # Build Output @@ -66,3 +65,13 @@ next-env.d.ts .temp .tmp +# ============================================== +# Environment Variables +# ============================================== +.env +.env.local +.env.prod +# .env.dev는 허용 (배포용) +!.env.dev +!.env.example + diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 3185e3c..bc8f7c2 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -11,13 +11,11 @@ COPY package*.json ./ # 의존성 설치 RUN npm install -# 소스 코드 복사 +# 소스 코드 복사 (node_modules 제외 - .dockerignore) COPY . . # 빌드 시 필요한 환경 변수 설정 ENV NEXT_TELEMETRY_DISABLED=1 -ENV NODE_ENV=production -ENV NEXT_PUBLIC_API_URL=/backend/api # Next.js 빌드 RUN npm run build diff --git a/frontend/next.config.ts b/frontend/next.config.ts index 9f2ccf9..6f4347f 100644 --- a/frontend/next.config.ts +++ b/frontend/next.config.ts @@ -1,19 +1,22 @@ import type { NextConfig } from "next"; -// Next.js 핵심 설정 파일, Next.js가 시작할 때 이 파일을 찾아서 읽음 -// 여기에 Next.js 설정 옵션을 정의할 수 있음 +// 백엔드 URL 설정 +// 로컬: http://localhost:4000 +// Docker: http://host.docker.internal:4000 +const BACKEND_URL = process.env.BACKEND_INTERNAL_URL || 'http://localhost:4000'; + const nextConfig: NextConfig = { eslint: { - ignoreDuringBuilds: true, // 빌드 시 ESLint warning 무시 + ignoreDuringBuilds: true, }, typescript: { - ignoreBuildErrors: true, // 빌드 시 TypeScript 에러 무시 (임시) + ignoreBuildErrors: true, }, async rewrites() { return [ { - source: '/backend/api/:path*', // /api가 붙은 모든 요청 - destination: 'http://192.168.11.249:4000/:path*', // 백엔드 API로 요청 + source: '/backend/api/:path*', + destination: `${BACKEND_URL}/:path*`, }, ]; }, diff --git a/frontend/next.config.ts.dev b/frontend/next.config.ts.dev deleted file mode 100644 index 9f2ccf9..0000000 --- a/frontend/next.config.ts.dev +++ /dev/null @@ -1,22 +0,0 @@ -import type { NextConfig } from "next"; - -// Next.js 핵심 설정 파일, Next.js가 시작할 때 이 파일을 찾아서 읽음 -// 여기에 Next.js 설정 옵션을 정의할 수 있음 -const nextConfig: NextConfig = { - eslint: { - ignoreDuringBuilds: true, // 빌드 시 ESLint warning 무시 - }, - typescript: { - ignoreBuildErrors: true, // 빌드 시 TypeScript 에러 무시 (임시) - }, - async rewrites() { - return [ - { - source: '/backend/api/:path*', // /api가 붙은 모든 요청 - destination: 'http://192.168.11.249:4000/:path*', // 백엔드 API로 요청 - }, - ]; - }, -}; - -export default nextConfig;