-
Notifications
You must be signed in to change notification settings - Fork 2
chore/#243 운영 배포를 위한 스테이징 환경 구축 및 스크립트 구성 #244
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fac61e8
refactor: admin api 엔드포인트 admin 프리픽스 추가
LeeHanEum 46387d9
chore: 프로덕션 스웨거 false
LeeHanEum 9fbdd99
chore: 스테이징 도커 환경 세팅
LeeHanEum ba2d1de
chore: Staing 배포 스크립트 구성
LeeHanEum bed0a6a
chore: 애플리케이션에 태그 추가
LeeHanEum eee24a3
Update .github/workflows/staging-build-deploy.yml
LeeHanEum 76d8414
Update .github/workflows/staging-build-deploy.yml
LeeHanEum 4c77460
chore: 코드래빗 리뷰 적용
LeeHanEum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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: Build and Deploy to Staging Server | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build-and-deploy: | ||
| runs-on: ubuntu-latest | ||
| environment: staging | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '17' | ||
| distribution: 'temurin' | ||
|
|
||
| - name: Grant execute permission for gradlew | ||
| run: chmod +x gradlew | ||
|
|
||
| - name: Build all modules | ||
| run: | | ||
| ./gradlew clean build -p aics-admin -x test | ||
| ./gradlew clean build -p aics-api -x test | ||
| ./gradlew clean build -p aics-auth -x test | ||
|
|
||
| - name: Build Docker images | ||
| run: | | ||
| docker build -t aics-admin:${GITHUB_SHA} -f aics-admin/Dockerfile aics-admin | ||
| docker build -t aics-api:${GITHUB_SHA} -f aics-api/Dockerfile aics-api | ||
| docker build -t aics-auth:${GITHUB_SHA} -f aics-auth/Dockerfile aics-auth | ||
|
|
||
| - name: Save Docker images as tar | ||
| run: | | ||
| mkdir -p deploy | ||
| docker save aics-admin:${GITHUB_SHA} -o deploy/aics-admin.tar | ||
| docker save aics-api:${GITHUB_SHA} -o deploy/aics-api.tar | ||
| docker save aics-auth:${GITHUB_SHA} -o deploy/aics-auth.tar | ||
LeeHanEum marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Upload Docker images to server | ||
| uses: appleboy/scp-action@v1.0.0 | ||
| with: | ||
| host: ${{ secrets.STAGING_SERVER_HOST }} | ||
| username: ${{ secrets.STAGING_SERVER_USERNAME }} | ||
| password: ${{ secrets.STAGING_SERVER_PASSWORD }} | ||
| port: ${{ secrets.STAGING_SERVER_PORT }} | ||
| source: "deploy/*" | ||
| target: ${{ secrets.STAGING_DEPLOY_PATH }} | ||
|
|
||
| - name: Deploy on server | ||
| uses: appleboy/ssh-action@v1.1.0 | ||
| with: | ||
| host: ${{ secrets.STAGING_SERVER_HOST }} | ||
| username: ${{ secrets.STAGING_SERVER_USERNAME }} | ||
| password: ${{ secrets.STAGING_SERVER_PASSWORD }} | ||
| port: ${{ secrets.STAGING_SERVER_PORT }} | ||
| script: | | ||
| cd ${{ secrets.STAGING_DEPLOY_PATH }} | ||
| chmod +x backend/deploy.sh | ||
| ./backend/deploy.sh | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| APP_HOME=$(pwd)/backend | ||
|
|
||
| echo "===== Loading Docker images =====" | ||
| sudo docker load -i $APP_HOME/tar/aics-api.tar | ||
| sudo docker tag aics-admin:${GITHUB_SHA} aics-admin:latest | ||
| sudo docker load -i $APP_HOME/tar/aics-admin.tar | ||
| sudo docker tag aics-auth:${GITHUB_SHA} aics-auth:latest | ||
| sudo docker load -i $APP_HOME/tar/aics-auth.tar | ||
| sudo docker tag aics-api:${GITHUB_SHA} aics-api:latest | ||
|
|
||
| echo "===== Stopping existing containers =====" | ||
| sudo docker compose -f $APP_HOME/docker-compose.yml down || true | ||
|
|
||
| echo "===== Starting containers =====" | ||
| sudo docker compose -f $APP_HOME/docker-compose.yml --env-file $APP_HOME/.env up -d | ||
|
|
||
| echo "===== Deployment finished =====" |
This file contains hidden or 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 @@ | ||
| include: | ||
| - networks.yml | ||
| - service-postgres.yml | ||
| - service-redis.yml | ||
LeeHanEum marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or 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 @@ | ||
| include: | ||
| - networks.yml | ||
| - service-application.yml | ||
| - service-nginx.yml |
This file contains hidden or 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,3 @@ | ||
| networks: | ||
| aics-network: | ||
| driver: bridge |
This file contains hidden or 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,60 @@ | ||
| services: | ||
| aics-api: | ||
| image: aics-api:latest | ||
| container_name: aics-api | ||
| env_file: | ||
| - .env | ||
| environment: | ||
| SPRING_PROFILES_ACTIVE: prod | ||
| DB_HOST: postgres | ||
| DB_PORT: 5432 | ||
| DB_NAME: ${POSTGRES_DB} | ||
| DB_USERNAME: ${POSTGRES_USER} | ||
| DB_PASSWORD: ${POSTGRES_PASSWORD} | ||
| JWT_ISSUER: kgudevelopers@gmail.com | ||
| JWT_SECRET_KEY: ${JWT_SECRET_KEY} | ||
| REDIS_HOST: redis | ||
| REDIS_PASSWORD: ${REDIS_PASSWORD} | ||
| FILE_SECRET_KEY: ${FILE_SECRET_KEY} | ||
| networks: | ||
| - aics-network | ||
|
|
||
| aics-admin: | ||
| image: aics-admin:latest | ||
| container_name: aics-admin | ||
| env_file: | ||
| - .env | ||
| environment: | ||
| SPRING_PROFILES_ACTIVE: prod | ||
| DB_HOST: postgres | ||
| DB_PORT: 5432 | ||
| DB_NAME: ${POSTGRES_DB} | ||
| DB_USERNAME: ${POSTGRES_USER} | ||
| DB_PASSWORD: ${POSTGRES_PASSWORD} | ||
| JWT_ISSUER: kgudevelopers@gmail.com | ||
| JWT_SECRET_KEY: ${JWT_SECRET_KEY} | ||
| REDIS_HOST: redis | ||
| REDIS_PASSWORD: ${REDIS_PASSWORD} | ||
| FILE_SECRET_KEY: ${FILE_SECRET_KEY} | ||
| networks: | ||
| - aics-network | ||
|
|
||
| aics-auth: | ||
| image: aics-auth:latest | ||
| container_name: aics-auth | ||
| env_file: | ||
| - .env | ||
| environment: | ||
| SPRING_PROFILES_ACTIVE: prod | ||
| DB_HOST: postgres | ||
| DB_PORT: 5432 | ||
| DB_NAME: ${POSTGRES_DB} | ||
| DB_USERNAME: ${POSTGRES_USER} | ||
| DB_PASSWORD: ${POSTGRES_PASSWORD} | ||
| JWT_ISSUER: kgudevelopers@gmail.com | ||
| JWT_SECRET_KEY: ${JWT_SECRET_KEY} | ||
| REDIS_HOST: redis | ||
| REDIS_PASSWORD: ${REDIS_PASSWORD} | ||
| FILE_SECRET_KEY: ${FILE_SECRET_KEY} | ||
| networks: | ||
| - aics-network |
This file contains hidden or 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,9 @@ | ||
| services: | ||
| nginx: | ||
| image: nginx:latest | ||
| volumes: | ||
| - ./nginx.conf:/etc/nginx/conf.d/default.conf | ||
LeeHanEum marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ports: | ||
| - "80:80" | ||
| networks: | ||
| - aics-network | ||
This file contains hidden or 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 @@ | ||
| services: | ||
| postgres: | ||
| image: postgres:15 | ||
| container_name: postgres | ||
| restart: always | ||
| env_file: | ||
| - .env | ||
| ports: | ||
| - "5432:5432" | ||
| environment: | ||
| POSTGRES_USER: ${POSTGRES_USER} | ||
| POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} | ||
| POSTGRES_DB: ${POSTGRES_DB} | ||
| volumes: | ||
| - postgres-data:/var/lib/postgresql/data | ||
| networks: | ||
| - aics-network | ||
|
|
||
| volumes: | ||
| postgres-data: |
This file contains hidden or 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,12 @@ | ||
| services: | ||
| redis: | ||
| image: redis:latest | ||
| container_name: redis | ||
| restart: always | ||
| command: ["redis-server", "--requirepass", "${REDIS_PASSWORD}"] | ||
| env_file: | ||
| - .env | ||
| environment: | ||
| REDIS_PASSWORD: ${REDIS_PASSWORD} | ||
| networks: | ||
| - aics-network |
This file contains hidden or 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,33 @@ | ||
| server { | ||
| listen 80; | ||
|
|
||
| location ^~ /api/v1/auth/ { | ||
| proxy_pass http://aics-auth:8082/api/v1/; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header Origin $http_origin; | ||
| } | ||
|
|
||
| location ^~ /api/v1/admin/ { | ||
| proxy_pass http://aics-admin:8081/api/v1/admin/; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header Origin $http_origin; | ||
| } | ||
|
|
||
| location ^~ /api/v1/ { | ||
| proxy_pass http://aics-api:8080/api/v1/; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header Origin $http_origin; | ||
| } | ||
|
|
||
| location / { | ||
| proxy_pass http://aics-app:3000/; | ||
| proxy_http_version 1.1; | ||
| proxy_set_header Upgrade $http_upgrade; | ||
| proxy_set_header Connection 'upgrade'; | ||
| proxy_set_header Host $host; | ||
| proxy_cache_bypass $http_upgrade; | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.