-
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.
Merge pull request #194 from boostcampwm-2024/dev
Dev
- Loading branch information
Showing
312 changed files
with
16,875 additions
and
824 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,180 @@ | ||
name: Build and Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
- dev-be | ||
jobs: | ||
build_and_deploy: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- server: main | ||
host: ${{ vars.SSH_HOST }} | ||
type: full | ||
# - server: loadbalancer | ||
# host: ${{ vars.LOAD_SSH_HOST }} | ||
# type: api | ||
# - server: loadbalancer2 | ||
# host: ${{ vars.LOAD_SSH_HOST_2 }} | ||
# type: api2 | ||
# - server: loadbalancer3 | ||
# host: ${{ vars.LOAD_SSH_HOST_3 }} | ||
# type: api3 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Docker Hub login | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Build and Push Docker images | ||
run: | | ||
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/corinee-server -f ./dockerfile-server . | ||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/corinee-server | ||
if [ "${{ matrix.type }}" = "full" ]; then | ||
docker build --build-arg VITE_API_BASE_URL=${{ secrets.VITE_API_BASE_URL }} -t ${{ secrets.DOCKERHUB_USERNAME }}/corinee-client -f ./dockerfile-client . | ||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/corinee-client | ||
fi | ||
- name: Make main server environment | ||
if: matrix.type == 'full' | ||
run: | | ||
echo "${{ secrets.DEPLOY_ENV }}" > .env | ||
- name: Make loadbalancer environment | ||
if: matrix.type != 'full' | ||
run: | | ||
echo "${{ secrets.LOAD_DEPLOY_ENV }}" > .env | ||
- name: Send files & deploy script | ||
if: matrix.type == 'full' | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
password: ${{ secrets.SSH_PASSWORD }} | ||
port: ${{ secrets.SSH_PORT }} | ||
source: "docker-compose.yml,nginx.conf,.env" | ||
target: /corinee | ||
overwrite: true | ||
|
||
# - name: Send files to loadbalancer | ||
# if: matrix.type == 'api' | ||
# uses: appleboy/scp-action@master | ||
# with: | ||
# host: ${{ secrets.LOAD_SSH_HOST }} | ||
# username: ${{ secrets.SSH_USERNAME }} | ||
# password: ${{ secrets.LOAD_SSH_PASSWORD }} | ||
# port: ${{ secrets.SSH_PORT }} | ||
# source: "docker-compose.server.yml,.env" | ||
# target: /corinee | ||
# overwrite: true | ||
|
||
# - name: Send files to loadbalancer | ||
# if: matrix.type == 'api2' | ||
# uses: appleboy/scp-action@master | ||
# with: | ||
# host: ${{ secrets.LOAD_SSH_HOST_2 }} | ||
# username: ${{ secrets.SSH_USERNAME }} | ||
# password: ${{ secrets.LOAD_SSH_PASSWORD_2 }} | ||
# port: ${{ secrets.SSH_PORT }} | ||
# source: "docker-compose.server.yml,.env" | ||
# target: /corinee | ||
# overwrite: true | ||
|
||
# - name: Send files to loadbalancer | ||
# if: matrix.type == 'api3' | ||
# uses: appleboy/scp-action@master | ||
# with: | ||
# host: ${{ secrets.LOAD_SSH_HOST_3 }} | ||
# username: ${{ secrets.SSH_USERNAME }} | ||
# password: ${{ secrets.LOAD_SSH_PASSWORD_3 }} | ||
# port: ${{ secrets.SSH_PORT }} | ||
# source: "docker-compose.server.yml,.env" | ||
# target: /corinee | ||
# overwrite: true | ||
|
||
- name: Deploy to main server | ||
if: matrix.type == 'full' | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
password: ${{ secrets.SSH_PASSWORD }} | ||
port: ${{ secrets.SSH_PORT }} | ||
script: | | ||
cd /corinee | ||
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/corinee-server | ||
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/corinee-client | ||
docker-compose down | ||
docker-compose up -d | ||
docker image prune -f | ||
# - name: Deploy to loadbalancer1 | ||
# if: matrix.type == 'api' | ||
# uses: appleboy/ssh-action@master | ||
# with: | ||
# host: ${{ secrets.LOAD_SSH_HOST }} | ||
# username: ${{ secrets.SSH_USERNAME }} | ||
# password: ${{ secrets.LOAD_SSH_PASSWORD }} | ||
# port: ${{ secrets.SSH_PORT }} | ||
# script: | | ||
# cd /corinee | ||
# docker pull ${{ secrets.DOCKERHUB_USERNAME }}/corinee-server | ||
# docker-compose -f docker-compose.server.yml down | ||
# docker-compose -f docker-compose.server.yml up -d | ||
# docker image prune -f | ||
# - name: Deploy to loadbalancer2 | ||
# if: matrix.type == 'api2' | ||
# uses: appleboy/ssh-action@master | ||
# with: | ||
# host: ${{ secrets.LOAD_SSH_HOST_2 }} | ||
# username: ${{ secrets.SSH_USERNAME }} | ||
# password: ${{ secrets.LOAD_SSH_PASSWORD_2 }} | ||
# port: ${{ secrets.SSH_PORT }} | ||
# script: | | ||
# cd /corinee | ||
# docker pull ${{ secrets.DOCKERHUB_USERNAME }}/corinee-server | ||
# docker-compose -f docker-compose.server.yml down | ||
# docker-compose -f docker-compose.server.yml up -d | ||
# docker image prune -f | ||
# - name: Deploy to loadbalancer3 | ||
# if: matrix.type == 'api3' | ||
# uses: appleboy/ssh-action@master | ||
# with: | ||
# host: ${{ secrets.LOAD_SSH_HOST_3 }} | ||
# username: ${{ secrets.SSH_USERNAME }} | ||
# password: ${{ secrets.LOAD_SSH_PASSWORD_3 }} | ||
# port: ${{ secrets.SSH_PORT }} | ||
# script: | | ||
# cd /corinee | ||
# docker pull ${{ secrets.DOCKERHUB_USERNAME }}/corinee-server | ||
# docker-compose -f docker-compose.server.yml down | ||
# docker-compose -f docker-compose.server.yml up -d | ||
# docker image prune -f | ||
|
||
- name: Generate Error Report | ||
if: failure() | ||
run: | | ||
echo "Deployment Report" > report.txt | ||
echo "===================" >> report.txt | ||
echo "Commit SHA: ${{ github.sha }}" >> report.txt | ||
echo "Branch: ${{ github.ref }}" >> report.txt | ||
echo "Deployment Status: Failed" >> report.txt | ||
echo "Error Details: ${{ job.status }}" >> report.txt | ||
echo "===================" >> report.txt | ||
cat report.txt | ||
- name: Upload Error Report | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: deployment-error-report | ||
path: report.txt |
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 |
---|---|---|
|
@@ -14,3 +14,6 @@ | |
|
||
#!.yarn/cache | ||
.pnp.* | ||
.env.* | ||
.env | ||
ssl |
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 |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
"singleQuote": true, | ||
"trailingComma": "all", | ||
"arrowParens": "always" | ||
} | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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 +1 @@ | ||
yarnPath: .yarn/releases/yarn-4.5.1.cjs | ||
yarnPath: .yarn/releases/yarn-4.5.1.cjs |
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,21 @@ | ||
services: | ||
client: | ||
build: | ||
context: . | ||
dockerfile: dockerfile-client | ||
image: seunggwan/corinee-client | ||
ports: | ||
- "80:80" | ||
- "443:443" | ||
volumes: | ||
- /etc/letsencrypt/live/corinee.site:/etc/letsencrypt/live/corinee.site | ||
- /etc/letsencrypt/live/corinee.site/fullchain.pem:/etc/letsencrypt/live/corinee.site/fullchain.pem | ||
- /etc/letsencrypt/live/corinee.site/privkey.pem:/etc/letsencrypt/live/corinee.site/privkey.pem | ||
- /etc/letsencrypt/archive:/etc/letsencrypt/archive | ||
- /etc/letsencrypt/live:/etc/letsencrypt/live | ||
networks: | ||
- app-network | ||
|
||
networks: | ||
app-network: | ||
driver: bridge |
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,35 @@ | ||
services: | ||
server: | ||
image: seunggwan/corinee-server | ||
restart: always | ||
container_name: corinee_server_2 # 두 번째 서버임을 명시 | ||
env_file: | ||
- .env | ||
ports: | ||
- "3000:3000" | ||
networks: | ||
- app-network | ||
server: | ||
image: seunggwan/corinee-server | ||
restart: always | ||
container_name: corinee_server_3 # 두 번째 서버임을 명시 | ||
env_file: | ||
- .env | ||
ports: | ||
- "3001:3001" | ||
networks: | ||
- app-network | ||
server: | ||
image: seunggwan/corinee-server | ||
restart: always | ||
container_name: corinee_server_4 # 두 번째 서버임을 명시 | ||
env_file: | ||
- .env | ||
ports: | ||
- "3002:3002" | ||
networks: | ||
- app-network | ||
networks: | ||
app-network: | ||
name: corinee_app-network # 메인 서버와 같은 네트워크 이름 사용 | ||
driver: bridge |
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,21 @@ | ||
services: | ||
server: | ||
image: seunggwan/corinee-server | ||
restart: always | ||
container_name: corinee_server_2 # 두 번째 서버임을 명시 | ||
env_file: | ||
- .env | ||
ports: | ||
- "3000:3000" | ||
networks: | ||
- app-network | ||
healthcheck: # 헬스체크 추가 | ||
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"] | ||
interval: 30s | ||
timeout: 10s | ||
retries: 3 | ||
|
||
networks: | ||
app-network: | ||
name: corinee_app-network # 메인 서버와 같은 네트워크 이름 사용 | ||
driver: bridge |
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,38 @@ | ||
services: | ||
server: | ||
build: | ||
context: . | ||
dockerfile: dockerfile-server | ||
image: seunggwan/corinee-server | ||
restart: always | ||
container_name: corinee_server_1 # 컨테이너 이름 명시 | ||
env_file: | ||
- .env | ||
ports: | ||
- "3000:3000" | ||
networks: | ||
- app-network | ||
|
||
client: | ||
build: | ||
context: . | ||
dockerfile: dockerfile-client | ||
args: | ||
- VITE_API_BASE_URL=${VITE_API_BASE_URL} | ||
image: seunggwan/corinee-client | ||
container_name: corinee_client_1 # 컨테이너 이름 명시 | ||
env_file: | ||
- .env | ||
ports: | ||
- "80:80" | ||
depends_on: | ||
- server | ||
volumes: | ||
- /etc/letsencrypt:/etc/letsencrypt # 간단하게 수정 | ||
networks: | ||
- app-network | ||
|
||
networks: | ||
app-network: | ||
name: corinee_app-network # 네트워크 이름 명시 | ||
driver: bridge |
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,20 @@ | ||
FROM node:20 AS build | ||
WORKDIR /app | ||
COPY packages/client/package.json . | ||
RUN yarn install | ||
COPY packages/client . | ||
|
||
ARG VITE_API_BASE_URL | ||
ENV VITE_API_BASE_URL=$VITE_API_BASE_URL | ||
|
||
RUN yarn build | ||
|
||
FROM nginx:alpine | ||
COPY --from=build /app/dist /usr/share/nginx/html | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
# SSL 인증서 디렉토리 생성 | ||
RUN mkdir -p /etc/letsencrypt/live/corinee.site | ||
|
||
EXPOSE 80 443 | ||
CMD ["nginx", "-g", "daemon off;"] |
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,18 @@ | ||
FROM node:20 | ||
WORKDIR /app | ||
|
||
# 패키지 설치 | ||
COPY packages/server/package.json . | ||
RUN yarn install | ||
|
||
# 소스 파일 복사 | ||
COPY packages/server . | ||
|
||
# 애플리케이션 빌드 | ||
RUN yarn build | ||
|
||
# 포트 노출 | ||
EXPOSE 3000 | ||
|
||
# 컨테이너 시작 시 애플리케이션 실행 | ||
CMD ["yarn", "start:prod"] |
Oops, something went wrong.