기능 변경 후 AOS와의 통신 테스트를 위한 개발 환경 배포 #10
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: EATceed | |
run-name: '${{ github.event.pull_request.title }}' | |
# Event: develop branch merge | |
on: | |
pull_request: | |
branches: | |
- develop | |
types: | |
- closed | |
jobs: | |
build-and-push: | |
name: Build and Push Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
# Actions: chekcout action3 | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
# Dockerhub 로그인 | |
- name: Docker Hub Login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
# Docker build | |
- name: Build Docker Image | |
run: docker buildx build --platform linux/amd64 -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DEV_APPLICATION }} -f server/Dockerfile.dev server | |
# Docker push | |
- name: Push Docker Image | |
run: docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DEV_APPLICATION }} | |
deploy: | |
name: Deploy on AWS EC2 Server(Dev) | |
runs-on: ubuntu-latest | |
needs: build-and-push | |
steps: | |
# chekcout action의 3 버전을 Actions으로써 실행 | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
# AWS EC2 연결 및 배포 | |
- name: Connect to AWS EC2 and Deploy | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.DEV_AWS_HOST }} | |
username: ${{ secrets.DEV_AWS_USER }} | |
key: ${{ secrets.DEV_AWS_PRIVATE_KEY }} | |
# 기존 AWS EC2 서버에서 수행한 명령어 작성 | |
script: | | |
cd ai | |
sudo docker stop fastapi | |
sudo docker rm fastapi | |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DEV_APPLICATION }} | |
sudo docker run -d -p 8000:8000 --name fastapi --env-file .env -v ${{ secrets.GOOGLE_API_PATH }} ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DEV_APPLICATION }} | |
sudo docker image prune -a -f |