From d8d26dfda9397831de09549e7b352d3eaba7d4f4 Mon Sep 17 00:00:00 2001 From: realgoob Date: Fri, 27 Sep 2024 10:06:18 -0600 Subject: [PATCH 1/2] Create Dockerfile --- Dockerfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cf2b9c5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.11-slim + +WORKDIR /app +COPY . . + +RUN pip install gunicorn +RUN pip install -r requirements.txt + +# Expose the port on which the Flask app will run +EXPOSE 8080 + +# Define the command to run the application using Gunicorn on port 8080 +CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:app"] From 0af0b7e074c48055f8e390bb31dc37f1bd3e9b60 Mon Sep 17 00:00:00 2001 From: realgoob Date: Fri, 27 Sep 2024 10:16:00 -0600 Subject: [PATCH 2/2] Update run-tests.yml Added new branch for updates and included variables for docker connection --- .github/workflows/run-tests.yml | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index f04dc9d..9a4baed 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,9 +1,10 @@ -name: Run Tests on Push to session-1 and Pull Request to main +name: CI/CD Pipeline on: push: branches: - session-1 + - session-2 pull_request: branches: - main @@ -19,7 +20,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' # Specify the Python version you want to use + python-version: '3.11' - name: Install dependencies run: | @@ -29,3 +30,26 @@ jobs: - name: Run tests run: | pytest --maxfail=1 --disable-warnings + + build_and_push: + runs-on: ubuntu-latest + needs: test + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/tech-trek:${{ github.sha }}