Skip to content

Commit

Permalink
Merge pull request #6 from boostcampwm2023/chore/#5
Browse files Browse the repository at this point in the history
[chore] API 서버 CI/CD
  • Loading branch information
jmhee28 authored Nov 9, 2023
2 parents f173c42 + 606d47b commit b83ceb2
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: auto deploy

on:
push:
branches:
- dev

jobs:
push_to_registry:
name: Push to ncp container registry
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to NCP Container Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.NCP_CONTAINER_REGISTRY }}
username: ${{ secrets.NCP_ACCESS_KEY }}
password: ${{ secrets.NCP_SECRET_KEY }}
- name: build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./server/api-server/Dockerfile
push: true
tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/api-server:latest
cache-from: type=registry,ref=${{ secrets.NCP_CONTAINER_REGISTRY }}/api-server:latest
cache-to: type=inline

pull_from_registry:
name: Connect server ssh and pull from container registry
needs: push_to_registry
runs-on: ubuntu-latest
steps:
- name: connect ssh
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.API_SERVER_HOST }}
username: ${{ secrets.API_SERVER_USERNAME }}
password: ${{ secrets.API_SERVER_PASSWORD }}
port: ${{ secrets.API_SERVER_PORT }}
script: |
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/api-server
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker run -d -p 80:3000 ${{ secrets.NCP_CONTAINER_REGISTRY }}/api-server
docker image prune -f
14 changes: 14 additions & 0 deletions server/api-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:lts-alpine

WORKDIR /usr/src/app

COPY ./server/api-server/package*.json ./
COPY ./server/api-server/yarn*.lock ./

RUN yarn install

COPY ./server/api-server/. .

EXPOSE 80

CMD ["yarn","start"]

0 comments on commit b83ceb2

Please sign in to comment.