Skip to content

Commit

Permalink
Merge pull request #158 from tnpfldyd/BE-feature/image-storage
Browse files Browse the repository at this point in the history
슀페이슀, ν”„λ‘œν•„ 이미지 μ—…λ‘œλ“œ
  • Loading branch information
Conut-1 authored Dec 5, 2023
2 parents c0d4ef4 + 6440c1c commit 9f5793d
Show file tree
Hide file tree
Showing 15 changed files with 417 additions and 53 deletions.
84 changes: 48 additions & 36 deletions .github/workflows/BE-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,56 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: BE-develop
sparse-checkout: nestjs-BE
- name: Login to github Packages
run: echo ${{ secrets.PACKAGE_ACCESS_TOKEN }} | docker login ghcr.io -u ${{ secrets.PACKAGE_USERNAME }} --password-stdin
- name: Build and push Docker image
run: |
echo "SERVER_PORT=$SERVER_PORT" >> ./nestjs-BE/server/.env
echo "JWT_SECRET=$JWT_SECRET" >> ./nestjs-BE/server/.env
echo "KAKAO_ADMIN_KEY=$KAKAO_ADMIN_KEY" >> ./nestjs-BE/server/.env
echo "MYSQL_DATABASE_URL=$MYSQL_DATABASE_URL" >> ./nestjs-BE/server/.env
echo "MONGODB_DATABASE_URL=$MONGODB_DATABASE_URL" >> ./nestjs-BE/server/.env
echo "MONGODB_DATABASE_URI=$MONGODB_DATABASE_URI" >> ./nestjs-BE/server/.env
docker build -t ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync ./nestjs-BE/server
docker push ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync:latest
env:
SERVER_PORT: ${{ secrets.CONTAINER_PORT }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
KAKAO_ADMIN_KEY: ${{ secrets.KAKAO_ADMIN_KEY }}
MYSQL_DATABASE_URL: ${{ secrets.MYSQL_DATABASE_URL }}
MONGODB_DATABASE_URL: ${{ secrets.MONGODB_DATABASE_URL }}
MONGODB_DATABASE_URI: ${{ secrets.MONGODB_DATABASE_URI }}
- uses: actions/checkout@v4
with:
ref: BE-develop
sparse-checkout: nestjs-BE
- name: Login to github Packages
run: echo ${{ secrets.PACKAGE_ACCESS_TOKEN }} | docker login ghcr.io -u ${{ secrets.PACKAGE_USERNAME }} --password-stdin
- name: Build and push Docker image
run: |
echo "SERVER_PORT=$SERVER_PORT" >> ./nestjs-BE/server/.env
echo "JWT_SECRET=$JWT_SECRET" >> ./nestjs-BE/server/.env
echo "KAKAO_ADMIN_KEY=$KAKAO_ADMIN_KEY" >> ./nestjs-BE/server/.env
echo "MYSQL_DATABASE_URL=$MYSQL_DATABASE_URL" >> ./nestjs-BE/server/.env
echo "MONGODB_DATABASE_URL=$MONGODB_DATABASE_URL" >> ./nestjs-BE/server/.env
echo "MONGODB_DATABASE_URI=$MONGODB_DATABASE_URI" >> ./nestjs-BE/server/.env
echo "NCLOUD_ACCESS_KEY=$NCLOUD_ACCESS_KEY" >> ./nestjs-BE/server/.env
echo "NCLOUD_SECRET_KEY=$NCLOUD_SECRET_KEY" >> ./nestjs-BE/server/.env
echo "NCLOUD_REGION=$NCLOUD_REGION" >> ./nestjs-BE/server/.env
echo "STORAGE_URL=$STORAGE_URL" >> ./nestjs-BE/server/.env
echo "BASE_IMAGE_URL=$BASE_IMAGE_URL" >> ./nestjs-BE/server/.env
echo "BUCKET_NAME=$BUCKET_NAME" >> ./nestjs-BE/server/.env
docker build -t ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync ./nestjs-BE/server
docker push ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync:latest
env:
SERVER_PORT: ${{ secrets.CONTAINER_PORT }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
KAKAO_ADMIN_KEY: ${{ secrets.KAKAO_ADMIN_KEY }}
MYSQL_DATABASE_URL: ${{ secrets.MYSQL_DATABASE_URL }}
MONGODB_DATABASE_URL: ${{ secrets.MONGODB_DATABASE_URL }}
MONGODB_DATABASE_URI: ${{ secrets.MONGODB_DATABASE_URI }}
NCLOUD_ACCESS_KEY: ${{ secrets.NCLOUD_ACCESS_KEY }}
NCLOUD_SECRET_KEY: ${{ secrets.NCLOUD_SECRET_KEY }}
NCLOUD_REGION: ${{ secrets.NCLOUD_REGION }}
STORAGE_URL: ${{ secrets.STORAGE_URL }}
BASE_IMAGE_URL: ${{ secrets.BASE_IMAGE_URL }}
BUCKET_NAME: ${{ secrets.BUCKET_NAME }}

deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Pull Docker image
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
port: ${{ secrets.REMOTE_PORT }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.REMOTE_SSH_KEY }}
script: |
echo ${{ secrets.PACKAGE_ACCESS_TOKEN }} | docker login ghcr.io -u ${{ secrets.PACKAGE_USERNAME }} --password-stdin
docker pull ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync
docker stop mindsync_server || true
docker rm mindsync_server || true
docker run -d --name mindsync_server -p ${{ secrets.SERVER_PORT }}:${{ secrets.CONTAINER_PORT }} ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync
- name: Pull Docker image
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
port: ${{ secrets.REMOTE_PORT }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.REMOTE_SSH_KEY }}
script: |
echo ${{ secrets.PACKAGE_ACCESS_TOKEN }} | docker login ghcr.io -u ${{ secrets.PACKAGE_USERNAME }} --password-stdin
docker pull ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync
docker stop mindsync_server || true
docker rm mindsync_server || true
docker run -d --name mindsync_server -p ${{ secrets.SERVER_PORT }}:${{ secrets.CONTAINER_PORT }} ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync
Loading

0 comments on commit 9f5793d

Please sign in to comment.