-
Notifications
You must be signed in to change notification settings - Fork 125
Update Docker workflow for permissions and manifests #1080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,10 @@ on: | |
| description: 'tag to containerize' | ||
| required: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| concurrency: | ||
| group: Containerization | ||
| cancel-in-progress: false | ||
|
|
@@ -24,6 +28,7 @@ jobs: | |
| runs-on: ${{ matrix.config.runner }} | ||
| outputs: | ||
| tag: ${{ steps.clone.outputs.tag }} | ||
|
|
||
| steps: | ||
| - name: Free Disk Space | ||
| uses: jlumbroso/free-disk-space@main | ||
|
|
@@ -36,12 +41,20 @@ jobs: | |
| docker-images: true | ||
| swap-storage: true | ||
|
|
||
| - name: Login | ||
| # ----- Logins ----- | ||
| - name: Login to Docker Hub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
|
||
| - name: Login to GHCR | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Setup Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
|
|
@@ -89,12 +102,16 @@ jobs: | |
| FC_COMPILER=${{ 'gfortran' }} | ||
| COMPILER_PATH=${{ '/usr/bin' }} | ||
| COMPILER_LD_LIBRARY_PATH=${{ '/usr/lib' }} | ||
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.name }} | ||
| labels: | | ||
| org.opencontainers.image.source=https://github.com/${{ github.repository }} | ||
| tags: | | ||
| ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.name }} | ||
| ghcr.io/${{ github.repository_owner }}/mfc:${{ env.TAG }}-${{ matrix.config.name }} | ||
|
Comment on lines
+107
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The GHCR tags are built from Useful? React with 👍 / 👎. |
||
| push: true | ||
|
|
||
| - name: Build and push image (gpu) | ||
| if: ${{ matrix.config.name == 'gpu' }} | ||
| uses: docker/build-push-action@v5 | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| builder: default | ||
| context: /mnt/share | ||
|
|
@@ -107,26 +124,61 @@ jobs: | |
| FC_COMPILER=${{ 'nvfortran' }} | ||
| COMPILER_PATH=${{ '/opt/nvidia/hpc_sdk/Linux_x86_64/compilers/bin' }} | ||
| COMPILER_LD_LIBRARY_PATH=${{ '/opt/nvidia/hpc_sdk/Linux_x86_64/compilers/lib' }} | ||
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.name }}-${{ matrix.config.runner}} | ||
| labels: | | ||
| org.opencontainers.image.source=https://github.com/${{ github.repository }} | ||
| tags: | | ||
| ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.name }}-${{ matrix.config.runner}} | ||
| ghcr.io/${{ github.repository_owner }}/mfc:${{ env.TAG }}-${{ matrix.config.name }}-${{ matrix.config.runner}} | ||
|
Comment on lines
+129
to
+131
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reconsider GPU image tag naming strategy. Using the full runner name ( Current tags like Consider one of these alternatives:
If you want to maintain per-runner image artifacts for debugging or pinning specific builds, consider using a different approach such as:
🤖 Prompt for AI Agents |
||
| push: true | ||
|
|
||
| manifests: | ||
| runs-on: ubuntu-latest | ||
| needs: Container | ||
| steps: | ||
| - name: Login | ||
| - name: Login to Docker Hub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
|
||
| - name: Create and Push Manifest Lists | ||
| - name: Login to GHCR | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Create and Push Manifest Lists (Docker Hub + GHCR) | ||
| env: | ||
| TAG: ${{ needs.Container.outputs.tag }} | ||
| REGISTRY: ${{ secrets.DOCKERHUB_USERNAME }}/mfc | ||
| DH_REGISTRY: ${{ secrets.DOCKERHUB_USERNAME }}/mfc | ||
| GH_REGISTRY: ghcr.io/${{ github.repository_owner }}/mfc | ||
| run: | | ||
| docker buildx imagetools create -t $REGISTRY:latest-cpu $REGISTRY:$TAG-cpu | ||
| docker manifest create $REGISTRY:$TAG-gpu $REGISTRY:$TAG-gpu-ubuntu-22.04 $REGISTRY:$TAG-gpu-ubuntu-22.04-arm | ||
| docker manifest create $REGISTRY:latest-gpu $REGISTRY:$TAG-gpu-ubuntu-22.04 $REGISTRY:$TAG-gpu-ubuntu-22.04-arm | ||
| docker manifest push $REGISTRY:$TAG-gpu | ||
| docker manifest push $REGISTRY:latest-gpu | ||
| # ---- CPU multi-arch "latest-cpu" from the already pushed $TAG-cpu ---- | ||
| docker buildx imagetools create -t $DH_REGISTRY:latest-cpu $DH_REGISTRY:$TAG-cpu | ||
| docker buildx imagetools create -t $GH_REGISTRY:latest-cpu $GH_REGISTRY:$TAG-cpu | ||
|
|
||
| # ---- GPU manifests across the two runners ---- | ||
| # Tag these for versioned + latest GPU | ||
| docker manifest create $DH_REGISTRY:$TAG-gpu \ | ||
| $DH_REGISTRY:$TAG-gpu-ubuntu-22.04 \ | ||
| $DH_REGISTRY:$TAG-gpu-ubuntu-22.04-arm | ||
|
|
||
| docker manifest create $DH_REGISTRY:latest-gpu \ | ||
| $DH_REGISTRY:$TAG-gpu-ubuntu-22.04 \ | ||
| $DH_REGISTRY:$TAG-gpu-ubuntu-22.04-arm | ||
|
|
||
| docker manifest push $DH_REGISTRY:$TAG-gpu | ||
| docker manifest push $DH_REGISTRY:latest-gpu | ||
|
|
||
| # GHCR equivalent | ||
| docker manifest create $GH_REGISTRY:$TAG-gpu \ | ||
| $GH_REGISTRY:$TAG-gpu-ubuntu-22.04 \ | ||
| $GH_REGISTRY:$TAG-gpu-ubuntu-22.04-arm | ||
|
|
||
| docker manifest create $GH_REGISTRY:latest-gpu \ | ||
| $GH_REGISTRY:$TAG-gpu-ubuntu-22.04 \ | ||
| $GH_REGISTRY:$TAG-gpu-ubuntu-22.04-arm | ||
|
|
||
| docker manifest push $GH_REGISTRY:$TAG-gpu | ||
| docker manifest push $GH_REGISTRY:latest-gpu | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High-level Suggestion
The manifest creation script in the
manifestsjob contains duplicated logic for Docker Hub and GHCR. This should be refactored into a loop over the registries to improve readability and maintainability. [High-level, importance: 7]Solution Walkthrough:
Before:
After: