From 83315b940aa85263f94393c0786eeda516a826ac Mon Sep 17 00:00:00 2001 From: seokjin1023 Date: Mon, 5 May 2025 13:47:00 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20github=5Faction=EC=9C=BC=EB=A1=9C=20doc?= =?UTF-8?q?ker=5Fhub=20=EC=9E=90=EB=8F=99=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 29 +++++++++++++++++++++++++++++ Dockerfile | 6 ++++++ 2 files changed, 35 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 Dockerfile diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..df41045 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,29 @@ +name: Docker Build & Push + +on: + push: + branches: [ "main", "dev" ] + pull_request: + branches: [ "main", "dev" ] + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + ${{ secrets.DOCKER_USERNAME }}/fastapi-app:latest + ${{ secrets.DOCKER_USERNAME }}/fastapi-app:${{ github.sha }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c28134c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3.9-slim +WORKDIR /app +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt +COPY . . +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]