Skip to content
Open
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
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
dist
.git
.github
coverage
temp
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.env
**/.env
61 changes: 61 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# TODO) ENV-Sample: 참고 용도로 건들 필요 없음
# [필수] DATABASE_URL
# PostgreSQL 형식: postgresql://USER:PASSWORD@HOST:PORT/DATABASE
DATABASE_URL="postgresql://user:password@localhost:5432/<디비제목>"

# 서버 포트
PORT=3000

# 실행 환경 (development, production, test)
NODE_ENV=development

# [선택] 디버그 (true/false)
DEBUG_MODE=true

# [선택] 로그 레벨 (개발에서 디버그까지 보고 싶을 때)
LOG_LEVEL=debug

# 베이스 URL (images)
BASE_URL=http://localhost:3000

# Socket.IO CORS 허용 도메인 목록 (쉼표로 구분)
# 예: http://localhost:5173,https://your-frontend.com
SOCKET_CORS_ORIGINS=

### Session ###
# 세션 스토어 전용 (DB명 반드시 포함, ?schema 제거)
SESSION_STORE_URL="postgresql://user:password@localhost:5432/<디비제목>"

# 세션 비밀키 (실제 서비스 시 랜덤 문자열 추천)
SESSION_SECRET=

### JWT ###
# 해쉬 강도 (보통 10~12 추천)
SALT_ROUNDS=

# 토큰 비밀키 (실제 서비스 시 랜덤 문자열 추천)
JWT_ACCESS_SECRET=
JWT_REFRESH_SECRET=

# 토큰 유효기간
# 분 단위 추천 예: 15m
JWT_ACCESS_EXPIRES=
# 일 단위 추천 예: 7d
JWT_REFRESH_EXPIRES=

### Google OAuth 2.0 ###
# Google에서 발급한 Client ID
# OAuth 로그인 시작할 때 구글에 알려주는 "우리 앱의 ID"
GOOGLE_CLIENT_ID=

# Google Client Secret
# Google에게 토큰 받기 위해 필요한 비밀키 (절대 공개 금지!)
GOOGLE_CLIENT_SECRET=

### 추가 설명 ###
# 1) Google OAuth는 Redirect URI 반드시 일치해야 함
# 예: http://localhost:3000/auth/google/callback
# Google Cloud Console → Authorized Redirect URIs에 등록 필수
#
# 2) JWT Secret은 실제 서비스에서는 더 긴 랜덤 문자열 사용
# 예: openssl rand -base64 32
47 changes: 47 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CD

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Deploy to EC2
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
port: 22
command_timeout: 30m
script: |
set -e
cd /home/ec2-user/sprint-5/6-sprint-mission-copy
export GIT_TERMINAL_PROMPT=0

# Prefer GitHub secret, fallback to EC2 .env.
if [ -n "${{ secrets.DATABASE_URL }}" ]; then
export DATABASE_URL='${{ secrets.DATABASE_URL }}'
fi

if [ -z "${DATABASE_URL:-}" ] && [ -f .env ]; then
set -a
. ./.env
set +a
fi

if [ -z "${DATABASE_URL:-}" ]; then
echo "DATABASE_URL is empty. Set GitHub secret DATABASE_URL or configure EC2 .env."
exit 1
fi

git pull --ff-only origin main
npm ci
npx prisma generate
npx prisma migrate deploy
npm run build
pm2 reload infra/ec2/ecosystem.config.cjs --update-env || pm2 start infra/ec2/ecosystem.config.cjs
58 changes: 58 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI

on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:16
ports:
- 5432:5432
env:
POSTGRES_USER: ci_user
POSTGRES_PASSWORD: ci_password
POSTGRES_DB: ci_test_db
options: >-
--health-cmd "pg_isready -U ci_user -d ci_test_db"
--health-interval 10s
--health-timeout 5s
--health-retries 5

env:
POSTGRES_USER: ci_user
POSTGRES_PASSWORD: ci_password
POSTGRES_DB: ci_test_db
DATABASE_URL: postgresql://ci_user:ci_password@localhost:5432/ci_test_db
JWT_ACCESS_SECRET: test-access-secret
JWT_REFRESH_SECRET: test-refresh-secret
DEBUG_MODE: "false"
LOG_LEVEL: error

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- name: Install dependencies
run: npm ci

- name: Generate Prisma Client
run: npx prisma generate

- name: Apply migrations
run: npx prisma migrate deploy

- name: Build
run: npm run build

- name: Test
run: npm test
158 changes: 158 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# TODO) Git-Ignore: 노드 기반 프로젝트 공통 무시 규칙
# =====================================================================
# Node.js 개발환경에서 자동 생성되거나, 필요 없는 파일들 제외
# 팀 개발 시 불필요한 파일이 Git에 올라가는 것을 방지하기 위한 설정
# =====================================================================

### Node 기본 ###
# 로그 파일 (서버 실행 중 생기는 log들은 커밋할 필요 없음)
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Node 진단 리포트 (node --report-on-fatalerror)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# 실행 중 생성되는 pid 파일
pids
*.pid
*.seed
*.pid.lock

# jscoverage/JSCover 결과물
lib-cov

# 테스트 커버리지 디렉토리
coverage
*.lcov

# nyc 테스트 커버리지 출력
.nyc_output

# Grunt 내부 저장소
.grunt

# Bower 패키지 디렉토리
bower_components

# node-waf 설정 파일
.lock-wscript

# Node 애드온 빌드 파일
build/Release

# 의존성 패키지 디렉토리
node_modules/
jspm_packages/

# Snowpack 의존성
web_modules/

# TypeScript 캐시
*.tsbuildinfo

# npm 캐시(선택)
.npm

# ESLint 캐시
.eslintcache

# stylelint 캐시
.stylelintcache

# Microbundle 캐시
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Node REPL 히스토리
.node_repl_history

# npm pack 생성 파일
*.tgz

# Yarn 무결성 파일
.yarn-integrity

### 환경 변수 ###
# 중요: 비밀키가 포함된 env 파일은 절대 Git에 올리지 않음
.env
**/.env
.env.development.local
.env.test.local
.env.production.local
.env.local

### 웹 번들러 / 프레임워크 ###
# Parcel
.cache
.parcel-cache

# Next.js 빌드 결과물
.next
out

# Nuxt.js 빌드 결과물
.nuxt
dist

# Gatsby 캐시
.cache/

# VuePress 빌드 결과물
.vuepress/dist
.temp

# Docusaurus 캐시
.docusaurus

# Serverless 빌드 출력을 제외
.serverless/

# FuseBox 캐시
.fusebox/

# DynamoDB Local
.dynamodb/

# TernJS 포트 파일
.tern-port

### VSCode 관련 ###
# 개인 개발환경 설정 제외 (필요한 일부만 허용)
.vscode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# VSCode Local History
.history/
*.vsix

# Ionide (F# 관련)
.ionide

### Yarn v2 ###
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

### SvelteKit ###
.svelte-kit

### Webpack ###
.webpack/

### 개인 작업 디렉토리 ###
# temp 폴더는 개인 테스트용이므로 Git에 올리지 않음
temp/
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5"
}
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:22-alpine

WORKDIR /app

COPY package.json package-lock.json ./
RUN npm ci

COPY prisma ./prisma
RUN npx prisma generate

COPY tsconfig.json ./
COPY src ./src
COPY public ./public

RUN npm run build

RUN mkdir -p /app/public/uploads

EXPOSE 3000

CMD ["sh", "-c", "npx prisma migrate deploy && node dist/app.js"]
Loading
Loading