From f893bc25ed5f799b58fe01a40291147d732f9331 Mon Sep 17 00:00:00 2001 From: Sunyoung Date: Wed, 11 Feb 2026 09:20:22 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=EB=AF=B8=EC=85=98=2010=20=EC=98=A4?= =?UTF-8?q?=ED=83=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infra/ec2/ecosystem.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/ec2/ecosystem.config.js b/infra/ec2/ecosystem.config.js index dc709bc7..142fb913 100644 --- a/infra/ec2/ecosystem.config.js +++ b/infra/ec2/ecosystem.config.js @@ -1,8 +1,8 @@ -'build/main.js',module.exports = { +module.exports = { apps: [ { name: 'sprint-mission', - script: 'build/main.js', + script: 'build/main.js', instances: 1, exec_mode: 'fork', env: { From f02b385a3b21b1ccfbdec7fd9b9b74098633cb6b Mon Sep 17 00:00:00 2001 From: Sunyoung Date: Wed, 11 Feb 2026 16:50:03 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=EB=AF=B8=EC=85=98=2011?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 8 ++++++++ .github/workflows/deploy.yml | 25 +++++++++++++++++++++++++ .github/workflows/test.yml | 36 ++++++++++++++++++++++++++++++++++++ Dockerfile | 23 +++++++++++++++++++++++ docker-compose.yml | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 124 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/test.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..a16bd769 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +node_modules +npm-debug.log +build +.git +.gitignore +README.md +.env +.DS_Store diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..f43916dc --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,25 @@ +name: Deploy to EC2 +on: + push: + branches: + - main # push 발생 시 AWS 배포 + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Deploy to EC2 via SSH + uses: appleboy/ssh-action@v0.1.6 + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USER }} + key: ${{ secrets.EC2_PRIVATE_KEY }} + port: 22 + script: | + cd /home/ec2-user/6-sprint-mission + git pull origin main + npm install + npm run build + npx prisma migrate deploy + pm2 reload all diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..b9958d80 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,36 @@ +name: Test +on: + pull_request: + branches: [main] # PR 발생 시 테스트 + +jobs: + test: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:15 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: testdb + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + DATABASE_URL: ${{ secrets.DATABASE_URL }} + JWT_ACCESS_TOKEN_SECRET: ${{ secrets.JWT_ACCESS_TOKEN_SECRET }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '24.13.0' + - run: npm ci + - run: npx prisma migrate deploy + - name: Type Check + run: npm run typecheck + - name: Run Tests + run: npm run test diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..3813c95b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# 베이스 이미지 +ARG NODE_VERSION=24.13.0 +FROM node:${NODE_VERSION} + +# 환경 변수 선언: express 서버를 실행할 포트 +ENV SERVER_PORT=3000 + +# 이미지 빌드 간 현재 디렉토리 설정: 프로젝트 루트 디렉토리 +WORKDIR /app + +# 4. 패키지 설치 +COPY package*.json ./ +RUN npm ci + +# 5. 소스 코드 복사 +COPY . . + +# 6. Prisma 및 빌드 +RUN npx prisma generate +RUN npm run build + +# 컨테이너가 켜질 때 DB 테이블부터 만들고 서버 실행 +ENTRYPOINT ["sh", "-c", "npx prisma migrate deploy && npm run start"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..139b7d52 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,32 @@ +name: sprint-mission-11 +services: + server: + build: + context: . + dockerfile: Dockerfile + ports: + - '3000:3000' + environment: + DATABASE_URL: 'postgresql://postgres:password123@db:5432/mission11' + JWT_ACCESS_TOKEN_SECRET: ${JWT_ACCESS_TOKEN_SECRET} + JWT_REFRESH_TOKEN_SECRET: ${JWT_REFRESH_TOKEN_SECRET} + ACCESS_TOKEN_COOKIE_NAME: ${ACCESS_TOKEN_COOKIE_NAME} + REFRESH_TOKEN_COOKIE_NAME: ${REFRESH_TOKEN_COOKIE_NAME} + S3_BUCKET_NAME: ${S3_BUCKET_NAME} + S3_REGION: ${S3_REGION} + S3_ACCESS_KEY: ${S3_ACCESS_KEY} + S3_SECRET_KEY: ${S3_SECRET_KEY} + volumes: + - ./uploads:/app/uploads:rw + depends_on: + - db + + db: + image: postgres:15 + container_name: postgres-db + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password123 + POSTGRES_DB: mission11 + ports: + - '5434:5432' From 104e6db863f1b849c3155672b91debd86893bf81 Mon Sep 17 00:00:00 2001 From: Sunyoung Date: Wed, 11 Feb 2026 17:13:52 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=EB=AF=B8=EC=85=98=2011=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 10 ++++------ .github/workflows/test.yml | 5 +++-- docker-compose.yml | 8 +++++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f43916dc..6ca5ebb3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,7 @@ name: Deploy to EC2 on: push: branches: - - main # push 발생 시 AWS 배포 + - 김선영 # push 발생 시 AWS 배포 jobs: deploy: @@ -18,8 +18,6 @@ jobs: port: 22 script: | cd /home/ec2-user/6-sprint-mission - git pull origin main - npm install - npm run build - npx prisma migrate deploy - pm2 reload all + git pull origin 김선영 + docker compose down + docker compose up -d --build diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b9958d80..5921a49d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,8 @@ name: Test on: pull_request: - branches: [main] # PR 발생 시 테스트 + branches: + - 김선영 # PR 발생 시 테스트 jobs: test: @@ -14,7 +15,7 @@ jobs: POSTGRES_PASSWORD: postgres POSTGRES_DB: testdb ports: - - 5432:5432 + - 5433:5432 options: >- --health-cmd pg_isready --health-interval 10s diff --git a/docker-compose.yml b/docker-compose.yml index 139b7d52..49ec255d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,8 @@ services: volumes: - ./uploads:/app/uploads:rw depends_on: - - db + db: + condition: service_healthy db: image: postgres:15 @@ -30,3 +31,8 @@ services: POSTGRES_DB: mission11 ports: - '5434:5432' + healthcheck: + test: ['CMD-SHELL', 'pg_isready -U postgres'] + interval: 5s + timeout: 5s + retries: 5 From 1163567a7f9b9cc6e4b963c00e68eaa61ef4afa6 Mon Sep 17 00:00:00 2001 From: Sunyoung Date: Wed, 11 Feb 2026 17:19:07 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=ED=99=98=EA=B2=BD=20=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5921a49d..4c621e6c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: --health-timeout 5s --health-retries 5 env: - DATABASE_URL: ${{ secrets.DATABASE_URL }} + DATABASE_URL: postgresql://postgres:postgres@localhost:5433/testdb JWT_ACCESS_TOKEN_SECRET: ${{ secrets.JWT_ACCESS_TOKEN_SECRET }} steps: - uses: actions/checkout@v3 From 6280093d9fdddbb77376edd26584e93b7d1f23e0 Mon Sep 17 00:00:00 2001 From: Sunyoung Date: Wed, 11 Feb 2026 17:23:48 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=EB=AF=B8=EC=85=98=2011=20=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EB=AC=B8=EC=A0=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f6956ad8..da2abe29 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "start": "node ./build/main.js", "build": "tsc", "dev": "nodemon ./src/main.ts --watch ./src", - "test": "dotenv -e .env.test -- prisma migrate dev && dotenv -e .env.test -- jest -i --coverage" + "typecheck": "tsc --noEmit", + "test": "jest -i --coverage" }, "devDependencies": { "@types/bcrypt": "^5.0.2", From 383121702b8a5cad3cf1b77e3ed343aa4548474d Mon Sep 17 00:00:00 2001 From: Sunyoung Date: Wed, 11 Feb 2026 17:32:27 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=EB=AA=85=20=EB=8C=80?= =?UTF-8?q?=EC=86=8C=EB=AC=B8=EC=9E=90=20=EC=9D=B8=EC=8B=9D=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 --- src/types/{notification.ts => Notification.ts} | 0 2 files changed, 3 deletions(-) delete mode 100644 .vscode/settings.json rename src/types/{notification.ts => Notification.ts} (100%) diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 97f0e81d..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "prisma.pinToPrisma6": true -} diff --git a/src/types/notification.ts b/src/types/Notification.ts similarity index 100% rename from src/types/notification.ts rename to src/types/Notification.ts