From 45bdedf8075b6ec973d4c2e25edf723aa73cf791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EB=8C=80=EC=9A=A9?= Date: Wed, 11 Feb 2026 13:21:43 +0900 Subject: [PATCH 1/9] feat: complete sprint10 mission --- .dockerignore | 8 +++++++ .github/workflows/deploy-main.yml | 27 ++++++++++++++++++++++ .github/workflows/pr-test.yml | 24 +++++++++++++++++++ Dockerfile | 19 ++++++++++++++++ docker-compose.yml | 38 +++++++++++++++++++++++++++++++ package.json | 1 + 6 files changed, 117 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/deploy-main.yml create mode 100644 .github/workflows/pr-test.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..49016f437 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +node_modules +dist +.git +.github +infra +temp +npm-debug.log +.DS_Store diff --git a/.github/workflows/deploy-main.yml b/.github/workflows/deploy-main.yml new file mode 100644 index 000000000..244c7c61e --- /dev/null +++ b/.github/workflows/deploy-main.yml @@ -0,0 +1,27 @@ +name: Deploy To AWS + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Deploy via SSH + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USERNAME }} + key: ${{ secrets.EC2_SSH_KEY }} + port: ${{ secrets.EC2_PORT || 22 }} + script: | + set -e + cd ${{ secrets.EC2_PROJECT_PATH }} + git fetch origin + git checkout main + git pull origin main + docker compose down + docker compose up -d --build diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml new file mode 100644 index 000000000..cb0921a31 --- /dev/null +++ b/.github/workflows/pr-test.yml @@ -0,0 +1,24 @@ +name: PR Test + +on: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm test diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..beb4e9ea0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:22-alpine + +WORKDIR /app + +COPY package*.json ./ +RUN npm ci + +COPY prisma ./prisma +RUN npx prisma generate + +COPY tsconfig.json ./ +COPY src ./src +RUN npm run build + +RUN mkdir -p public + +EXPOSE 3000 + +CMD ["sh", "-c", "npx prisma migrate deploy && node dist/main.js"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..98c9f4424 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,38 @@ +services: + db: + image: postgres:16-alpine + container_name: sprint11-db + restart: always + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: pandamarket + ports: + - "5432:5432" + volumes: + - postgres-data:/var/lib/postgresql/data + + app: + build: + context: . + dockerfile: Dockerfile + container_name: sprint11-app + restart: always + depends_on: + - db + environment: + NODE_ENV: production + PORT: 3000 + DATABASE_URL: postgresql://postgres:postgres@db:5432/pandamarket?schema=public + JWT_ACCESS_TOKEN_SECRET: change-me-access-secret + JWT_REFRESH_TOKEN_SECRET: change-me-refresh-secret + JWT_ACCESS_EXPIRES_IN: 1h + JWT_REFRESH_EXPIRES_IN: 14d + ports: + - "3000:3000" + volumes: + - uploads:/app/public + +volumes: + postgres-data: + uploads: diff --git a/package.json b/package.json index 494e436c3..884deb69c 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "scripts": { "start": "node ./dist/main.js", "build": "tsc", + "test": "npm run build", "dev": "tsx src/main.ts", "dev:watch": "tsx watch src/main.ts" }, From e264818ae82c15463baef131b0d1339a77deba9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EB=8C=80=EC=9A=A9?= Date: Wed, 11 Feb 2026 14:08:16 +0900 Subject: [PATCH 2/9] =?UTF-8?q?fix:=20gitignore=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr-test.yml | 32 ++++++++++++++++++++++++++++++++ .gitignore | 2 ++ 2 files changed, 34 insertions(+) diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index cb0921a31..43eb45b48 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -7,6 +7,29 @@ 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 + POSTGRES_URL: postgresql://ci_user:ci_password@localhost:5432/ci_test_db + JWT_ACCESS_TOKEN_SECRET: test_secret_key + JWT_REFRESH_TOKEN_SECRET: test_secret_key + steps: - name: Checkout uses: actions/checkout@v4 @@ -20,5 +43,14 @@ jobs: - name: Install dependencies run: npm ci + - name: Generate Prisma Client + run: npx prisma generate + + - name: Apply database migrations + run: npx prisma migrate deploy + + - name: build + run: npm run build + - name: Run tests run: npm test diff --git a/.gitignore b/.gitignore index ba541ece7..39d817b20 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,8 @@ yarn-debug.log* yarn-error.log* lerna-debug.log* .pnpm-debug.log* +.vscode + # Node 진단 리포트 (node --report-on-fatalerror) report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json From 78b0b7af98709893cec9ba41951460a82b71eb45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EB=8C=80=EC=9A=A9?= Date: Wed, 11 Feb 2026 15:13:52 +0900 Subject: [PATCH 3/9] =?UTF-8?q?fix:=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 16 +--------------- prisma/schema.prisma | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 39d817b20..834158612 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ yarn-debug.log* yarn-error.log* lerna-debug.log* .pnpm-debug.log* -.vscode + # Node 진단 리포트 (node --report-on-fatalerror) @@ -125,20 +125,6 @@ dist # 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 diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 4a8400b30..9c9db7334 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -55,18 +55,18 @@ model Comment { } model User { - id Int @id @default(autoincrement()) - email String @unique - nickname String - image String? - password String - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - articles Article[] - products Product[] - comments Comment[] - favorites Favorite[] - likes Like[] + id Int @id @default(autoincrement()) + email String @unique + nickname String + image String? + password String + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + articles Article[] + products Product[] + comments Comment[] + favorites Favorite[] + likes Like[] notifications Notification[] } From d56c3ce9ae78c0111d084d87042c2dbf6e6e8e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EB=8C=80=EC=9A=A9?= Date: Wed, 11 Feb 2026 15:17:56 +0900 Subject: [PATCH 4/9] =?UTF-8?q?=EC=98=A4=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 --- .github/workflows/pr-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 43eb45b48..aee0970e7 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -26,7 +26,7 @@ jobs: POSTGRES_USER: ci_user POSTGRES_PASSWORD: ci_password POSTGRES_DB: ci_test_db - POSTGRES_URL: postgresql://ci_user:ci_password@localhost:5432/ci_test_db + DATABASE_URL: postgresql://ci_user:ci_password@localhost:5432/ci_test_db JWT_ACCESS_TOKEN_SECRET: test_secret_key JWT_REFRESH_TOKEN_SECRET: test_secret_key From 21a8c9ae3d7bd82d2fb20fc5536b4101404f9cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EB=8C=80=EC=9A=A9?= Date: Wed, 11 Feb 2026 15:29:51 +0900 Subject: [PATCH 5/9] =?UTF-8?q?=E3=85=87=E3=85=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-main.yml | 25 ++++++++++++++++---- docker-compose.yaml | 38 +++++++++++++++++++++++++++++++ docker-compose.yml | 6 ++--- 3 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 docker-compose.yaml diff --git a/.github/workflows/deploy-main.yml b/.github/workflows/deploy-main.yml index 244c7c61e..6c0b396ac 100644 --- a/.github/workflows/deploy-main.yml +++ b/.github/workflows/deploy-main.yml @@ -12,16 +12,31 @@ jobs: steps: - name: Deploy via SSH uses: appleboy/ssh-action@v1.2.0 + env: + DATABASE_URL: ${{ secrets.DATABASE_URL }} + JWT_ACCESS_TOKEN_SECRET: ${{ secrets.JWT_ACCESS_TOKEN_SECRET }} + JWT_REFRESH_TOKEN_SECRET: ${{ secrets.JWT_REFRESH_TOKEN_SECRET }} with: host: ${{ secrets.EC2_HOST }} - username: ${{ secrets.EC2_USERNAME }} - key: ${{ secrets.EC2_SSH_KEY }} + username: ${{ secrets.EC2_USER }} + key: ${{ secrets.EC2_PRIVATE_KEY }} port: ${{ secrets.EC2_PORT || 22 }} + envs: DATABASE_URL,JWT_ACCESS_TOKEN_SECRET,JWT_REFRESH_TOKEN_SECRET script: | set -e - cd ${{ secrets.EC2_PROJECT_PATH }} + PROJECT_PATH="${{ secrets.EC2_PROJECT_PATH }}" + if [ -z "$PROJECT_PATH" ]; then + PROJECT_PATH="$HOME/6-sprint-mission" + fi + cd "$PROJECT_PATH" git fetch origin git checkout main git pull origin main - docker compose down - docker compose up -d --build + DATABASE_URL="$DATABASE_URL" \ + JWT_ACCESS_TOKEN_SECRET="${JWT_ACCESS_TOKEN_SECRET:-change-me-access-secret}" \ + JWT_REFRESH_TOKEN_SECRET="${JWT_REFRESH_TOKEN_SECRET:-change-me-refresh-secret}" \ + docker compose -f docker-compose.yml down + DATABASE_URL="$DATABASE_URL" \ + JWT_ACCESS_TOKEN_SECRET="${JWT_ACCESS_TOKEN_SECRET:-change-me-access-secret}" \ + JWT_REFRESH_TOKEN_SECRET="${JWT_REFRESH_TOKEN_SECRET:-change-me-refresh-secret}" \ + docker compose -f docker-compose.yml up -d --build diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 000000000..c71b3059b --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,38 @@ +services: + db: + image: postgres:16-alpine + container_name: sprint11-db + restart: always + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: pandamarket + ports: + - "5432:5432" + volumes: + - postgres-data:/var/lib/postgresql/data + + app: + build: + context: . + dockerfile: Dockerfile + container_name: sprint11-app + restart: always + depends_on: + - db + environment: + NODE_ENV: production + PORT: 3000 + DATABASE_URL: ${DATABASE_URL:-postgresql://postgres:postgres@db:5432/pandamarket?schema=public} + JWT_ACCESS_TOKEN_SECRET: ${JWT_ACCESS_TOKEN_SECRET:-change-me-access-secret} + JWT_REFRESH_TOKEN_SECRET: ${JWT_REFRESH_TOKEN_SECRET:-change-me-refresh-secret} + JWT_ACCESS_EXPIRES_IN: 1h + JWT_REFRESH_EXPIRES_IN: 14d + ports: + - "3000:3000" + volumes: + - uploads:/app/public + +volumes: + postgres-data: + uploads: diff --git a/docker-compose.yml b/docker-compose.yml index 98c9f4424..c71b3059b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,9 +23,9 @@ services: environment: NODE_ENV: production PORT: 3000 - DATABASE_URL: postgresql://postgres:postgres@db:5432/pandamarket?schema=public - JWT_ACCESS_TOKEN_SECRET: change-me-access-secret - JWT_REFRESH_TOKEN_SECRET: change-me-refresh-secret + DATABASE_URL: ${DATABASE_URL:-postgresql://postgres:postgres@db:5432/pandamarket?schema=public} + JWT_ACCESS_TOKEN_SECRET: ${JWT_ACCESS_TOKEN_SECRET:-change-me-access-secret} + JWT_REFRESH_TOKEN_SECRET: ${JWT_REFRESH_TOKEN_SECRET:-change-me-refresh-secret} JWT_ACCESS_EXPIRES_IN: 1h JWT_REFRESH_EXPIRES_IN: 14d ports: From 8ec8db27d14fc9470c0be41d908cf7ed3bf9157a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EB=8C=80=EC=9A=A9?= Date: Wed, 11 Feb 2026 16:18:12 +0900 Subject: [PATCH 6/9] =?UTF-8?q?=EB=8F=84=EC=BB=A4=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index beb4e9ea0..6dcf060ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:22-alpine +FROM node:22-bookworm-slim WORKDIR /app From 75274536a7c1a7ceb27c99479d310a6c47186dfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EB=8C=80=EC=9A=A9?= Date: Wed, 11 Feb 2026 16:36:08 +0900 Subject: [PATCH 7/9] fix: install openssl in docker image for prisma --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index 6dcf060ef..8f888683c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,10 @@ FROM node:22-bookworm-slim WORKDIR /app +RUN apt-get update \ + && apt-get install -y --no-install-recommends openssl ca-certificates \ + && rm -rf /var/lib/apt/lists/* + COPY package*.json ./ RUN npm ci From dd90f5c47e20a85535359c34d6662b7f3ce82de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EB=8C=80=EC=9A=A9?= Date: Fri, 20 Feb 2026 13:29:48 +0900 Subject: [PATCH 8/9] fix: align docker runtime for prisma openssl compatibility --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8f888683c..76441ceb0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:22-bookworm-slim +FROM node:20-bullseye-slim WORKDIR /app From de1927b4c20764fd3d57517e6f31d8d7228db3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EB=8C=80=EC=9A=A9?= Date: Fri, 20 Feb 2026 14:07:35 +0900 Subject: [PATCH 9/9] revert: rollback assistant docker runtime changes --- Dockerfile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 76441ceb0..6dcf060ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,7 @@ -FROM node:20-bullseye-slim +FROM node:22-bookworm-slim WORKDIR /app -RUN apt-get update \ - && apt-get install -y --no-install-recommends openssl ca-certificates \ - && rm -rf /var/lib/apt/lists/* - COPY package*.json ./ RUN npm ci