Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@
NEXT_PUBLIC_CURRENT_TERM=2025-2

# Shared configuration across all environments
# Environment-specific values should be set in Vercel dashboard or .env.production
# Environment-specific values are in .env.development, .env.preview, .env.production

# Login mode configuration
# true: HTTP-only 쿠키 + Zustand (보안 강화)
# false: 로컬스토리지 + Zustand (개발/테스트 편의)
NEXT_PUBLIC_COOKIE_LOGIN_ENABLED=true

# Stage API (default for PR/Preview and main branch)
# Production API is configured via Vercel CLI in release workflow
NEXT_PUBLIC_WEB_URL=https://www.stage.solid-connection.com
NEXT_PUBLIC_API_SERVER_URL=https://api.stage.solid-connection.com
NEXT_PUBLIC_KAKAO_JS_KEY=c080f1d215a69b47401cda1d7528418a

NEXT_PUBLIC_IMAGE_URL=https://d1q5o8tzvz4j3d.cloudfront.net
NEXT_PUBLIC_UPLOADED_IMAGE_URL=https://d23lwokhcc3r0c.cloudfront.net

Expand Down
14 changes: 14 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
SENTRY_ENVIRONMENT=development

# web page
NEXT_PUBLIC_WEB_URL=http://localhost:3000

# api server
NEXT_PUBLIC_API_SERVER_URL=https://api.stage.solid-connection.com

# kakao
NEXT_PUBLIC_KAKAO_JS_KEY=c080f1d215a69b47401cda1d7528418a

# Login mode configuration for development
# 개발 환경에서는 로컬스토리지 모드 사용 (디버깅 편의)
NEXT_PUBLIC_COOKIE_LOGIN_ENABLED=false
61 changes: 35 additions & 26 deletions .env.guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,60 @@
## Structure

### `.env`
- **용도**: 모든 환경의 기본값 (stage API)
- **용도**: 모든 환경의 공통 설정
- **커밋**: ✅ Git에 포함
- **사용**: PR, Preview, main 브랜치 배포
- **내용**: 공통 값만 (CURRENT_TERM, IMAGE_URL, GOOGLE_MAPS_KEY 등)

### `.env.development`
- **용도**: 로컬 개발 환경 (`npm run dev`)
- **커밋**: ✅ Git에 포함
- **내용**: localhost:3000, stage API, 로컬스토리지 로그인

### `.env.preview`
- **용도**: Vercel Preview 배포 (PR)
- **커밋**: ✅ Git에 포함
- **내용**: stage 도메인, stage API, 쿠키 로그인

### `.env.production`
- **용도**: Production API (릴리즈 전용)
- **용도**: Production 배포
- **커밋**: ✅ Git에 포함
- **사용**: 수동 릴리즈 워크플로우에서만 사용
- **내용**: production 도메인, production API, 쿠키 로그인

### `.env.local` (권장)
- **용도**: 로컬 개발 환경별 설정
- **용도**: 개발자별 로컬 설정
- **커밋**: ❌ Git에서 제외 (.gitignore)
- **사용**: 개발자별 로컬 설정 (포트, 로컬 API 등)
- **내용**: 로컬 API 서버, 개인 테스트 키 등

## Deployment Flow

### 1. PR/Preview (자동)
- Vercel Integration 사용
- `.env` 기본값 사용 (stage API)
### 1. 로컬 개발 (`npm run dev`)
- `.env.development` 사용
- localhost:3000, stage API

### 2. PR/Preview (Vercel Integration)
- `.env.preview` 사용
- stage 도메인, stage API

### 2. Main 브랜치 머지 (자동)
- Vercel Integration 사용
- `.env` 기본값 사용 (stage API)
### 3. Main 브랜치 머지 (Vercel Integration)
- `.env.production` 사용
- production 도메인, production API

### 3. 릴리즈 (수동)
- GitHub Actions의 release.yml 워크플로우
- `--build-env` 플래그로 production API 주입
- `.env.production`의 값들을 명시적으로 주입
### 4. 수동 릴리즈 (release.yml)
- `--build-env` 플래그로 production API 명시적 주입
- GitHub Release 태그 생성

## Best Practices

1. **민감 정보는 환경 변수에 넣지 않기**
- `NEXT_PUBLIC_*` 접두사는 클라이언트에 노출됨
- API 키 등은 서버 사이드에서만 사용
1. **환경별 파일 분리**
- 각 환경의 설정을 명확히 분리
- 공통 설정은 `.env`에만

2. **로컬 개발 시 `.env.local` 사용**
2. **로컬 개발 시 `.env.local` 활용**
```bash
# .env.local (gitignore됨)
NEXT_PUBLIC_WEB_URL=http://localhost:3000
NEXT_PUBLIC_API_SERVER_URL=http://localhost:8080
```

3. **환경별 우선순위 이해**
- Vercel CLI `--build-env` > `.env.production` > `.env.local` > `.env`

4. **Vercel 대시보드 환경 변수는 사용하지 않음**
- 파일 기반 관리로 투명성 확보
- release.yml의 `--build-env`로 production 값 명시적 주입
- `.env.[mode].local` > `.env.[mode]` > `.env.local` > `.env`
- Vercel CLI `--build-env`는 모든 파일보다 우선
14 changes: 14 additions & 0 deletions .env.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
SENTRY_ENVIRONMENT=preview

# web page
NEXT_PUBLIC_WEB_URL=https://www.stage.solid-connection.com

# api server
NEXT_PUBLIC_API_SERVER_URL=https://api.stage.solid-connection.com

# kakao
NEXT_PUBLIC_KAKAO_JS_KEY=c080f1d215a69b47401cda1d7528418a

# Login mode configuration for preview
# Preview 환경에서는 stage API와 쿠키 로그인 사용
NEXT_PUBLIC_COOKIE_LOGIN_ENABLED=true
67 changes: 0 additions & 67 deletions .github/workflows/build.yml

This file was deleted.