README update. #121
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: docker-jupyter-hub-all | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| branches: ['**'] | |
| tags: ['v*.*.*'] | |
| pull_request: | |
| branches: ['**'] | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| concurrency: | |
| group: docker-jupyter-all-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # ---------- AMD64 ---------- | |
| build-amd64: | |
| runs-on: ubuntu-22.04 | |
| if: ${{ github.event_name != 'pull_request' }} | |
| outputs: | |
| hub_digest: ${{ steps.hub.outputs.digest }} | |
| su_digest: ${{ steps.su.outputs.digest }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: { submodules: recursive, fetch-depth: 0 } | |
| - uses: docker/setup-buildx-action@v3 | |
| - name: Docker meta (hub) | |
| id: meta_hub | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: cogstacksystems/jupyter-hub | |
| tags: | | |
| # vX.Y.Z -> X.Y.Z and X.Y (strip leading "v") | |
| type=semver,pattern={{version}},prefix=v | |
| type=semver,pattern={{major}}.{{minor}},prefix=v | |
| # latest on main and on v-tags | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} | |
| # branch tag for non-PR branches | |
| type=ref,event=branch,enable=${{ github.event_name != 'pull_request' }} | |
| # short sha | |
| type=sha,format=short | |
| - name: Docker meta (singleuser) | |
| id: meta_su | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: cogstacksystems/jupyter-singleuser | |
| tags: | | |
| # vX.Y.Z -> X.Y.Z and X.Y (strip "v") | |
| type=semver,pattern={{version}},prefix=v | |
| type=semver,pattern={{major}}.{{minor}},prefix=v | |
| # latest on main AND on v-tags | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} | |
| # branches (non-PR) | |
| type=ref,event=branch,enable=${{ github.event_name != 'pull_request' }} | |
| # short sha | |
| type=sha,format=short | |
| - uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - name: Build & push hub (amd64) | |
| id: hub | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile_hub | |
| platforms: linux/amd64 | |
| build-args: | | |
| CPU_ARCHITECTURE=amd64 | |
| GPU_BUILD=false | |
| tags: ${{ steps.meta_hub.outputs.tags }} | |
| labels: ${{ steps.meta_hub.outputs.labels }} | |
| cache-from: type=gha,scope=hub-amd64 | |
| cache-to: type=gha,mode=max,scope=hub-amd64 | |
| provenance: false | |
| push: true | |
| - name: Build & push singleuser (amd64) | |
| id: su | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile_singleuser | |
| platforms: linux/amd64 | |
| build-args: | | |
| CPU_ARCHITECTURE=amd64 | |
| GPU_BUILD=false | |
| tags: ${{ steps.meta_su.outputs.tags }} | |
| labels: ${{ steps.meta_su.outputs.labels }} | |
| cache-from: type=gha,scope=singleuser-amd64 | |
| cache-to: type=gha,mode=max,scope=singleuser-amd64 | |
| provenance: false | |
| push: true | |
| # ---------- ARM64 ---------- | |
| build-arm64: | |
| runs-on: ubuntu-22.04-arm | |
| if: ${{ github.event_name != 'pull_request' }} | |
| outputs: | |
| hub_digest: ${{ steps.hub.outputs.digest }} | |
| su_digest: ${{ steps.su.outputs.digest }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: { submodules: recursive, fetch-depth: 0 } | |
| - uses: docker/setup-buildx-action@v3 | |
| - name: Docker meta (hub) | |
| id: meta_hub | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: cogstacksystems/jupyter-hub | |
| tags: | | |
| # vX.Y.Z -> X.Y.Z and X.Y (strip "v") | |
| type=semver,pattern={{version}},prefix=v | |
| type=semver,pattern={{major}}.{{minor}},prefix=v | |
| # latest on main AND on v-tags | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} | |
| # branches (non-PR) | |
| type=ref,event=branch,enable=${{ github.event_name != 'pull_request' }} | |
| # short sha | |
| type=sha,format=short | |
| - name: Docker meta (singleuser) | |
| id: meta_su | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: cogstacksystems/jupyter-singleuser | |
| tags: | | |
| # vX.Y.Z -> X.Y.Z and X.Y (strip "v") | |
| type=semver,pattern={{version}},prefix=v | |
| type=semver,pattern={{major}}.{{minor}},prefix=v | |
| # latest on main AND on v-tags | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} | |
| # branches (non-PR) | |
| type=ref,event=branch,enable=${{ github.event_name != 'pull_request' }} | |
| # short sha | |
| type=sha,format=short | |
| - uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - name: Build & push hub (arm64) | |
| id: hub | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile_hub | |
| platforms: linux/arm64 | |
| build-args: | | |
| CPU_ARCHITECTURE=arm64 | |
| GPU_BUILD=false | |
| tags: ${{ steps.meta_hub.outputs.tags }} | |
| labels: ${{ steps.meta_hub.outputs.labels }} | |
| cache-from: type=gha,scope=hub-arm64 | |
| cache-to: type=gha,mode=max,scope=hub-arm64 | |
| provenance: false | |
| push: true | |
| - name: Build & push singleuser (arm64) | |
| id: su | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile_singleuser | |
| platforms: linux/arm64 | |
| build-args: | | |
| CPU_ARCHITECTURE=arm64 | |
| GPU_BUILD=false | |
| tags: ${{ steps.meta_su.outputs.tags }} | |
| labels: ${{ steps.meta_su.outputs.labels }} | |
| cache-from: type=gha,scope=singleuser-arm64 | |
| cache-to: type=gha,mode=max,scope=singleuser-arm64 | |
| provenance: false | |
| push: true | |
| # ---------- GPU (unchanged, amd64-only) ---------- | |
| build-gpu: | |
| runs-on: ubuntu-22.04 | |
| if: ${{ github.event_name != 'pull_request' }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: { submodules: recursive, fetch-depth: 0 } | |
| - uses: docker/setup-buildx-action@v3 | |
| - name: Docker meta (singleuser-gpu) | |
| id: meta_gpu | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: cogstacksystems/jupyter-singleuser-gpu | |
| tags: | | |
| # vX.Y.Z -> X.Y.Z and X.Y (strip "v") | |
| type=semver,pattern={{version}},prefix=v | |
| type=semver,pattern={{major}}.{{minor}},prefix=v | |
| # latest on main AND on v-tags | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} | |
| # branches (non-PR) | |
| type=ref,event=branch,enable=${{ github.event_name != 'pull_request' }} | |
| # short sha | |
| type=sha,format=short | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android | |
| sudo apt-get clean | |
| docker system prune -af --volumes || true | |
| - uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - name: Build & push singleuser GPU (amd64) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile_singleuser | |
| platforms: linux/amd64 | |
| build-args: | | |
| CPU_ARCHITECTURE=amd64 | |
| GPU_BUILD=true | |
| tags: ${{ steps.meta_gpu.outputs.tags }} | |
| labels: ${{ steps.meta_gpu.outputs.labels }} | |
| cache-from: type=gha,scope=singleuser-gpu-amd64 | |
| cache-to: type=gha,mode=max,scope=singleuser-gpu-amd64 | |
| provenance: false | |
| push: true | |
| manifest: | |
| runs-on: ubuntu-22.04 | |
| if: ${{ github.event_name != 'pull_request' }} | |
| needs: [build-amd64, build-arm64] | |
| steps: | |
| - uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| # Recompute tags (must match both builds) | |
| - name: Docker meta (hub) | |
| id: meta_hub | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: cogstacksystems/jupyter-hub | |
| tags: | | |
| # vX.Y.Z -> X.Y.Z and X.Y (strip "v") | |
| type=semver,pattern={{version}},prefix=v | |
| type=semver,pattern={{major}}.{{minor}},prefix=v | |
| # latest on main AND on v-tags | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} | |
| # branches (non-PR) | |
| type=ref,event=branch,enable=${{ github.event_name != 'pull_request' }} | |
| # short sha | |
| type=sha,format=short | |
| - name: Docker meta (singleuser) | |
| id: meta_su | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: cogstacksystems/jupyter-singleuser | |
| tags: | | |
| # vX.Y.Z -> X.Y.Z and X.Y (strip "v") | |
| type=semver,pattern={{version}},prefix=v | |
| type=semver,pattern={{major}}.{{minor}},prefix=v | |
| # latest on main AND on v-tags | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} | |
| # branches (non-PR) | |
| type=ref,event=branch,enable=${{ github.event_name != 'pull_request' }} | |
| # short sha | |
| type=sha,format=short | |
| - name: Create hub multi-arch manifests | |
| shell: bash | |
| env: | |
| AMD64: ${{ needs.build-amd64.outputs.hub_digest }} | |
| ARM64: ${{ needs.build-arm64.outputs.hub_digest }} | |
| run: | | |
| set -euo pipefail | |
| # must have both digests | |
| if [ -z "${AMD64:-}" ] || [ -z "${ARM64:-}" ]; then | |
| echo "Missing hub digests (amd64='${AMD64:-}', arm64='${ARM64:-}')." | |
| exit 1 | |
| fi | |
| while IFS= read -r ref; do | |
| [[ -z "$ref" ]] && continue | |
| img="${ref%%:*}" | |
| tag="${ref#*:}" | |
| # normalize: if tag starts with 'v', strip it (v2.0.9 -> 2.0.9) | |
| if [[ "$tag" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then | |
| echo "normalize: $img:$tag -> $img:${tag#v}" | |
| tag="${tag#v}" | |
| fi | |
| echo "⛵ ${img}:${tag}" | |
| docker buildx imagetools create \ | |
| --tag "${img}:${tag}" \ | |
| "${img}@${AMD64}" \ | |
| "${img}@${ARM64}" | |
| done < <(printf "%s" "${{ steps.meta_hub.outputs.tags }}") | |
| - name: Create singleuser multi-arch manifests | |
| shell: bash | |
| env: | |
| AMD64: ${{ needs.build-amd64.outputs.su_digest }} | |
| ARM64: ${{ needs.build-arm64.outputs.su_digest }} | |
| run: | | |
| set -euo pipefail | |
| # must have both digests | |
| if [ -z "${AMD64:-}" ] || [ -z "${ARM64:-}" ]; then | |
| echo "Missing singleuser digests (amd64='${AMD64:-}', arm64='${ARM64:-}')." | |
| exit 1 | |
| fi | |
| # stitch each tag from the singleuser meta | |
| while IFS= read -r ref; do | |
| [[ -z "$ref" ]] && continue | |
| img="${ref%%:*}" | |
| tag="${ref#*:}" | |
| # normalize: if tag starts with 'v', strip it (v2.0.9 -> 2.0.9) | |
| if [[ "$tag" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then | |
| echo "normalize: $img:$tag -> $img:${tag#v}" | |
| tag="${tag#v}" | |
| fi | |
| echo "⛵ ${img}:${tag}" | |
| docker buildx imagetools create \ | |
| --tag "${img}:${tag}" \ | |
| "${img}@${AMD64}" \ | |
| "${img}@${ARM64}" | |
| done < <(printf "%s" "${{ steps.meta_su.outputs.tags }}") |