This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
Merge branch 'main' of https://github.com/racheliee/ai-LangDevAssist #1
This file contains 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
name: Docker Image CI | |
on: | |
push: | |
paths: | |
- backend/** | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
defaults: | |
run: | |
working-directory: './backend' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login Dockerhub | |
env: | |
DOCKER_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} | |
DOCKER_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} | |
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD | |
- name: Build the Docker image | |
run: docker build --platform linux/amd64 -t ${{secrets.DOCKERHUB_USERNAME}}/sprout-backend:latest . | |
- name: push | |
run: docker push ${{secrets.DOCKERHUB_USERNAME}}/sprout-backend:latest | |
- name: Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} # EC2 인스턴스 퍼블릭 DNS | |
username: root | |
key: ${{ secrets.PRIVATE_KEY }} # pem 키 | |
# 도커 작업 | |
script: | | |
docker pull ${{ secrets.DOCKER_USERNAME }}/sprout-backend:latest | |
docker stop main | |
docker remove main | |
docker run -d --log-driver=syslog -p 8000:8000 --network app --env-file .env --name main ${{ secrets.DOCKER_USERNAME }}/sprout-backend:latest | |
docker image prune -a -f |