From c799b2b189acef5b8813bff7b92a850bd1678bdd Mon Sep 17 00:00:00 2001 From: Nandaja Varma Date: Mon, 15 Jul 2024 10:48:02 +0000 Subject: [PATCH] Fixing the dockerfile again --- .github/workflows/docker-build.yml | 20 ++++++++++++++++++-- deployment/Dockerfile | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index f5b1510..90b7d60 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -4,6 +4,10 @@ on: push: branches: - main + pull_request: + branches: + - '*' + workflow_dispatch: jobs: build: @@ -22,13 +26,25 @@ jobs: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Determine Docker tag + id: docker-tag + run: | + if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then + echo "::set-output name=tag::latest" + elif [ "${{ github.event_name }}" == "pull_request" ]; then + echo "::set-output name=tag::pr-${{ github.event.number }}" + else + BRANCH_NAME=$(echo "${{ github.ref }}" | sed 's/refs\/heads\///') + echo "::set-output name=tag::${BRANCH_NAME}" + fi + - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . file: deployment/Dockerfile push: true - tags: pearsproject/pears-federated:latest + tags: pearsproject/pears-federated:${{ steps.docker-tag.outputs.tag }} - name: Image digest - run: echo ${{ steps.build.outputs.digest }} + run: echo ${{ steps.build.outputs.digest }} \ No newline at end of file diff --git a/deployment/Dockerfile b/deployment/Dockerfile index b479db2..66b1682 100644 --- a/deployment/Dockerfile +++ b/deployment/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /app COPY requirements.txt /tmp/ RUN pip install --requirement /tmp/requirements.txt -RUN sudo apt-get install -y poppler-utils +RUN apt update && apt install -y poppler-utils # Additionally, install Gunicorn RUN pip install gunicorn