Skip to content

Fix: move dockerfile to root directory #68

Fix: move dockerfile to root directory

Fix: move dockerfile to root directory #68

Workflow file for this run

name: Deploy to EC2
on:
push:
branches:
- main # 또는 배포 브랜치 이름
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip list --format=freeze > requirements.txt
pip install -r requirements.txt
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.EC2_KEY }}
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build Docker image
run: docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/pureplate:latest .
- name: Push Docker image to Docker Hub
run: docker push ${{ secrets.DOCKER_HUB_USERNAME }}/pureplate:latest
- name: Deploy to EC2
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/pureplate:latest
docker stop pureplate || true
docker rm pureplate || true
docker run -d -p 8000:8000 --name pureplate ${{ secrets.DOCKER_HUB_USERNAME }}/pureplate:latest
EOF