-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
chore: ec2 + docker 배포 세팅
Showing
4 changed files
with
68 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
PORT= | ||
DATABASE_URL= | ||
MONGODB_URL= | ||
REDIS_HOST= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Docker CI/CD Pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
build-and-push: | ||
name: 도커 이미지화 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: 리포지토리 코드 체크아웃 | ||
uses: actions/checkout@v3 | ||
|
||
- name: Docker Buildx 설정 | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Docker Hub 로그인 | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
|
||
- name: Docker 이미지 빌드 및 푸시 | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./ | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/nestjs-app:${{ github.sha }} | ||
|
||
deploy: | ||
name: 서버 배포 | ||
needs: build-and-push | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: 서버 배포 및 상태 확인 | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SERVER_HOST }} | ||
username: ${{ secrets.SERVER_USER }} | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
script: | | ||
cd /home/ubuntu | ||
docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/nestjs-app:latest | ||
sudo docker-compose down | ||
sudo docker-compose up -d | ||
docker image prune —f | ||
echo "=== Docker 컨테이너 상태 ===" | ||
sudo docker-compose ps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Node.js 경량 Alpine 버전 사용 | ||
FROM node:20-alpine | ||
FROM node:22-alpine | ||
|
||
# 작업 디렉토리 설정 | ||
WORKDIR /usr/src/app | ||
|
This file was deleted.
Oops, something went wrong.