From aef3de070a30f88e010a2ed2ad97ca61b6047218 Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Thu, 29 Aug 2024 16:37:35 -0400 Subject: [PATCH] Use docker/metadata-action --- .github/workflows/ci.yml | 36 ++++++++++++++++-------------------- Dockerfile | 9 --------- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b00143a..420bea07 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,24 +29,21 @@ jobs: needs: [ test ] if: github.event_name == 'push' || github.event_name == 'release' runs-on: ubuntu-24.04 - env: - repo_name: fnndsc/cube steps: - - name: Determine image tags - id: determine - run: | - repo="${{ env.repo_name }}" - tag="${GITHUB_REF_NAME:-latest}" # if build triggered by tag, use tag name - - # if tag is a version number prefixed by 'v', remove the 'v' - if [[ "$tag" =~ ^v[0-9].* ]]; then - tag="${tag:1}" - fi - - dock_image=$repo:$tag - echo $dock_image - echo "dock_image=$dock_image" >> $GITHUB_OUTPUT - uses: actions/checkout@v4 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + docker.io/fnndsc/cube + ghcr.io/fnndsc/cube + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=raw,value=latest,enable={{is_default_branch}} - uses: docker/setup-qemu-action@v3 - uses: docker/setup-buildx-action@v3 - name: Login to DockerHub @@ -67,12 +64,11 @@ jobs: push: true context: . file: ./Dockerfile - tags: | - docker.io/${{ steps.determine.outputs.dock_image }} - ghcr.io/${{ steps.determine.outputs.dock_image }} platforms: linux/amd64,linux/ppc64le,linux/arm64 cache-from: type=gha cache-to: type=gha,mode=max + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} - name: Update Docker Hub description uses: peter-evans/dockerhub-description@v4 @@ -81,4 +77,4 @@ jobs: password: ${{ secrets.DOCKERHUB_PASSWORD }} short-description: ChRIS backend readme-filepath: ./README.md - repository: ${{ env.repo_name }} + repository: fnndsc/cube diff --git a/Dockerfile b/Dockerfile index bbeb9bce..2602375e 100755 --- a/Dockerfile +++ b/Dockerfile @@ -41,14 +41,5 @@ RUN if [ "$ENVIRONMENT" = "production" ]; then \ CMD ["gunicorn", "-b", "0.0.0.0:8000", "-w", "4", "config.wsgi:application"] -LABEL org.opencontainers.image.authors="FNNDSC " \ - org.opencontainers.image.title="ChRIS Backend" \ - org.opencontainers.image.description="ChRIS backend django API server" \ - org.opencontainers.image.url="https://chrisproject.org/" \ - org.opencontainers.image.source="https://github.com/FNNDSC/ChRIS_ultron_backEnd" \ - org.opencontainers.image.documentation="https://github.com/FNNDSC/ChRIS_ultron_backEnd/wiki/" \ - org.opencontainers.image.version="" \ - org.opencontainers.image.licenses="MIT" - HEALTHCHECK --interval=30s --timeout=5s \ CMD curl -f http://localhost:8000/api/v1/users/ || exit 1