From 21b9dcc649731964ccdd45d3d6d9f2f0aadee9d1 Mon Sep 17 00:00:00 2001 From: jeongmin Date: Sun, 10 Dec 2023 14:29:13 +0900 Subject: [PATCH] deploy: build and scp frontend --- .github/workflows/deploy-frontend.yml | 43 ++++++++------------------- docker/fe/Dockerfile | 2 ++ 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/.github/workflows/deploy-frontend.yml b/.github/workflows/deploy-frontend.yml index f36561e..de5d355 100644 --- a/.github/workflows/deploy-frontend.yml +++ b/.github/workflows/deploy-frontend.yml @@ -1,4 +1,4 @@ -name: Build and Push frontend +name: Build and Scp frontend on: push: @@ -15,41 +15,24 @@ jobs: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up Docker Compose - run: | - sudo apt-get update - sudo apt-get install -y curl - sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - docker-compose --version - - - name: Login to NCP Container Registry - uses: docker/login-action@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 with: - registry: byeolsoop-registry.kr.ncr.ntruss.com - username: ${{ secrets.API_ACCESS_KEY }} - password: ${{ secrets.API_SECRET_KEY }} + node-version: "20.10.0" - - name: Build and Push Frontend Docker Image + - name: Install Dependencies and Build run: | - docker build -t byeolsoop-registry.kr.ncr.ntruss.com/frontend:byeolsoop -f ./docker/fe/Dockerfile . - docker push byeolsoop-registry.kr.ncr.ntruss.com/frontend:byeolsoop + cd ./FE + echo ${{secrets.ENV_FE}} > .env + npm install --force + npm run build - pull-and-deploy: - runs-on: ubuntu-20.04 - needs: build-and-push-frontend - - steps: - - name: SSH-deploy - uses: appleboy/ssh-action@master + - name: Deploy to NCloud + uses: appleboy/scp-action@master with: host: ${{secrets.VPC_HOST}} username: ${{secrets.VPC_USER}} password: ${{secrets.VPC_PASSWORD}} port: ${{secrets.VPC_PORT}} - script: | - cd /home/docker-byeolsoop/srcs - docker system prune -f - docker pull byeolsoop-registry.kr.ncr.ntruss.com/frontend:byeolsoop - docker compose up --force-recreate -d 2>log.out - cat log.out + source: "./FE/build/*" + target: "/home/docker-byeolsoop/data/www" diff --git a/docker/fe/Dockerfile b/docker/fe/Dockerfile index 4cc57f5..55b4168 100644 --- a/docker/fe/Dockerfile +++ b/docker/fe/Dockerfile @@ -1,3 +1,5 @@ +# 정적 파일 서빙방식으로 변경하면서 사용하지 않음 + FROM node:20.10.0-alpine3.18 LABEL author jeongmin