Skip to content

Commit

Permalink
Merge pull request #70 from boostcampwm2023/dev/be
Browse files Browse the repository at this point in the history
backend CI/CD μ›Œν¬ν”Œλ‘œμš° μ„€μ •
  • Loading branch information
sickbirdd authored Nov 15, 2023
2 parents ba690a5 + b5e9583 commit ace72d8
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/backend-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: πŸ€ Deploy to Naver Cloud Platform
on:
push:
branches:
- release # Only in release branch

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: ./backend/Dockerfile
push: true
tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/server:latest
cache-from: type=registry,ref=${{ secrets.NCP_CONTAINER_REGISTRY }}/server:latest
cache-to: type=inline
secrets: |
GIT_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }}
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.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
script: |
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/server
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker run -d -p 80:3000 --env-file ${{ secrets.ENV_FILE }} ${{ secrets.NCP_CONTAINER_REGISTRY }}/server
docker image prune -f
20 changes: 20 additions & 0 deletions .github/workflows/backend-eslint-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: ESLint Check
on:
pull_request:
paths:
- backend/**
jobs:
eslint:
name: runner / eslint
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-eslint@v1
with:
eslint_flags: "src/"
filter_mode: file
workdir: "backend"
fail_on_error: true
15 changes: 15 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:lts-alpine

WORKDIR /usr/src/app

COPY ./backend/package*.json ./

RUN npm install

COPY ./backend/. .

RUN npm run build

EXPOSE 3000

CMD ["npm", "start"]

0 comments on commit ace72d8

Please sign in to comment.