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
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules
dist
uploads
.git
.env
*.jpg
*.png
infra
client-demo
__tests__
.devcontainer
generated
46 changes: 46 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI - Test

on:
pull_request:
branches: ["*"]

jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: panda
POSTGRES_PASSWORD: panda1234
POSTGRES_DB: panda_market_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U panda -d panda_market_test"
--health-interval 5s
--health-timeout 3s
--health-retries 5

env:
DATABASE_URL: postgresql://panda:panda1234@localhost:5432/panda_market_test
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

하드코딩 되어 있는 것중 민감한 정보는 따로 .env로 빼는것을 추천드립니다.

JWT_ACCESS_SECRET: test-access-secret
JWT_REFRESH_SECRET: test-refresh-secret
NODE_ENV: test

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- run: npm ci

- run: npx prisma generate

- run: npx prisma migrate deploy

- run: npm run build
39 changes: 39 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CD - Deploy to AWS

on:
push:
branches: [main]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- run: npm ci

- run: npx prisma generate

- run: npm run build

- name: Deploy to EC2
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd ~/sprint-mission-
git pull origin main
npm ci
npx prisma generate
npx prisma migrate deploy
npm run build
pm2 restart pandamarket-api || pm2 start npm --name pandamarket-api -- run start
pm2 save
116 changes: 0 additions & 116 deletions ArticleService.js

This file was deleted.

20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:20-alpine
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추후 멀티 스테이지 적용을 해보시는 걸 추천드립니다.
싱글 스테이지와 차이점을 확인하고 왜 멀티 스테이지를 구성해야 하는지 아는 것이 중요합니다.


WORKDIR /app

COPY package.json package-lock.json ./

RUN npm ci

COPY prisma ./prisma
RUN npx prisma generate

COPY . .

RUN npm run build

RUN mkdir -p /app/uploads

EXPOSE 3000

CMD ["sh", "-c", "npx prisma migrate deploy && node dist/src/server.js"]
48 changes: 0 additions & 48 deletions ProductService.js

This file was deleted.

33 changes: 0 additions & 33 deletions app.js

This file was deleted.

39 changes: 39 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
services:
app:
build: .
ports:
- "3000:3000"
environment:
DATABASE_URL: postgresql://panda:panda1234@db:5432/panda_market
JWT_ACCESS_SECRET: docker-access-secret
JWT_REFRESH_SECRET: docker-refresh-secret
JWT_ACCESS_EXPIRES_IN: 15m
JWT_REFRESH_EXPIRES_IN: 7d
PORT: "3000"
CORS_ORIGIN: http://localhost:3001
NODE_ENV: production
volumes:
- uploads:/app/uploads
depends_on:
db:
condition: service_healthy

db:
image: postgres:16-alpine
environment:
POSTGRES_USER: panda
POSTGRES_PASSWORD: panda1234
POSTGRES_DB: panda_market
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U panda -d panda_market"]
interval: 5s
timeout: 3s
retries: 5

volumes:
uploads:
pgdata:
Loading
Loading