-
Notifications
You must be signed in to change notification settings - Fork 30
[김선영] sprint11 #216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "\uAE40\uC120\uC601-sprint11"
[김선영] sprint11 #216
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| node_modules | ||
| npm-debug.log | ||
| build | ||
| .git | ||
| .gitignore | ||
| README.md | ||
| .env | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| name: Deploy to EC2 | ||
| on: | ||
| push: | ||
| branches: | ||
| - 김선영 # 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 김선영 | ||
| docker compose down | ||
| docker compose up -d --build | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: Test | ||
| on: | ||
| pull_request: | ||
| branches: | ||
| - 김선영 # PR 발생 시 테스트 | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| services: | ||
| postgres: | ||
| image: postgres:15 | ||
| env: | ||
| POSTGRES_USER: postgres | ||
| POSTGRES_PASSWORD: postgres | ||
| POSTGRES_DB: testdb | ||
| ports: | ||
| - 5433:5432 | ||
| options: >- | ||
| --health-cmd pg_isready | ||
| --health-interval 10s | ||
| --health-timeout 5s | ||
| --health-retries 5 | ||
| env: | ||
| DATABASE_URL: postgresql://postgres:postgres@localhost:5433/testdb | ||
| 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 |
This file was deleted.
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 단일 스테이지 빌드를 사용하고 있어서, 최종 이미지에 devDependencies(jest, ts-jest, prettier 등)와 TypeScript 소스 코드가 모두 포함돼요. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| 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 | ||
|
Comment on lines
+19
to
+20
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Volume을 미션의 요구사항을 충족하려면, 실제로 파일이 해당 경로에 저장되도록 업로드 로직을 맞춰줄 필요가 있을 거 같네요. |
||
| depends_on: | ||
| db: | ||
| condition: service_healthy | ||
|
|
||
| db: | ||
| image: postgres:15 | ||
| container_name: postgres-db | ||
| environment: | ||
| POSTGRES_USER: postgres | ||
| POSTGRES_PASSWORD: password123 | ||
| POSTGRES_DB: mission11 | ||
| ports: | ||
| - '5434:5432' | ||
| healthcheck: | ||
| test: ['CMD-SHELL', 'pg_isready -U postgres'] | ||
| interval: 5s | ||
| timeout: 5s | ||
| retries: 5 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재 구조에서는 down → up 사이에 서비스가 중단되는 시간이 발생해요.
지금 단계에서 무중단 배포까지 구현할 필요는 없지만,
docker compose down과up사이에 빌드가 포함되어 있어서 다운타임이 길어질 수 있다는 점은 인식하고 계시면 좋겠어요.docker compose up -d --build만 사용하면 새 컨테이너가 준비된 후 기존 것을 교체하는 방식으로 동작하기도 합니다.