From e5edd6fe920d98f2c46fe5f720ece6a1f49a98e0 Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Sat, 2 Nov 2024 02:10:03 +0000 Subject: [PATCH 1/7] feat(#128) Add arm builds for multi arch support --- .github/workflows/build.yml | 106 ++++++--------------------- Makefile | 8 ++ bakefile.hcl | 142 ++++++++++++++++++++++++++++++++++++ notebook/Dockerfile | 2 +- 4 files changed, 175 insertions(+), 83 deletions(-) create mode 100644 Makefile create mode 100644 bakefile.hcl diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e4503a5..3e834d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,20 +16,6 @@ jobs: release: "2024.9.1" defaultpython: "3.10" - strategy: - fail-fast: false - matrix: - python: ["3.10", "3.11", "3.12"] - image: - - tag: "daskdev/dask" - context: "./base" - - tag: "ghcr.io/dask/dask" - context: "./base" - - tag: "daskdev/dask-notebook" - context: "./notebook" - - tag: "ghcr.io/dask/dask-notebook" - context: "./notebook" - steps: - name: Checkout uses: actions/checkout@v2 @@ -42,83 +28,39 @@ jobs: with: driver: docker - - name: Install Container Canary - run: | - LATEST_RELEASE=$(curl --retry 6 --retry-delay 10 -s https://api.github.com/repos/NVIDIA/container-canary/releases/latest | jq -r ".assets[] | select(.name | test(\"canary_linux_amd64$\")) | .browser_download_url") - curl --retry 6 --retry-delay 10 -sSL $LATEST_RELEASE > /usr/local/bin/canary - chmod +x /usr/local/bin/canary - canary version + #- name: Install Container Canary + # run: | + # LATEST_RELEASE=$(curl --retry 6 --retry-delay 10 -s https://api.github.com/repos/NVIDIA/container-canary/releases/latest | jq -r ".assets[] | select(.name | test(\"canary_linux_amd64$\")) | .browser_download_url") + # curl --retry 6 --retry-delay 10 -sSL $LATEST_RELEASE > /usr/local/bin/canary + # chmod +x /usr/local/bin/canary + # canary version - - name: Login to DockerHub - uses: docker/login-action@v1 - if: github.repository == 'dask/dask-docker' && github.event_name == 'push' - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + #- name: Login to DockerHub + # uses: docker/login-action@v1 + # if: github.repository == 'dask/dask-docker' && github.event_name == 'push' + # with: + # username: ${{ secrets.DOCKERHUB_USERNAME }} + # password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry uses: docker/login-action@v1 - if: github.repository == 'dask/dask-docker' && github.event_name == 'push' + # if: github.repository == 'dask/dask-docker' && github.event_name == 'push' with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Generate tags - id: tags - env: - image: ${{ matrix.image.tag }} - python: ${{ matrix.python }} - stable: ${{ startsWith(github.ref, 'refs/tags') }} - run: | - if [ "$stable" == "true" ]; then - tag="${image}:${release}-py${python}" - tags=${image}:latest-py${python},$tag - if [ "$python" == "$defaultpython" ]; then - tags=${image}:latest,${image}:${release},$tags - fi - else - tag="${image}:dev-py${python}" - tags=$tag - if [ "$python" == "$defaultpython" ]; then - tags=${image}:dev,$tags - fi - fi - - echo "tags=${tags}" >> $GITHUB_OUTPUT - echo "tag=${tag}" >> $GITHUB_OUTPUT - - - name: Checkout upstream Jupyter Lab image repo - uses: actions/checkout@v2 - if: contains(matrix.image.tag, 'dask-notebook') - with: - repository: jupyter/docker-stacks - ref: main - path: docker-stacks - - - name: Build upstream Jupyter Lab image - uses: docker/build-push-action@v2 - if: contains(matrix.image.tag, 'dask-notebook') - with: - context: ./docker-stacks/images/docker-stacks-foundation - push: false - load: true - platforms: linux/amd64 - tags: daskdev/docker-stacks-foundation:lab - build-args: | - PYTHON_VERSION=${{ matrix.python }} - - name: Build and push - uses: docker/build-push-action@v2 + uses: docker/bake-action@v4 with: - context: ${{ matrix.image.context }} - push: ${{ github.repository == 'dask/dask-docker' && github.event_name == 'push' }} - platforms: linux/amd64 - tags: ${{ steps.tags.outputs.tags }} - build-args: | - python=${{ matrix.python }} - release=${{ env.release }} - base=daskdev + push: true + targets: dask + files: bakefile.hcl + env: + STABLE: ${{ startsWith(github.ref, 'refs/tags') }} + RELEASE: ${{ env.release }} + DEFAULT_PY_VERSION: ${{ env.defaultpython }} + - name: Validate Jupyter Lab image for Binder if: contains(matrix.image.tag, 'dask-notebook') @@ -128,5 +70,5 @@ jobs: if: contains(matrix.image.tag, 'dask-notebook') run: canary validate --file https://github.com/NVIDIA/container-canary/raw/main/examples/kubeflow.yaml ${{ steps.tags.outputs.tag }} - - name: Report - run: echo Built ${{ steps.tags.outputs.tags }} + #- name: Report + # run: echo Built ${{ steps.tags.outputs.tags }} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..459a0a0 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ + +build-docker: + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + docker buildx create --name dask-builder || true + docker buildx bake --file bakefile.hcl --builder=dask-builder dask + +print-docker: + docker buildx bake --file bakefile.hcl dask --print \ No newline at end of file diff --git a/bakefile.hcl b/bakefile.hcl new file mode 100644 index 0000000..26081ac --- /dev/null +++ b/bakefile.hcl @@ -0,0 +1,142 @@ +variable "GH_REGISTRY" { + #default = "ghcr.io/dask" + default = "ghcr.io/ryanolee" +} + +variable "DOCKER_HUB_REGISTRY" { + #default = "daskdev" +} + +variable "RELEASE" { + default = "2024.9.1" +} + +variable "STABLE" { + default = "true" +} + +variable "DEFAULT_PY_VERSION" { + default = "3.10" +} + +function "tags" { + params = [ + image, + label + ] + result = [ + "${GH_REGISTRY}/${image}:${label}", + #"${DOCKER_HUB_REGISTRY}/${image}:${label}" + ] +} + +function "tag_stable" { + params = [ + image, + release, + py_version + ] + result = concat( + tags(image, "${release}-py${py_version}"), + tags(image, "latest-py${py_version}"), + equal(py_version, DEFAULT_PY_VERSION) ? tags(image, "latest") : [], + equal(py_version, DEFAULT_PY_VERSION) ? tags(image, release) : [] + ) +} + +function "tag_dev" { + params = [ + image, + py_version + ] + result = concat( + tags(image, "dev-py${py_version}"), + equal(py_version, DEFAULT_PY_VERSION) ? tags(image, "dev") : [] + ) +} + +function "tag" { + params = [ + image, + release, + py_version + ] + result = equal(STABLE, "true") ? tag_stable(image, release, py_version) : tag_dev(image, py_version) +} + +group "dask" { + targets = ["base", "notebook"] +} + +target "base" { + context = "./base" + dockerfile = "Dockerfile" + platforms = ["linux/amd64", "linux/arm64"] + matrix = { + py_version = ["3.10", "3.11", "3.12"] + } + args = { + python = py_version + release = RELEASE + } + + name = "dask-${replace(py_version, ".", "")}" + tags = tag( + "dask", + RELEASE, + py_version + ) +} + +target "notebook-base" { + context = "https://github.com/jupyter/docker-stacks.git#main:images/docker-stacks-foundation" + dockerfile = "Dockerfile" + platforms = ["linux/amd64", "linux/arm64"] + matrix = { + py_version = ["3.12"] + } + args = { + PYTHON_VERSION = py_version + } + name = "notebook-base-${replace(py_version, ".", "")}" +} + +# Pre 311 builds do not work due to https://github.com/jupyter/docker-stacks/issues/2146#issuecomment-2382315848 +# patch works for now. This can be collapsed into "notebook-base" once a fix has been released +target "notebook-base-pre-311" { + context = "https://github.com/jupyter/docker-stacks.git#5365b9f79fa4ffbb20f10133cc6ac5bec5046302:images/docker-stacks-foundation" + dockerfile = "Dockerfile" + platforms = ["linux/amd64", "linux/arm64"] + matrix = { + py_version = ["3.10", "3.11"] + } + args = { + PYTHON_VERSION = py_version + } + name = "notebook-base-${replace(py_version, ".", "")}" +} + +target "notebook" { + context = "./notebook" + dockerfile = "Dockerfile" + platforms = ["linux/amd64", "linux/arm64"] + matrix = { + py_version = ["3.12", "3.11", "3.10"] + } + args = { + python = py_version + release = RELEASE + base = "baseapp" + } + + contexts = { + baseapp = "target:notebook-base-${replace(py_version, ".", "")}" + } + + name = "dask-${replace(py_version, ".", "")}" + tags = tag( + "dask-notebook", + RELEASE, + py_version + ) +} diff --git a/notebook/Dockerfile b/notebook/Dockerfile index f9cfb26..4802de1 100644 --- a/notebook/Dockerfile +++ b/notebook/Dockerfile @@ -1,6 +1,6 @@ ARG base -FROM $base/docker-stacks-foundation:lab +FROM $base ARG release ARG python From 09bba987f31d88498b9727e6640a7c1a4d17e8e2 Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Sat, 2 Nov 2024 02:13:49 +0000 Subject: [PATCH 2/7] feat(#128): Update buildx action --- .github/workflows/build.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3e834d0..0c1cfee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,11 +22,9 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - with: - driver: docker + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 #- name: Install Container Canary # run: | From 1aa99c24c0796fb4ccef772062d148d0e92999e5 Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Sat, 2 Nov 2024 02:40:00 +0000 Subject: [PATCH 3/7] feat(#128): Fix build targets --- bakefile.hcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bakefile.hcl b/bakefile.hcl index 26081ac..fb55d45 100644 --- a/bakefile.hcl +++ b/bakefile.hcl @@ -133,7 +133,7 @@ target "notebook" { baseapp = "target:notebook-base-${replace(py_version, ".", "")}" } - name = "dask-${replace(py_version, ".", "")}" + name = "dask-notebook-${replace(py_version, ".", "")}" tags = tag( "dask-notebook", RELEASE, From f82d231e95b4886b93dc1104815a36312353f708 Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Sat, 2 Nov 2024 14:28:16 +0000 Subject: [PATCH 4/7] feat(#128): Patch base file for quemu support --- base/Dockerfile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/base/Dockerfile b/base/Dockerfile index 55416d5..98bd9b6 100644 --- a/base/Dockerfile +++ b/base/Dockerfile @@ -10,14 +10,15 @@ ENV PATH /opt/conda/bin:$PATH ENV PYTHON_VERSION=${python} ENV DASK_VERSION=${release} -RUN mamba install -y \ - "mamba>=0.27.0" \ - python=${PYTHON_VERSION} \ - nomkl \ - cmake \ - dask=${DASK_VERSION} \ - cachey \ - streamz \ +RUN export G_SLICE=always-malloc \ + && mamba install -y \ + "mamba>=0.27.0" \ + python=${PYTHON_VERSION} \ + nomkl \ + cmake \ + dask=${DASK_VERSION} \ + cachey \ + streamz \ && mamba clean -tipy \ && find /opt/conda/ -type f,l -name '*.a' -delete \ && find /opt/conda/ -type f,l -name '*.pyc' -delete \ From 8fed99025910b5eb1a96e35b65b5f68c7f1c1a12 Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Sat, 2 Nov 2024 15:52:27 +0000 Subject: [PATCH 5/7] feat(#128) Apply fix to both --- notebook/Dockerfile | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/notebook/Dockerfile b/notebook/Dockerfile index 4802de1..3fbfcd5 100644 --- a/notebook/Dockerfile +++ b/notebook/Dockerfile @@ -27,19 +27,20 @@ RUN MAGICARCH=$(dpkg --print-architecture) && \ USER $NB_USER -RUN mamba install -y \ - python=${PYTHON_VERSION} \ - nomkl \ - cytoolz \ - dask==${DASK_VERSION} \ - lz4 \ - numpy \ - pandas \ - ipywidgets \ - cachey \ - streamz \ - jupyterlab \ - "dask-labextension>=5" \ +RUN export G_SLICE=always-malloc \ + && mamba install -y \ + python=${PYTHON_VERSION} \ + nomkl \ + cytoolz \ + dask==${DASK_VERSION} \ + lz4 \ + numpy \ + pandas \ + ipywidgets \ + cachey \ + streamz \ + jupyterlab \ + "dask-labextension>=5" \ && mamba clean -tipy \ && jupyter lab clean \ && find /opt/conda/ -type f,l -name '*.a' -delete \ From 05bd4208655052cbdf15ac865836e73133155dd6 Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Sun, 3 Nov 2024 23:23:37 +0000 Subject: [PATCH 6/7] feat(#128) Fix issues with syntax --- notebook/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebook/Dockerfile b/notebook/Dockerfile index 3fbfcd5..f6bc131 100644 --- a/notebook/Dockerfile +++ b/notebook/Dockerfile @@ -82,4 +82,4 @@ HEALTHCHECK --interval=15s --timeout=3s --start-period=5s --retries=3 \ USER $NB_USER ENTRYPOINT ["tini", "--", "/usr/bin/prepare.sh"] -CMD ["jupyter", "lab", '--NotebookApp.base_url="${NB_PREFIX:-/}"', '${JUPYTERLAB_ARGS}'] +CMD jupyter lab --NotebookApp.base_url="${NB_PREFIX:-/}" ${JUPYTERLAB_ARGS} From b38e3e05f366c7862910b8c6d61efd2651f2114c Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Sat, 16 Nov 2024 01:43:30 +0000 Subject: [PATCH 7/7] chore(#128) Revert problematic changes from #290 --- notebook/Dockerfile | 1 - notebook/prepare.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/notebook/Dockerfile b/notebook/Dockerfile index f6bc131..cd135d1 100644 --- a/notebook/Dockerfile +++ b/notebook/Dockerfile @@ -82,4 +82,3 @@ HEALTHCHECK --interval=15s --timeout=3s --start-period=5s --retries=3 \ USER $NB_USER ENTRYPOINT ["tini", "--", "/usr/bin/prepare.sh"] -CMD jupyter lab --NotebookApp.base_url="${NB_PREFIX:-/}" ${JUPYTERLAB_ARGS} diff --git a/notebook/prepare.sh b/notebook/prepare.sh index a286dd5..c7a3247 100755 --- a/notebook/prepare.sh +++ b/notebook/prepare.sh @@ -35,4 +35,4 @@ fi # Execute the jupyterlab as specified. -exec start.sh $@ +exec start.sh jupyter lab --NotebookApp.base_url="${NB_PREFIX:-/}" ${JUPYTERLAB_ARGS}