diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index e0e27db..19b8415 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -14,7 +14,9 @@ on: env: # Use docker.io for Docker Hub if empty REGISTRY: ghcr.io + JAX_VERSION : 0.4.23 # github.repository as / + JAX_CONDA_IMAGE_NAME : "yfukai/conda-jax" IMAGE_NAME: ${{ github.repository }} @@ -36,7 +38,7 @@ jobs: # Install the cosign tool except on PR # https://github.com/sigstore/cosign-installer - name: Install Cosign - if: github.event_name != 'pull_request' +# if: github.event_name != 'pull_request' uses: sigstore/cosign-installer@v3.1.1 with: cosign-release: 'v2.2.1' @@ -48,7 +50,7 @@ jobs: # Login against a Docker registry except on PR # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' +# if: github.event_name != 'pull_request' uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c with: registry: ${{ env.REGISTRY }} @@ -57,12 +59,19 @@ jobs: # Extract metadata (tags, labels) for Docker # https://github.com/docker/metadata-action + - name: Extract Docker metadata (JAX conda) + id: meta_jax_conda + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Extract Docker metadata id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Get the tag name run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV @@ -71,12 +80,52 @@ jobs: # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - - name: Build and push Docker image - id: build-and-push + - name: Build and push Docker image (JAX conda CPU) + id: build-and-push-jax-conda-cpu + uses: docker/build-push-action@v5 + with: + context: jax_image/ + platforms: linux/amd64,linux/arm64/v8 + push: true #${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta_jax_conda.outputs.tags }} + labels: ${{ steps.meta_jax_conda.outputs.labels }} + build-args: | + JAX_VERSION=${{ env.JAX_version }} + + - name: Build and push Docker image (JAX conda GPU) + id: build-and-push-jax-conda-gpu + uses: docker/build-push-action@v5 + with: + context: jax_image/ + platforms: linux/amd64 + push: true #${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta_jax_conda.outputs.tags }}-cuda + labels: ${{ steps.meta_jax_conda.outputs.labels }} + build-args: | + JAX_VERSION=${{ env.JAX_version }} + JAX_VERSION_EXTRA="cuda11_local" + BASE_IMAGE="nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04" + + - name: Build and push Docker image (CPU) + id: build-and-push-cpu uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64/v8 - push: ${{ github.event_name != 'pull_request' }} + push: true # ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + BASE_IMAGE="${{ env.REGISTRY }}/${{ env.JAX_CONDA_IMAGE_NAME }}:latest" + + - name: Build and push Docker image (GPU) + id: build-and-push-gpu + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64 + push: true #${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }}-cuda + labels: ${{ steps.meta.outputs.labels }} + build-args: | + BASE_IMAGE="${{ env.REGISTRY }}/${{ env.JAX_CONDA_IMAGE_NAME }}:latest-cuda" diff --git a/.github/workflows/jax-conda-docker-publish.yml b/.github/workflows/jax-conda-docker-publish.yml new file mode 100644 index 0000000..66034d6 --- /dev/null +++ b/.github/workflows/jax-conda-docker-publish.yml @@ -0,0 +1,128 @@ +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + release: + types: [ "published" ] + pull_request: + branches: [ "main" ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + JAX_VERSION : 0.4.23 + # github.repository as / + JAX_CONDA_IMAGE_NAME : "yfukai/conda-jax" + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + strategy: + matrix: + target: ["cpu", "gpu"] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Install the cosign tool except on PR + # https://github.com/sigstore/cosign-installer + - name: Install Cosign + if: github.event_name != 'pull_request' + uses: sigstore/cosign-installer@v3.1.1 + with: + cosign-release: 'v2.2.1' + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Get the tag name + run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image (JAX conda CPU) + id: build-and-push-jax-conda-cpu + uses: docker/build-push-action@v5 + with: + context: jax_image/ + platforms: linux/amd64,linux/arm64/v8 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + JAX_VERSION=${{ env.JAX_version }} + + - name: Build and push Docker image (JAX conda GPU) + id: build-and-push-jax-conda-gpu + uses: docker/build-push-action@v5 + with: + context: jax_image/ + platforms: linux/amd64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + JAX_VERSION=${{ env.JAX_version }} + JAX_VERSION_EXTRA="cuda11_local" + BASE_IMAGE="nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04" + + - name: Build and push Docker image (CPU) + id: build-and-push-cpu + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64/v8 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + BASE_IMAGE="${{ env.REGISTRY }}/yfukai/conda-jax:latest" + + - name: Build and push Docker image (GPU) + id: build-and-push-gpu + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + BASE_IMAGE="${{ env.REGISTRY }}/yfukai/conda-jax:latest-cuda" diff --git a/Dockerfile b/Dockerfile index 59a70f5..2752223 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG BASE_IMAGE="yfukai/conda-jax:latest" +ARG BASE_IMAGE="ghcr.io/yfukai/conda-jax:latest" FROM ${BASE_IMAGE} #https://stackoverflow.com/questions/44438637/arg-substitution-in-run-command-not-working-for-dockerfile diff --git a/jax_image/build.sh b/jax_image/build.sh index 94e226d..648fb23 100755 --- a/jax_image/build.sh +++ b/jax_image/build.sh @@ -12,8 +12,9 @@ docker buildx build \ docker buildx build \ --push \ --platform linux/amd64 \ + --build-arg BASE_IMAGE="nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04" \ --build-arg JAX_VERSION="$JAX_VERSION" \ - --build-arg JAX_VERSION_EXTRA="cuda12_pip" \ + --build-arg JAX_VERSION_EXTRA="cuda11_local" \ -t yfukai/conda-jax:$JAX_VERSION-cuda \ -t yfukai/conda-jax:latest-cuda \ "."