From 0c56eb63040794cbee96d85a3af41e4a03be1395 Mon Sep 17 00:00:00 2001 From: d33bs Date: Tue, 2 Apr 2024 16:04:35 -0600 Subject: [PATCH] fix(ci): docker image push fixes Co-Authored-By: Ken Brewer --- .github/workflows/integration-test.yml | 13 +++++++------ build/docker/Dockerfile | 6 +++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 91c17628..ab59b9eb 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -201,13 +201,14 @@ jobs: # Gather and prepare the dynamic version and other vars for use with work below. # For example, 1.1.0.post6.dev0+bc093ef becomes 1.1.0.post6.dev0_bc093ef - name: Gather dynamic version and set env var + if: (github.event_name == 'push'|| github.event_name == 'schedule') && github.ref == 'refs/heads/main' id: env-vars run: >- - echo "CLEAN_VERSION=$(echo ${{ env.sdist_filename }} | tr '+' '_' )" >> "$GITHUB_OUTPUT" && + echo "CLEAN_VERSION=$(echo ${{ env.sdist_extracted_name }} | tr '+' '_' )" >> "$GITHUB_OUTPUT" && echo "DATE_TAG=$(date +'%y%m%d')" >> "$GITHUB_OUTPUT" - name: Login to Docker Hub # only run this task if we have a pull request merged or the schedule triggers from main - if: (github.event.pull_request.merged || github.event_name == 'schedule') && github.ref == 'refs/heads/main' + if: (github.event_name == 'push'|| github.event_name == 'schedule') && github.ref == 'refs/heads/main' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USER }} @@ -220,24 +221,24 @@ jobs: with: context: "${{ env.sdist_extracted_name }}" push: true - file: ../build/docker/Dockerfile + file: ./build/docker/Dockerfile target: production tags: cytomining/pycytominer:${{ steps.env-vars.outputs.CLEAN_VERSION }}_${{ steps.env-vars.outputs.DATE_TAG }} # Docker image push based on GitHub pushes to main - name: Push-based docker image push # only run this task if we have a pull request which is merged - if: github.event.pull_request.merged && github.ref == 'refs/heads/main' && github.repository == 'cytomining/pycytominer' + if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'cytomining/pycytominer' uses: docker/build-push-action@v5 with: context: "${{ env.sdist_extracted_name }}" push: true - file: ../build/docker/Dockerfile + file: ./build/docker/Dockerfile target: production tags: cytomining/pycytominer:latest,cytomining/pycytominer:${{ steps.env-vars.outputs.CLEAN_VERSION }} # update docker hub description using readme on merge - name: Docker Hub # only run this task if we have a pull request which is merged - if: github.event.pull_request.merged && github.ref == 'refs/heads/main' && github.repository == 'cytomining/pycytominer' + if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'cytomining/pycytominer' uses: peter-evans/dockerhub-description@v3 with: username: ${{ secrets.DOCKER_USER }} diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 9948094a..d288e812 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -25,7 +25,8 @@ RUN pip install --no-cache-dir poetry FROM base as production # copy the pycytominer source into image -COPY . . +COPY README.md pyproject.toml poetry.lock ./ +COPY pycytominer ./pycytominer # install pycytominer using poetry root dependencies and all extras RUN poetry install --all-extras -v --no-interaction @@ -33,5 +34,8 @@ RUN poetry install --all-extras -v --no-interaction # create stage for production build (no dev or non-essential deps) FROM production as testing +# copy the tests dir for testing purposes +COPY tests ./tests + # install pycytominer from poetry with group deps and all extras for testing RUN poetry install --with dev --all-extras -v --no-interaction