From ac64aa7ea763c978bc23552367e5f2ee81b59515 Mon Sep 17 00:00:00 2001 From: Prabhakar Kumar Date: Wed, 6 Dec 2023 09:21:08 +0000 Subject: [PATCH] Introducing support for R2023b. Default OS updated to ubuntu22.04. Dockerfiles for ubuntu20.04 are moved to a new sub-folder. --- .../build-and-push-notebook/action.yml | 22 --- .github/workflows/README.md | 57 +++++++ .../build-and-publish-docker-image.yml | 98 ++++++++++++ .../build-and-publish-dockerfiles.yml | 69 -------- .github/workflows/matlab-byoi-dockerfile.yml | 33 ++++ .github/workflows/matlab-dockerfile.yml | 33 ++++ .../workflows/matlab-mounted-dockerfile.yml | 33 ++++ .../matlab-ubuntu20.04-byoi-dockerfile.yml | 33 ++++ .../matlab-ubuntu20.04-dockerfile.yml | 33 ++++ .../matlab-ubuntu20.04-mounted-dockerfile.yml | 33 ++++ .../matlab-ubuntu20.04-vnc-dockerfile.yml | 33 ++++ ...lab-ubuntu20.04-vnc-mounted-dockerfile.yml | 33 ++++ .github/workflows/matlab-vnc-dockerfile.yml | 33 ++++ .../matlab-vnc-mounted-dockerfile.yml | 33 ++++ matlab-vnc/Dockerfile | 64 +++++--- matlab-vnc/Dockerfile.mounted | 56 ++++--- matlab-vnc/ubuntu20.04/Dockerfile | 141 ++++++++++++++++ matlab-vnc/ubuntu20.04/Dockerfile.mounted | 129 +++++++++++++++ matlab/Dockerfile | 67 ++++---- matlab/Dockerfile.byoi | 75 +++++---- matlab/Dockerfile.mounted | 64 ++++---- matlab/Dockerfile.ubuntu-22.04 | 102 ------------ matlab/README-byoi.md | 21 ++- matlab/README-mounted.md | 17 +- matlab/README.md | 23 ++- matlab/ubuntu20.04/Dockerfile | 128 +++++++++++++++ matlab/ubuntu20.04/Dockerfile.byoi | 150 ++++++++++++++++++ matlab/ubuntu20.04/Dockerfile.mounted | 111 +++++++++++++ 28 files changed, 1378 insertions(+), 346 deletions(-) delete mode 100644 .github/actions/build-and-push-notebook/action.yml create mode 100644 .github/workflows/README.md create mode 100644 .github/workflows/build-and-publish-docker-image.yml delete mode 100644 .github/workflows/build-and-publish-dockerfiles.yml create mode 100644 .github/workflows/matlab-byoi-dockerfile.yml create mode 100644 .github/workflows/matlab-dockerfile.yml create mode 100644 .github/workflows/matlab-mounted-dockerfile.yml create mode 100644 .github/workflows/matlab-ubuntu20.04-byoi-dockerfile.yml create mode 100644 .github/workflows/matlab-ubuntu20.04-dockerfile.yml create mode 100644 .github/workflows/matlab-ubuntu20.04-mounted-dockerfile.yml create mode 100644 .github/workflows/matlab-ubuntu20.04-vnc-dockerfile.yml create mode 100644 .github/workflows/matlab-ubuntu20.04-vnc-mounted-dockerfile.yml create mode 100644 .github/workflows/matlab-vnc-dockerfile.yml create mode 100644 .github/workflows/matlab-vnc-mounted-dockerfile.yml create mode 100644 matlab-vnc/ubuntu20.04/Dockerfile create mode 100644 matlab-vnc/ubuntu20.04/Dockerfile.mounted delete mode 100644 matlab/Dockerfile.ubuntu-22.04 create mode 100644 matlab/ubuntu20.04/Dockerfile create mode 100644 matlab/ubuntu20.04/Dockerfile.byoi create mode 100644 matlab/ubuntu20.04/Dockerfile.mounted diff --git a/.github/actions/build-and-push-notebook/action.yml b/.github/actions/build-and-push-notebook/action.yml deleted file mode 100644 index 5f7b181..0000000 --- a/.github/actions/build-and-push-notebook/action.yml +++ /dev/null @@ -1,22 +0,0 @@ -runs: - using: "composite" - steps: - - uses: actions/checkout@v2 - - - uses: docker/setup-buildx-action@v1 - - - uses: docker/login-action@v1 - with: - registry: ${{ inputs.registry }} - username: ${{ github.repository_owner }} - password: ${{ inputs.github_token }} - - - uses: docker/build-push-action@v2 - with: - context: ${{ inputs.context }} - platforms: linux/amd64 - file: ${{ inputs.dockerfile }} - tags: ${{ inputs.registry }}/${{ inputs.github_repo }}/${{ inputs.image }}:${{ inputs.matlab_release }} - build-args: MATLAB_RELEASE=${{ inputs.matlab_release }} - push: true - diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 0000000..7028cac --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,57 @@ +# Workflows in matlab-integration-for-jupyter + +This repository uses workflows to build the Dockerfiles hosted in this repository and publish them to GHCR. + +## Overview + +There are 2 kinds of YML files used here: +1. `build-and-publish-docker-image.yml`, which specifies a reusable workflow, which MUST be called from a workflow configuration file. +2. Other YML files in the `.github/workflows` directory call this reusable-workflow. + +Each of these workflows: + a. Monitors a specific Dockerfile. For example, the file `matlab-ubuntu20.04-mounted-dockerfile.yml` monitors the Dockerfile `matlab/ubuntu20.04/Dockerfile.mounted` + b. Is triggered when changes are made to the Dockerfile it monitors. This should build and publish to the configured registries. + +## Triggers and Scheduled Jobs + +All workflows are scheduled to run on Monday at 00:00. +Workflows are also triggered when you push any changes to the directories with Dockerfiles. +Workflows can be manually triggered from the "Actions" tab. + +## Directory structure + +The matlab-integration-for-jupyter repository has the following folder structure: + +1. matlab : Hosts the Dockerfile that showcase access to matlab through the `jupyter-matlab-proxy` package. + * matlab/ubuntu20.04 : Hosts the same dockerfiles but with support for `ubuntu20.04` +1. matlab-vnc : Hosts the Dockerfile that showcase access to matlab through the `jupyter-matlab-vnc-proxy` package. + * matlab-vnc/ubuntu20.04 : Hosts the same dockerfiles but with support for `ubuntu20.04` + +## Images Pushed to GHCR: + +| Name of Dockerfile | Name of Image Pushed | Tags Available | +|----|----|----| +|matlab/Dockerfile | jupyter-matlab-notebook | r2023b, r2023a, r2022b, r2023b-ubuntu22.04, r2023a-ubuntu22.04, r2022b-ubuntu22.04 | +|matlab/Dockerfile.byoi | jupyter-byoi-matlab-notebook | r2023b, r2023a, r2022b, r2023b-ubuntu22.04, r2023a-ubuntu22.04, r2022b-ubuntu22.04 | +|matlab/Dockerfile.mounted | jupyter-mounted-matlab-notebook | r2023b, r2023a, r2022b, r2023b-ubuntu22.04, r2023a-ubuntu22.04, r2022b-ubuntu22.04 | +|matlab/ubuntu20.04/Dockerfile | jupyter-matlab-notebook | r2023b-ubuntu20.04, r2023a-ubuntu20.04, r2020b-ubuntu20.04, r2020a-ubuntu20.04, r2021b-ubuntu20.04, r2021a-ubuntu20.04, r2020b-ubuntu20.04 | +|matlab/ubuntu20.04/Dockerfile.byoi | jupyter-byoi-matlab-notebook | r2023b-ubuntu20.04, r2023a-ubuntu20.04, r2020b-ubuntu20.04, r2020a-ubuntu20.04, r2021b-ubuntu20.04, r2021a-ubuntu20.04, r2020b-ubuntu20.04 | +|matlab/ubuntu20.04/Dockerfile.mounted | jupyter-mounted-matlab-notebook |r2023b-ubuntu20.04, r2023a-ubuntu20.04, r2020b-ubuntu20.04, r2020a-ubuntu20.04, r2021b-ubuntu20.04, r2021a-ubuntu20.04, r2020b-ubuntu20.04 | +|matlab-vnc/Dockerfile | jupyter-matlab-vnc-notebook | r2023b, r2023a, r2022b, r2023b-ubuntu22.04, r2023a-ubuntu22.04, r2022b-ubuntu22.04 | +|matlab-vnc/Dockerfile.mounted | jupyter-mounted-matlab-vnc-notebook | r2023b, r2023a, r2022b, r2023b-ubuntu22.04, r2023a-ubuntu22.04, r2022b-ubuntu22.04 | +|matlab-vnc/ubuntu20.04/Dockerfile | jupyter-matlab-vnc-notebook | r2023b-ubuntu20.04, r2023a-ubuntu20.04, r2020b-ubuntu20.04, r2020a-ubuntu20.04, r2021b-ubuntu20.04, r2021a-ubuntu20.04, r2020b-ubuntu20.04 | +|matlab-vnc/ubuntu20.04/Dockerfile.mounted | jupyter-mounted-matlab-vnc-notebook | r2023b-ubuntu20.04, r2023a-ubuntu20.04, r2020b-ubuntu20.04, r2020a-ubuntu20.04, r2021b-ubuntu20.04, r2021a-ubuntu20.04, r2020b-ubuntu20.04 | + +Note: Pascal cased tags are also made available. ie: r2023a-ubuntu20.04 will also have a `R`2023a-ubuntu20.04 + +Each `reusable-workflow` job consists of the following steps: + +1. Check-out the repository into a GitHub Actions runner. +1. Setup Image Tags: Configures tags to have both Pascal & camel case tags (R2023a, r2023a) +1. Login to DockerHub Container Registry +1. Build the image & push +1. If the variable "should_add_latest_tag" is present that an additional "latest" tag is added to the image. + +---- +Copyright 2023 The MathWorks, Inc. +---- diff --git a/.github/workflows/build-and-publish-docker-image.yml b/.github/workflows/build-and-publish-docker-image.yml new file mode 100644 index 0000000..871e43f --- /dev/null +++ b/.github/workflows/build-and-publish-docker-image.yml @@ -0,0 +1,98 @@ +# Copyright 2023 The MathWorks, Inc. + +name: Build and Publish the Container Image + +# images build with this workflow are created with the following naming conventions: + # ${base_image_name}:${matlab_release}-${os} + +# built images are pushed to DockerHub. Note: Both camel & Pascal case versions of tags are generated and published + +# This workflow is only be triggered when called from another workflow. +on: + workflow_call: + inputs: + docker_build_context: + description: 'Relative path to folder with Dockerfile. Ex: ./matlab' + required: true + type: string + base_image_name: + description: 'Fully qualified name of image name' + required: true + type: string + matlab_release_tag: + description: 'Name of matlab release. Example: r2023a' + required: true + type: string + os_info_tag: + description: 'Allowed values: ubuntu20.04 ubuntu22.04' + required: true + type: string + is_default_os: + description: 'If true, then an additional tag without OS information is generated.' + required: true + type: boolean + +jobs: + build-push-image: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name : Setup Image Tags + id: setup_image_tags + run: | + RAW_MATLAB_RELEASE=${{ inputs.matlab_release_tag }} \ + && LOWER_CASE_MATLAB_RELEASE=${RAW_MATLAB_RELEASE,,} \ + && echo "TAG_RELEASE_ONLY_CAMEL_CASE=${LOWER_CASE_MATLAB_RELEASE}" >> "$GITHUB_OUTPUT" \ + && echo "TAG_RELEASE_ONLY_PASCAL_CASE=${LOWER_CASE_MATLAB_RELEASE^}" >> "$GITHUB_OUTPUT" \ + && echo "TAG_RELEASE_AND_OS_CAMEL_CASE=${LOWER_CASE_MATLAB_RELEASE}-${{ inputs.os_info_tag }}" >> "$GITHUB_OUTPUT" \ + && echo "TAG_RELEASE_AND_OS_PASCAL_CASE=${LOWER_CASE_MATLAB_RELEASE^}-${{ inputs.os_info_tag }}" >> "$GITHUB_OUTPUT" + + # See here for example: https://docs.docker.com/build/ci/github-actions/push-multi-registries/ + # - + # name: Login to Docker Hub + # uses: docker/login-action@v2 + # with: + # username: ${{ secrets.DOCKERHUB_USERNAME }} + # password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + # Example tags: r2023a-ubuntu20.04, R2023a-ubuntu20.04 + - name: Build & Push Image + if: ${{ inputs.is_default_os == false }} + uses: docker/build-push-action@v4 + with: + context: ${{ inputs.docker_build_context }} + platforms: linux/amd64 + push: true + tags: | + ${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_CAMEL_CASE }} + ${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_PASCAL_CASE }} + build-args: MATLAB_RELEASE=${{ inputs.matlab_release_tag }} + + # Example tags: r2023a-ubuntu20.04, R2023a-ubuntu20.04, r2023a, R2023a + - name: Build & Push Image for latest OS + if: ${{ inputs.is_default_os == true }} + uses: docker/build-push-action@v4 + with: + context: ${{ inputs.docker_build_context }} + platforms: linux/amd64 + push: true + tags: | + ${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_ONLY_CAMEL_CASE }} + ${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_ONLY_PASCAL_CASE }} + ${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_CAMEL_CASE }} + ${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_PASCAL_CASE }} + build-args: MATLAB_RELEASE=${{ inputs.matlab_release_tag }} + + diff --git a/.github/workflows/build-and-publish-dockerfiles.yml b/.github/workflows/build-and-publish-dockerfiles.yml deleted file mode 100644 index 2f8cfd7..0000000 --- a/.github/workflows/build-and-publish-dockerfiles.yml +++ /dev/null @@ -1,69 +0,0 @@ -# Build & Publish all Dockerfiles in the repository, for pre-defined set of MATLAB version. -name: Build MIFJ Dockerfiles - -# Define when builds will occur: -on: - # Run workflow when there is a push to the 'main' branch & push includes changes to any Dockerfile or YML files - push: - branches: - - 'main' - paths: - - '**Dockerfile*' - - '**.yml' - - # Run workflow when there is a release - release: - types: - - 'created' - - # Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru) - schedule: - - cron: '0 0 * * 1' - -jobs: - docker: - # Each job needs a runner environment - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - matlab_release: [r2023a, r2022b, r2022a, r2021b, r2021a, r2020b] - dockerfile: ["./matlab/Dockerfile", "./matlab/Dockerfile.byoi", "./matlab/Dockerfile.mounted", "./matlab-vnc/Dockerfile", "./matlab-vnc/Dockerfile.mounted"] - include: - - image: "jupyter-matlab-notebook" - dockerfile: "./matlab/Dockerfile" - context: "./matlab" - - # Build ubuntu22.04 only for r2023a - - image: "jupyter-matlab-notebook-ubuntu-2204" - dockerfile: "./matlab/Dockerfile.ubuntu-22.04" - context: "./matlab" - matlab_release: "r2023a" - - - image: "jupyter-byoi-matlab-notebook" - dockerfile: "./matlab/Dockerfile.byoi" - context: "./matlab" - - - image: "jupyter-mounted-matlab-notebook" - dockerfile: "./matlab/Dockerfile.mounted" - context: "./matlab" - - - image: "jupyter-matlab-vnc-notebook" - dockerfile: "./matlab-vnc/Dockerfile" - context: "./matlab-vnc" - - - image: "jupyter-mounted-matlab-vnc-notebook" - dockerfile: "./matlab-vnc/Dockerfile.mounted" - context: "./matlab-vnc" - - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/build-and-push-notebook - with: - dockerfile: ${{ matrix.dockerfile }} - context: ${{ matrix.context }} - matlab_release: ${{ matrix.matlab_release }} - image: ${{ matrix.image }} - registry: ghcr.io - github_token: ${{ secrets.GITHUB_TOKEN }} - github_repo: ${{ github.repository }} \ No newline at end of file diff --git a/.github/workflows/matlab-byoi-dockerfile.yml b/.github/workflows/matlab-byoi-dockerfile.yml new file mode 100644 index 0000000..2c719aa --- /dev/null +++ b/.github/workflows/matlab-byoi-dockerfile.yml @@ -0,0 +1,33 @@ +# Copyright 2023 The MathWorks, Inc. +# Build & Publish matlab/Dockerfile.byoi +name: matlab/Dockerfile.byoi + +# Define when builds will occur: +on: + # Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path + push: + branches: + - 'main' + paths: + - 'matlab/Dockerfile.byoi' + + # Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru) + schedule: + - cron: '0 0 * * 1' + + workflow_dispatch: + +jobs: + build-and-publish-docker-image: + strategy: + fail-fast: false + matrix: + matlab_release_tag: [r2023b, r2023a, r2022b] + uses: ./.github/workflows/build-and-publish-docker-image.yml + secrets: inherit + with: + docker_build_context: './matlab' + base_image_name: ghcr.io/${{ github.repository }}/jupyter-byoi-matlab-notebook + os_info_tag: 'ubuntu22.04' + matlab_release_tag: ${{ matrix.matlab_release_tag }} + is_default_os: true diff --git a/.github/workflows/matlab-dockerfile.yml b/.github/workflows/matlab-dockerfile.yml new file mode 100644 index 0000000..0a09064 --- /dev/null +++ b/.github/workflows/matlab-dockerfile.yml @@ -0,0 +1,33 @@ +# Copyright 2023 The MathWorks, Inc. +# Build & Publish matlab/Dockerfile +name: matlab/Dockerfile + +# Define when builds will occur: +on: + # Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path + push: + branches: + - 'main' + paths: + - 'matlab/Dockerfile' + + # Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru) + schedule: + - cron: '0 0 * * 1' + + workflow_dispatch: + +jobs: + build-and-publish-docker-image: + strategy: + fail-fast: false + matrix: + matlab_release_tag: [r2023b, r2023a, r2022b] + uses: ./.github/workflows/build-and-publish-docker-image.yml + secrets: inherit + with: + docker_build_context: './matlab' + base_image_name: ghcr.io/${{ github.repository }}/jupyter-matlab-notebook + os_info_tag: 'ubuntu22.04' + matlab_release_tag: ${{ matrix.matlab_release_tag }} + is_default_os: true diff --git a/.github/workflows/matlab-mounted-dockerfile.yml b/.github/workflows/matlab-mounted-dockerfile.yml new file mode 100644 index 0000000..81bcbf1 --- /dev/null +++ b/.github/workflows/matlab-mounted-dockerfile.yml @@ -0,0 +1,33 @@ +# Copyright 2023 The MathWorks, Inc. +# Build & Publish matlab/Dockerfile.mounted +name: matlab/Dockerfile.mounted + +# Define when builds will occur: +on: + # Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path + push: + branches: + - 'main' + paths: + - 'matlab/Dockerfile.mounted' + + # Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru) + schedule: + - cron: '0 0 * * 1' + + workflow_dispatch: + +jobs: + build-and-publish-docker-image: + strategy: + fail-fast: false + matrix: + matlab_release_tag: [r2023b, r2023a, r2022b] + uses: ./.github/workflows/build-and-publish-docker-image.yml + secrets: inherit + with: + docker_build_context: './matlab' + base_image_name: ghcr.io/${{ github.repository }}/jupyter-mounted-matlab-notebook + os_info_tag: 'ubuntu22.04' + matlab_release_tag: ${{ matrix.matlab_release_tag }} + is_default_os: true diff --git a/.github/workflows/matlab-ubuntu20.04-byoi-dockerfile.yml b/.github/workflows/matlab-ubuntu20.04-byoi-dockerfile.yml new file mode 100644 index 0000000..ae0e07d --- /dev/null +++ b/.github/workflows/matlab-ubuntu20.04-byoi-dockerfile.yml @@ -0,0 +1,33 @@ +# Copyright 2023 The MathWorks, Inc. +# Build & Publish matlab/ubuntu20.04/Dockerfile.byoi +name: matlab/ubuntu20.04/Dockerfile.byoi + +# Define when builds will occur: +on: + # Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path + push: + branches: + - 'main' + paths: + - 'matlab/ubuntu20.04/Dockerfile.byoi' + + # Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru) + schedule: + - cron: '0 0 * * 1' + + workflow_dispatch: + +jobs: + build-and-publish-docker-image: + strategy: + fail-fast: false + matrix: + matlab_release_tag: [r2023b, r2023a, r2022b, r2022a, r2021b, r2021a, r2020b] + uses: ./.github/workflows/build-and-publish-docker-image.yml + secrets: inherit + with: + docker_build_context: './matlab/ubuntu20.04' + base_image_name: ghcr.io/${{ github.repository }}/jupyter-byoi-matlab-notebook + os_info_tag: 'ubuntu20.04' + matlab_release_tag: ${{ matrix.matlab_release_tag }} + is_default_os: false diff --git a/.github/workflows/matlab-ubuntu20.04-dockerfile.yml b/.github/workflows/matlab-ubuntu20.04-dockerfile.yml new file mode 100644 index 0000000..b25810c --- /dev/null +++ b/.github/workflows/matlab-ubuntu20.04-dockerfile.yml @@ -0,0 +1,33 @@ +# Copyright 2023 The MathWorks, Inc. +# Build & Publish matlab/ubuntu20.04/Dockerfile +name: matlab/ubuntu20.04/Dockerfile + +# Define when builds will occur: +on: + # Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path + push: + branches: + - 'main' + paths: + - 'matlab/ubuntu20.04/Dockerfile' + + # Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru) + schedule: + - cron: '0 0 * * 1' + + workflow_dispatch: + +jobs: + build-and-publish-docker-image: + strategy: + fail-fast: false + matrix: + matlab_release_tag: [r2023b, r2023a, r2022b, r2022a, r2021b, r2021a, r2020b] + uses: ./.github/workflows/build-and-publish-docker-image.yml + secrets: inherit + with: + docker_build_context: './matlab/ubuntu20.04' + base_image_name: ghcr.io/${{ github.repository }}/jupyter-matlab-notebook + os_info_tag: 'ubuntu20.04' + matlab_release_tag: ${{ matrix.matlab_release_tag }} + is_default_os: false diff --git a/.github/workflows/matlab-ubuntu20.04-mounted-dockerfile.yml b/.github/workflows/matlab-ubuntu20.04-mounted-dockerfile.yml new file mode 100644 index 0000000..f878aa7 --- /dev/null +++ b/.github/workflows/matlab-ubuntu20.04-mounted-dockerfile.yml @@ -0,0 +1,33 @@ +# Copyright 2023 The MathWorks, Inc. +# Build & Publish matlab/ubuntu20.04/Dockerfile.mounted +name: matlab/ubuntu20.04/Dockerfile.mounted + +# Define when builds will occur: +on: + # Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path + push: + branches: + - 'main' + paths: + - 'matlab/ubuntu20.04/Dockerfile.mounted' + + # Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru) + schedule: + - cron: '0 0 * * 1' + + workflow_dispatch: + +jobs: + build-and-publish-docker-image: + strategy: + fail-fast: false + matrix: + matlab_release_tag: [r2023b, r2023a, r2022b, r2022a, r2021b, r2021a, r2020b] + uses: ./.github/workflows/build-and-publish-docker-image.yml + secrets: inherit + with: + docker_build_context: './matlab/ubuntu20.04' + base_image_name: ghcr.io/${{ github.repository }}/jupyter-mounted-matlab-notebook + os_info_tag: 'ubuntu20.04' + matlab_release_tag: ${{ matrix.matlab_release_tag }} + is_default_os: false diff --git a/.github/workflows/matlab-ubuntu20.04-vnc-dockerfile.yml b/.github/workflows/matlab-ubuntu20.04-vnc-dockerfile.yml new file mode 100644 index 0000000..9ec2e1e --- /dev/null +++ b/.github/workflows/matlab-ubuntu20.04-vnc-dockerfile.yml @@ -0,0 +1,33 @@ +# Copyright 2023 The MathWorks, Inc. +# Build & Publish matlab-vnc/ubuntu20.04/Dockerfile +name: matlab-vnc/ubuntu20.04/Dockerfile + +# Define when builds will occur: +on: + # Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path + push: + branches: + - 'main' + paths: + - 'matlab-vnc/ubuntu20.04/Dockerfile' + + # Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru) + schedule: + - cron: '0 0 * * 1' + + workflow_dispatch: + +jobs: + build-and-publish-docker-image: + strategy: + fail-fast: false + matrix: + matlab_release_tag: [r2023b, r2023a, r2022b, r2022a, r2021b, r2021a, r2020b] + uses: ./.github/workflows/build-and-publish-docker-image.yml + secrets: inherit + with: + docker_build_context: './matlab-vnc/ubuntu20.04' + base_image_name: ghcr.io/${{ github.repository }}/jupyter-matlab-vnc-notebook + os_info_tag: 'ubuntu20.04' + matlab_release_tag: ${{ matrix.matlab_release_tag }} + is_default_os: false diff --git a/.github/workflows/matlab-ubuntu20.04-vnc-mounted-dockerfile.yml b/.github/workflows/matlab-ubuntu20.04-vnc-mounted-dockerfile.yml new file mode 100644 index 0000000..da604c7 --- /dev/null +++ b/.github/workflows/matlab-ubuntu20.04-vnc-mounted-dockerfile.yml @@ -0,0 +1,33 @@ +# Copyright 2023 The MathWorks, Inc. +# Build & Publish matlab-vnc/ubuntu20.04/Dockerfile.mounted +name: matlab-vnc/ubuntu20.04/Dockerfile.mounted + +# Define when builds will occur: +on: + # Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path + push: + branches: + - 'main' + paths: + - 'matlab-vnc/ubuntu20.04/Dockerfile.mounted' + + # Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru) + schedule: + - cron: '0 0 * * 1' + + workflow_dispatch: + +jobs: + build-and-publish-docker-image: + strategy: + fail-fast: false + matrix: + matlab_release_tag: [r2023b, r2023a, r2022b, r2022a, r2021b, r2021a, r2020b] + uses: ./.github/workflows/build-and-publish-docker-image.yml + secrets: inherit + with: + docker_build_context: './matlab-vnc/ubuntu20.04' + base_image_name: ghcr.io/${{ github.repository }}/jupyter-mounted-matlab-vnc-notebook + os_info_tag: 'ubuntu20.04' + matlab_release_tag: ${{ matrix.matlab_release_tag }} + is_default_os: false diff --git a/.github/workflows/matlab-vnc-dockerfile.yml b/.github/workflows/matlab-vnc-dockerfile.yml new file mode 100644 index 0000000..f0a61fe --- /dev/null +++ b/.github/workflows/matlab-vnc-dockerfile.yml @@ -0,0 +1,33 @@ +# Copyright 2023 The MathWorks, Inc. +# Build & Publish matlab-vnc/Dockerfile +name: matlab-vnc/Dockerfile + +# Define when builds will occur: +on: + # Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path + push: + branches: + - 'main' + paths: + - 'matlab-vnc/Dockerfile' + + # Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru) + schedule: + - cron: '0 0 * * 1' + + workflow_dispatch: + +jobs: + build-and-publish-docker-image: + strategy: + fail-fast: false + matrix: + matlab_release_tag: [r2023b, r2023a, r2022b] + uses: ./.github/workflows/build-and-publish-docker-image.yml + secrets: inherit + with: + docker_build_context: './matlab-vnc' + base_image_name: ghcr.io/${{ github.repository }}/jupyter-matlab-vnc-notebook + os_info_tag: 'ubuntu22.04' + matlab_release_tag: ${{ matrix.matlab_release_tag }} + is_default_os: true diff --git a/.github/workflows/matlab-vnc-mounted-dockerfile.yml b/.github/workflows/matlab-vnc-mounted-dockerfile.yml new file mode 100644 index 0000000..0f12acb --- /dev/null +++ b/.github/workflows/matlab-vnc-mounted-dockerfile.yml @@ -0,0 +1,33 @@ +# Copyright 2023 The MathWorks, Inc. +# Build & Publish matlab-vnc/Dockerfile.mounted +name: matlab-vnc/Dockerfile.mounted + +# Define when builds will occur: +on: + # Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path + push: + branches: + - 'main' + paths: + - 'matlab-vnc/Dockerfile.mounted' + + # Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru) + schedule: + - cron: '0 0 * * 1' + + workflow_dispatch: + +jobs: + build-and-publish-docker-image: + strategy: + fail-fast: false + matrix: + matlab_release_tag: [r2023b, r2023a, r2022b] + uses: ./.github/workflows/build-and-publish-docker-image.yml + secrets: inherit + with: + docker_build_context: './matlab-vnc' + base_image_name: ghcr.io/${{ github.repository }}/jupyter-mounted-matlab-vnc-notebook + os_info_tag: 'ubuntu22.04' + matlab_release_tag: ${{ matrix.matlab_release_tag }} + is_default_os: true diff --git a/matlab-vnc/Dockerfile b/matlab-vnc/Dockerfile index abec599..623aeca 100644 --- a/matlab-vnc/Dockerfile +++ b/matlab-vnc/Dockerfile @@ -2,16 +2,33 @@ # Builds Docker image with # 1. MATLAB - Using MPM # 2. MATLAB Integration for Jupyter (VNC) -# on a base image of jupyter/base-notebook. +# on a base image of jupyter/base-notebook:python-3.xx ## Sample Build Command: -# docker build --build-arg MATLAB_RELEASE=r2023a \ +# docker build --build-arg MATLAB_RELEASE=r2023b \ # --build-arg MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Symbolic_Math_Toolbox"\ # --build-arg LICENSE_SERVER=12345@hostname.com \ # -t my_matlab_image_name . -# Specify release of MATLAB to build. (use lowercase, default is r2023a) -ARG MATLAB_RELEASE=r2023a +## Support for MATLAB Engine for Python by Release +# For more information, see: https://mathworks.com/support/requirements/python-compatibility.html +# MATLAB RELEASE | Supported Python Versions | OS supported by matlab-deps|Supported by this Dockerfile | +# ---------------| (MATLAB Engine for Python) |----------------------------|---------------------------------| +# ---------------|----------------------------|----------------------------|---------------------------------| +# R2023b | 3.9, 3.10, 3.11 | Ubuntu 20.04 & 22.04 | Yes | +# R2023a | 3.8, 3.9, 3.10 | Ubuntu 20.04 & 22.04 | Yes | +# R2022b | 3.8, 3.9, 3.10 | Ubuntu 20.04 & 22.04 | Yes | +# R2022a | 3.8, 3.9 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile | +# R2021b | 3.8, 3.9 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile | +# R2021a | 3.8 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile | +# R2020b | 3.8 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile | + +# Specify release of MATLAB to build. (use lowercase, default is r2023b) +ARG MATLAB_RELEASE=r2023b + +# Specify version of python thats used by jupyter/base-notebbok +# Using python 3.10 as default as it is the latest version compatible with MATLAB Engine for Python in R2023b, R2023a & R2022b +ARG PYTHON_VERSION=3.10 # Specify the list of products to install into MATLAB, ARG MATLAB_PRODUCT_LIST="MATLAB" @@ -26,10 +43,10 @@ ARG SHOULD_USE_LICENSE_SERVER=${LICENSE_SERVER:+"_with_lm"} ARG MW_CONTEXT_TAGS=MATLAB_PROXY:JUPYTER:MPM:V1 # Base Jupyter image without LICENSE_SERVER -FROM jupyter/base-notebook:ubuntu-20.04 AS base_jupyter_image +FROM jupyter/base-notebook:python-${PYTHON_VERSION} AS base_jupyter_image # Base Jupyter image with LICENSE_SERVER -FROM jupyter/base-notebook:ubuntu-20.04 AS base_jupyter_image_with_lm +FROM jupyter/base-notebook:python-${PYTHON_VERSION} AS base_jupyter_image_with_lm ARG LICENSE_SERVER # If license server information is available, then use it to set environment variable ENV MLM_LICENSE_FILE=${LICENSE_SERVER} @@ -44,19 +61,20 @@ ARG MATLAB_PRODUCT_LIST USER root ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" -## Installing Dependencies for Ubuntu 20.04 +## Installing Dependencies for Ubuntu 22.04 # For MATLAB : Get base-dependencies.txt from matlab-deps repository on GitHub # For mpm : wget, unzip, ca-certificates # For MATLAB Integration for Jupyter (VNC): xvfb dbus-x11 firefox xfce4 xfce4-panel xfce4-session xfce4-settings xorg xubuntu-icon-theme curl xscreensaver -# List of MATLAB Dependencies for Ubuntu 20.04 and specified MATLAB_RELEASE -ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu20.04/base-dependencies.txt" +# List of MATLAB Dependencies for Ubuntu 22.04 and specified MATLAB_RELEASE +ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu22.04/base-dependencies.txt" ARG MATLAB_DEPS_REQUIREMENTS_FILE_NAME="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt" # Install dependencies -RUN wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} && \ - export DEBIAN_FRONTEND=noninteractive && apt-get update && \ - xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ + && apt-get install --no-install-recommends -y \ + wget \ + xvfb \ dbus-x11 \ firefox \ xfce4 \ @@ -67,6 +85,8 @@ RUN wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAM xubuntu-icon-theme \ curl \ xscreensaver \ + && wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} \ + && xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ && apt-get remove -y gnome-screensaver \ && apt-get clean \ && apt-get -y autoremove \ @@ -82,17 +102,15 @@ RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm && \ rm -f mpm /tmp/mathworks_root.log && \ ln -s /opt/matlab/bin/matlab /usr/local/bin/matlab -# Install patched glibc - See https://github.com/mathworks/build-glibc-bz-19329-patch -WORKDIR /packages -RUN export DEBIAN_FRONTEND=noninteractive && \ - apt-get update && apt-get clean && apt-get autoremove && \ - wget -q https://github.com/mathworks/build-glibc-bz-19329-patch/releases/download/ubuntu-focal/all-packages.tar.gz && \ - tar -x -f all-packages.tar.gz \ - --exclude glibc-*.deb \ - --exclude libc6-dbg*.deb && \ - apt-get install --yes --no-install-recommends --allow-downgrades ./*.deb && \ - rm -fr /packages -WORKDIR / +# Optional: Install MATLAB Engine for Python, if possible. +# Note: Failure to install does not stop the build. +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ + && apt-get install --no-install-recommends -y python3-distutils \ + && apt-get clean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* \ + && cd /opt/matlab/extern/engines/python \ + && python setup.py install || true # Install tigervnc to /usr/local RUN curl -sSfL 'https://sourceforge.net/projects/tigervnc/files/stable/1.10.1/tigervnc-1.10.1.x86_64.tar.gz/download' \ diff --git a/matlab-vnc/Dockerfile.mounted b/matlab-vnc/Dockerfile.mounted index 40965cd..6fa8a2e 100644 --- a/matlab-vnc/Dockerfile.mounted +++ b/matlab-vnc/Dockerfile.mounted @@ -5,13 +5,30 @@ # Folder with the MATLAB installation needs to be mounted into the image at /opt/matlab ## Sample Build Command: -# docker build --build-arg MATLAB_RELEASE=r2023a \ +# docker build --build-arg MATLAB_RELEASE=r2023b \ # --build-arg LICENSE_SERVER=12345@hostname.com \ # -t my_matlab_image_name . -# Specify release of MATLAB being mounted. (use lowercase, default is r2023a) +## Support for MATLAB Engine for Python by Release +# For more information, see: https://mathworks.com/support/requirements/python-compatibility.html +# MATLAB RELEASE | Supported Python Versions | OS supported by matlab-deps|Supported by this Dockerfile | +# ---------------| (MATLAB Engine for Python) |----------------------------|---------------------------------| +# ---------------|----------------------------|----------------------------|---------------------------------| +# R2023b | 3.9, 3.10, 3.11 | Ubuntu 20.04 & 22.04 | Yes | +# R2023a | 3.8, 3.9, 3.10 | Ubuntu 20.04 & 22.04 | Yes | +# R2022b | 3.8, 3.9, 3.10 | Ubuntu 20.04 & 22.04 | Yes | +# R2022a | 3.8, 3.9 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile.mounted | +# R2021b | 3.8, 3.9 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile.mounted | +# R2021a | 3.8 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile.mounted | +# R2020b | 3.8 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile.mounted | + +# Specify release of MATLAB being mounted. (use lowercase, default is r2023b) # Used to fetch & install MATLAB's s/w dependencies -ARG MATLAB_RELEASE=r2023a +ARG MATLAB_RELEASE=r2023b + +# Specify version of python thats used by jupyter/base-notebbok +# Using python 3.10 as default as it is the latest version compatible with MATLAB Engine for Python in R2023b, R2023a & R2022b +ARG PYTHON_VERSION=3.10 # Optional Network License Server information in the form of port@hostname ARG LICENSE_SERVER @@ -23,10 +40,10 @@ ARG SHOULD_USE_LICENSE_SERVER=${LICENSE_SERVER:+"_with_lm"} ARG MW_CONTEXT_TAGS=MATLAB_PROXY:JUPYTER:MOUNTED:V1 # Base Jupyter image without LICENSE_SERVER -FROM jupyter/base-notebook:ubuntu-20.04 AS base_image +FROM jupyter/base-notebook:python-${PYTHON_VERSION} AS base_image # Base Jupyter image with LICENSE_SERVER -FROM jupyter/base-notebook:ubuntu-20.04 AS base_image_with_lm +FROM jupyter/base-notebook:python-${PYTHON_VERSION} AS base_image_with_lm ARG LICENSE_SERVER # If license server information is available, then use it to set environment variable ENV MLM_LICENSE_FILE=${LICENSE_SERVER} @@ -43,18 +60,19 @@ ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" # Put MATLAB on the PATH RUN ln -s /usr/local/MATLAB/bin/matlab /usr/local/bin/matlab -## Installing Dependencies for Ubuntu 20.04: +## Installing Dependencies for Ubuntu 22.04: # For MATLAB : Get base-dependencies.txt from matlab-deps repository on GitHub # For MATLAB Integration for Jupyter (VNC): xvfb dbus-x11 firefox xfce4 xfce4-panel xfce4-session xfce4-settings xorg xubuntu-icon-theme curl xscreensaver -# List of MATLAB Dependencies for Ubuntu 20.04 and specified MATLAB_RELEASE -ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu20.04/base-dependencies.txt" +# List of MATLAB Dependencies for Ubuntu 22.04 and specified MATLAB_RELEASE +ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu22.04/base-dependencies.txt" ARG MATLAB_DEPS_REQUIREMENTS_FILE_NAME="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt" # Install dependencies -RUN wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} && \ - export DEBIAN_FRONTEND=noninteractive && apt-get update && \ - xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ + && apt-get install --no-install-recommends -y \ + wget \ + xvfb \ dbus-x11 \ firefox \ xfce4 \ @@ -65,23 +83,13 @@ RUN wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAM xubuntu-icon-theme \ curl \ xscreensaver \ + && wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} \ + && xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ && apt-get remove -y gnome-screensaver \ && apt-get clean \ && apt-get -y autoremove \ && rm -rf /var/lib/apt/lists/* ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -# Install patched glibc - See https://github.com/mathworks/build-glibc-bz-19329-patch -WORKDIR /packages -RUN export DEBIAN_FRONTEND=noninteractive && \ - apt-get update && apt-get clean && apt-get autoremove && \ - wget -q https://github.com/mathworks/build-glibc-bz-19329-patch/releases/download/ubuntu-focal/all-packages.tar.gz && \ - tar -x -f all-packages.tar.gz \ - --exclude glibc-*.deb \ - --exclude libc6-dbg*.deb && \ - apt-get install --yes --no-install-recommends --allow-downgrades ./*.deb && \ - rm -fr /packages -WORKDIR / - # Install tigervnc to /usr/local RUN curl -sSfL 'https://sourceforge.net/projects/tigervnc/files/stable/1.10.1/tigervnc-1.10.1.x86_64.tar.gz/download' \ | tar -zxf - -C /usr/local --strip=2 @@ -113,8 +121,6 @@ ENV NOVNC_PATH=${NOVNC_PATH} # Pip install the latest version of the integration RUN curl -s https://api.github.com/repos/mathworks/jupyter-matlab-vnc-proxy/releases/latest | grep tarball_url | cut -d '"' -f 4 | xargs python -m pip install - - # Move MATLAB resource files to the expected locations RUN export RESOURCES_LOC=$(python -c "import jupyter_matlab_vnc_proxy as pkg; print(pkg.__path__[0])")/resources \ && mkdir -p ${HOME}/.local/share/applications ${HOME}/Desktop ${HOME}/.local/share/ ${HOME}/.icons \ diff --git a/matlab-vnc/ubuntu20.04/Dockerfile b/matlab-vnc/ubuntu20.04/Dockerfile new file mode 100644 index 0000000..9731bb3 --- /dev/null +++ b/matlab-vnc/ubuntu20.04/Dockerfile @@ -0,0 +1,141 @@ +# Copyright 2023 The MathWorks, Inc. +# Builds Docker image with +# 1. MATLAB - Using MPM +# 2. MATLAB Integration for Jupyter (VNC) +# on a base image of jupyter/base-notebook:ubuntu-20.04 + +## Sample Build Command: +# docker build --build-arg MATLAB_RELEASE=r2023b \ +# --build-arg MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Symbolic_Math_Toolbox"\ +# --build-arg LICENSE_SERVER=12345@hostname.com \ +# -t my_matlab_image_name . + +# Specify release of MATLAB to build. (use lowercase, default is r2023b) +ARG MATLAB_RELEASE=r2023b + +# Specify the list of products to install into MATLAB, +ARG MATLAB_PRODUCT_LIST="MATLAB" + +# Optional Network License Server information +ARG LICENSE_SERVER + +# If LICENSE_SERVER is provided then SHOULD_USE_LICENSE_SERVER will be set to "_use_lm" +ARG SHOULD_USE_LICENSE_SERVER=${LICENSE_SERVER:+"_with_lm"} + +# Default DDUX information +ARG MW_CONTEXT_TAGS=MATLAB_PROXY:JUPYTER:MPM:V1 + +# Base Jupyter image without LICENSE_SERVER +FROM jupyter/base-notebook:ubuntu-20.04 AS base_jupyter_image + +# Base Jupyter image with LICENSE_SERVER +FROM jupyter/base-notebook:ubuntu-20.04 AS base_jupyter_image_with_lm +ARG LICENSE_SERVER +# If license server information is available, then use it to set environment variable +ENV MLM_LICENSE_FILE=${LICENSE_SERVER} + +# Select base Jupyter image based on whether LICENSE_SERVER is provided +FROM base_jupyter_image${SHOULD_USE_LICENSE_SERVER} +ARG MW_CONTEXT_TAGS +ARG MATLAB_RELEASE +ARG MATLAB_PRODUCT_LIST + +# Switch to root user +USER root +ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" + +## Installing Dependencies for Ubuntu 20.04 +# For MATLAB : Get base-dependencies.txt from matlab-deps repository on GitHub +# For mpm : wget, unzip, ca-certificates +# For MATLAB Integration for Jupyter (VNC): xvfb dbus-x11 firefox xfce4 xfce4-panel xfce4-session xfce4-settings xorg xubuntu-icon-theme curl xscreensaver + +# List of MATLAB Dependencies for Ubuntu 20.04 and specified MATLAB_RELEASE +ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu20.04/base-dependencies.txt" +ARG MATLAB_DEPS_REQUIREMENTS_FILE_NAME="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt" + +# Install dependencies +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ + && apt-get install --no-install-recommends -y \ + wget \ + xvfb \ + dbus-x11 \ + firefox \ + xfce4 \ + xfce4-panel \ + xfce4-session \ + xfce4-settings \ + xorg \ + xubuntu-icon-theme \ + curl \ + xscreensaver \ + && wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} \ + && xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ + && apt-get remove -y gnome-screensaver \ + && apt-get clean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} + +# Run mpm to install MATLAB in the target location and delete the mpm installation afterwards +RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm && \ + chmod +x mpm && \ + ./mpm install \ + --release=${MATLAB_RELEASE} \ + --destination=/opt/matlab \ + --products ${MATLAB_PRODUCT_LIST} && \ + rm -f mpm /tmp/mathworks_root.log && \ + ln -s /opt/matlab/bin/matlab /usr/local/bin/matlab + +# Install patched glibc - See https://github.com/mathworks/build-glibc-bz-19329-patch +WORKDIR /packages +RUN export DEBIAN_FRONTEND=noninteractive && \ + apt-get update && apt-get clean && apt-get autoremove && \ + wget -q https://github.com/mathworks/build-glibc-bz-19329-patch/releases/download/ubuntu-focal/all-packages.tar.gz && \ + tar -x -f all-packages.tar.gz \ + --exclude glibc-*.deb \ + --exclude libc6-dbg*.deb && \ + apt-get install --yes --no-install-recommends --allow-downgrades ./*.deb && \ + rm -fr /packages +WORKDIR / + +# Install tigervnc to /usr/local +RUN curl -sSfL 'https://sourceforge.net/projects/tigervnc/files/stable/1.10.1/tigervnc-1.10.1.x86_64.tar.gz/download' \ + | tar -zxf - -C /usr/local --strip=2 + +# noVNC provides VNC over browser capability +# Set default install location for noVNC +ARG NOVNC_PATH=/opt/noVNC + +# Get noVNC +RUN mkdir -p ${NOVNC_PATH} \ + && curl -sSfL 'https://github.com/novnc/noVNC/archive/v1.2.0.tar.gz' \ + | tar -zxf - -C ${NOVNC_PATH} --strip=1 \ + && chown -R ${NB_USER}:users ${NOVNC_PATH} + +# JOVYAN is the default user in jupyter/base-notebook. +# JOVYAN is being set to be passwordless. +# This allows users to easily wake the desktop when it goes to sleep. +RUN passwd $NB_USER -d + +# Change user to jovyan from root as we do not want any changes to be made as root in the container +USER $NB_USER + +# Get websockify +RUN conda install -y -q websockify=0.10.0 + +# Set environment variable for python package jupyter-matlab-vnc-proxy +ENV NOVNC_PATH=${NOVNC_PATH} + +# Pip install the latest version of the integration +RUN curl -s https://api.github.com/repos/mathworks/jupyter-matlab-vnc-proxy/releases/latest | grep tarball_url | cut -d '"' -f 4 | xargs python -m pip install + +# Move MATLAB resource files to the expected locations +RUN export RESOURCES_LOC=$(python -c "import jupyter_matlab_vnc_proxy as pkg; print(pkg.__path__[0])")/resources \ + && mkdir -p ${HOME}/.local/share/applications ${HOME}/Desktop ${HOME}/.local/share/ ${HOME}/.icons \ + && cp ${RESOURCES_LOC}/MATLAB.desktop ${HOME}/Desktop/ \ + && cp ${RESOURCES_LOC}/MATLAB.desktop ${HOME}/.local/share/applications\ + && ln -s ${RESOURCES_LOC}/matlab_icon.png ${HOME}/.icons/matlab_icon.png \ + && cp ${RESOURCES_LOC}/matlab_launcher.py ${HOME}/.local/share/ \ + && cp ${RESOURCES_LOC}/mw_lite.html ${NOVNC_PATH} + +# Fixes occasional failure to start VNC desktop, which requires a reloading of the webpage to fix. +RUN touch ${HOME}/.Xauthority \ No newline at end of file diff --git a/matlab-vnc/ubuntu20.04/Dockerfile.mounted b/matlab-vnc/ubuntu20.04/Dockerfile.mounted new file mode 100644 index 0000000..f7e9d94 --- /dev/null +++ b/matlab-vnc/ubuntu20.04/Dockerfile.mounted @@ -0,0 +1,129 @@ +# Copyright 2023 The MathWorks, Inc. +# Builds Docker image with +# 1. MATLAB Integration for Jupyter (VNC) +# on a base image of jupyter/base-notebook:ubuntu-20.04 +# Folder with the MATLAB installation needs to be mounted into the image at /opt/matlab + +## Sample Build Command: +# docker build --build-arg MATLAB_RELEASE=r2023b \ +# --build-arg LICENSE_SERVER=12345@hostname.com \ +# -t my_matlab_image_name . + +# Specify release of MATLAB being mounted. (use lowercase, default is r2023b) +# Used to fetch & install MATLAB's s/w dependencies +ARG MATLAB_RELEASE=r2023b + +# Optional Network License Server information in the form of port@hostname +ARG LICENSE_SERVER + +# If LICENSE_SERVER is provided then SHOULD_USE_LICENSE_SERVER will be set to "_use_lm" +ARG SHOULD_USE_LICENSE_SERVER=${LICENSE_SERVER:+"_with_lm"} + +# Default DDUX information +ARG MW_CONTEXT_TAGS=MATLAB_PROXY:JUPYTER:MOUNTED:V1 + +# Base Jupyter image without LICENSE_SERVER +FROM jupyter/base-notebook:ubuntu-20.04 AS base_image + +# Base Jupyter image with LICENSE_SERVER +FROM jupyter/base-notebook:ubuntu-20.04 AS base_image_with_lm +ARG LICENSE_SERVER +# If license server information is available, then use it to set environment variable +ENV MLM_LICENSE_FILE=${LICENSE_SERVER} + +# Select base Jupyter image based on whether LICENSE_SERVER is provided +FROM base_image${SHOULD_USE_LICENSE_SERVER} +ARG MW_CONTEXT_TAGS +ARG MATLAB_RELEASE + +# Switch to root user +USER root +ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" + +# Put MATLAB on the PATH +RUN ln -s /usr/local/MATLAB/bin/matlab /usr/local/bin/matlab + +## Installing Dependencies for Ubuntu 20.04: +# For MATLAB : Get base-dependencies.txt from matlab-deps repository on GitHub +# For MATLAB Integration for Jupyter (VNC): xvfb dbus-x11 firefox xfce4 xfce4-panel xfce4-session xfce4-settings xorg xubuntu-icon-theme curl xscreensaver + +# List of MATLAB Dependencies for Ubuntu 20.04 and specified MATLAB_RELEASE +ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu20.04/base-dependencies.txt" +ARG MATLAB_DEPS_REQUIREMENTS_FILE_NAME="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt" + +# Install dependencies +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ + && apt-get install --no-install-recommends -y \ + wget \ + xvfb \ + dbus-x11 \ + firefox \ + xfce4 \ + xfce4-panel \ + xfce4-session \ + xfce4-settings \ + xorg \ + xubuntu-icon-theme \ + curl \ + xscreensaver \ + && wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} \ + && xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ + && apt-get remove -y gnome-screensaver \ + && apt-get clean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} + +# Install patched glibc - See https://github.com/mathworks/build-glibc-bz-19329-patch +WORKDIR /packages +RUN export DEBIAN_FRONTEND=noninteractive && \ + apt-get update && apt-get clean && apt-get autoremove && \ + wget -q https://github.com/mathworks/build-glibc-bz-19329-patch/releases/download/ubuntu-focal/all-packages.tar.gz && \ + tar -x -f all-packages.tar.gz \ + --exclude glibc-*.deb \ + --exclude libc6-dbg*.deb && \ + apt-get install --yes --no-install-recommends --allow-downgrades ./*.deb && \ + rm -fr /packages +WORKDIR / + +# Install tigervnc to /usr/local +RUN curl -sSfL 'https://sourceforge.net/projects/tigervnc/files/stable/1.10.1/tigervnc-1.10.1.x86_64.tar.gz/download' \ + | tar -zxf - -C /usr/local --strip=2 + +# noVNC provides VNC over browser capability +# Set default install location for noVNC +ARG NOVNC_PATH=/opt/noVNC + +# Get noVNC +RUN mkdir -p ${NOVNC_PATH} \ + && curl -sSfL 'https://github.com/novnc/noVNC/archive/v1.2.0.tar.gz' \ + | tar -zxf - -C ${NOVNC_PATH} --strip=1 \ + && chown -R ${NB_USER}:users ${NOVNC_PATH} + +# JOVYAN is the default user in jupyter/base-notebook. +# JOVYAN is being set to be passwordless. +# This allows users to easily wake the desktop when it goes to sleep. +RUN passwd $NB_USER -d + +# Switch back to notebook user +USER $NB_USER + +# Get websockify +RUN conda install -y -q websockify=0.10.0 + +# Set environment variable for python package jupyter-matlab-vnc-proxy +ENV NOVNC_PATH=${NOVNC_PATH} + +# Pip install the latest version of the integration +RUN curl -s https://api.github.com/repos/mathworks/jupyter-matlab-vnc-proxy/releases/latest | grep tarball_url | cut -d '"' -f 4 | xargs python -m pip install + +# Move MATLAB resource files to the expected locations +RUN export RESOURCES_LOC=$(python -c "import jupyter_matlab_vnc_proxy as pkg; print(pkg.__path__[0])")/resources \ + && mkdir -p ${HOME}/.local/share/applications ${HOME}/Desktop ${HOME}/.local/share/ ${HOME}/.icons \ + && cp ${RESOURCES_LOC}/MATLAB.desktop ${HOME}/Desktop/ \ + && cp ${RESOURCES_LOC}/MATLAB.desktop ${HOME}/.local/share/applications\ + && ln -s ${RESOURCES_LOC}/matlab_icon.png ${HOME}/.icons/matlab_icon.png \ + && cp ${RESOURCES_LOC}/matlab_launcher.py ${HOME}/.local/share/ \ + && cp ${RESOURCES_LOC}/mw_lite.html ${NOVNC_PATH} + +# Fixes occasional failure to start VNC desktop, which requires a reloading of the webpage to fix. +RUN touch ${HOME}/.Xauthority \ No newline at end of file diff --git a/matlab/Dockerfile b/matlab/Dockerfile index 4c18257..09e0614 100644 --- a/matlab/Dockerfile +++ b/matlab/Dockerfile @@ -1,17 +1,38 @@ # Copyright 2021-2023 The MathWorks, Inc. -# Builds Docker image with +# Builds Docker image on Ubuntu 22.04 with: # 1. MATLAB - Using MPM # 2. MATLAB Integration for Jupyter -# on a base image of jupyter/base-notebook. +# on a base image of jupyter/base-notebook:python-3.xx + +# NOTE: This Dockerfile can only build MATLAB releases which have system dependency lists available for 22.04 on container-images/matlab-deps. +# For complete listing, see https://github.com/mathworks-ref-arch/container-images/tree/main/matlab-deps ## Sample Build Command: -# docker build --build-arg MATLAB_RELEASE=r2023a \ +# docker build --build-arg MATLAB_RELEASE=r2023b \ +# --build-arg PYTHON_VERSION=3.11 \ # --build-arg MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Symbolic_Math_Toolbox"\ # --build-arg LICENSE_SERVER=12345@hostname.com \ # -t my_matlab_image_name . -# Specify release of MATLAB to build. (use lowercase, default is r2023a) -ARG MATLAB_RELEASE=r2023a +## Support for MATLAB Engine for Python by Release +# For more information, see: https://mathworks.com/support/requirements/python-compatibility.html +# MATLAB RELEASE | Supported Python Versions | OS supported by matlab-deps|Supported by this Dockerfile | +# ---------------| (MATLAB Engine for Python) |----------------------------|---------------------------------| +# ---------------|----------------------------|----------------------------|---------------------------------| +# R2023b | 3.9, 3.10, 3.11 | Ubuntu 22.04 & 20.04 | Yes | +# R2023a | 3.8, 3.9, 3.10 | Ubuntu 22.04 & 20.04 | Yes | +# R2022b | 3.8, 3.9, 3.10 | Ubuntu 22.04 & 20.04 | Yes | +# R2022a | 3.8, 3.9 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile | +# R2021b | 3.8, 3.9 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile | +# R2021a | 3.8 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile | +# R2020b | 3.8 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile | + +# Specify release of MATLAB to build. (use lowercase, default is r2023b) +ARG MATLAB_RELEASE=r2023b + +# Specify version of python thats used by jupyter/base-notebbok +# Using python 3.10 as default as it is the latest version compatible with MATLAB Engine for Python in R2023b, R2023a & R2022b +ARG PYTHON_VERSION=3.10 # Specify the list of products to install into MATLAB, ARG MATLAB_PRODUCT_LIST="MATLAB" @@ -25,11 +46,11 @@ ARG SHOULD_USE_LICENSE_SERVER=${LICENSE_SERVER:+"_with_lm"} # Default DDUX information ARG MW_CONTEXT_TAGS=MATLAB_PROXY:JUPYTER:MPM:V1 -# Base Jupyter image without LICENSE_SERVER -FROM jupyter/base-notebook:ubuntu-20.04 AS base_jupyter_image +# Base Jupyter ubuntu 22.04 image without LICENSE_SERVER +FROM jupyter/base-notebook:python-${PYTHON_VERSION} AS base_jupyter_image -# Base Jupyter image with LICENSE_SERVER -FROM jupyter/base-notebook:ubuntu-20.04 AS base_jupyter_image_with_lm +# Base Jupyter ubuntu 22.04 image with LICENSE_SERVER +FROM jupyter/base-notebook:python-${PYTHON_VERSION} AS base_jupyter_image_with_lm ARG LICENSE_SERVER # If license server information is available, then use it to set environment variable ENV MLM_LICENSE_FILE=${LICENSE_SERVER} @@ -44,22 +65,24 @@ ARG MATLAB_PRODUCT_LIST USER root ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" -## Installing Dependencies for Ubuntu 20.04 +## Installing Dependencies for Ubuntu 22.04 # For MATLAB : Get base-dependencies.txt from matlab-deps repository on GitHub # For mpm : wget, unzip, ca-certificates # For MATLAB Integration for Jupyter : xvfb -# List of MATLAB Dependencies for Ubuntu 20.04 and specified MATLAB_RELEASE -ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu20.04/base-dependencies.txt" +# List of MATLAB Dependencies for Ubuntu 22.04 and specified MATLAB_RELEASE +ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu22.04/base-dependencies.txt" ARG MATLAB_DEPS_REQUIREMENTS_FILE_NAME="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt" # Install dependencies -RUN wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} \ - && export DEBIAN_FRONTEND=noninteractive && apt-get update \ - && xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ + && apt-get install --no-install-recommends -y \ wget \ unzip \ ca-certificates \ xvfb \ + git \ + && wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} \ + && xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ && apt-get clean \ && apt-get -y autoremove \ && rm -rf /var/lib/apt/lists/* ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} @@ -74,18 +97,6 @@ RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm && \ rm -f mpm /tmp/mathworks_root.log && \ ln -s /opt/matlab/bin/matlab /usr/local/bin/matlab -# Install patched glibc - See https://github.com/mathworks/build-glibc-bz-19329-patch -WORKDIR /packages -RUN export DEBIAN_FRONTEND=noninteractive && \ - apt-get update && apt-get clean && apt-get autoremove && \ - wget -q https://github.com/mathworks/build-glibc-bz-19329-patch/releases/download/ubuntu-focal/all-packages.tar.gz && \ - tar -x -f all-packages.tar.gz \ - --exclude glibc-*.deb \ - --exclude libc6-dbg*.deb && \ - apt-get install --yes --no-install-recommends --allow-downgrades ./*.deb && \ - rm -fr /packages -WORKDIR / - # Optional: Install MATLAB Engine for Python, if possible. # Note: Failure to install does not stop the build. RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ @@ -103,8 +114,6 @@ WORKDIR /home/${NB_USER} # Install integration RUN python -m pip install jupyter-matlab-proxy - - # Make JupyterLab the default environment ENV JUPYTER_ENABLE_LAB="yes" diff --git a/matlab/Dockerfile.byoi b/matlab/Dockerfile.byoi index 6c3833e..a9f1cc3 100644 --- a/matlab/Dockerfile.byoi +++ b/matlab/Dockerfile.byoi @@ -1,22 +1,41 @@ # Copyright 2021-2023 The MathWorks, Inc. -# Builds Docker image with +# Builds Docker image on Ubuntu 22.04 with: # 1. MATLAB - Your existing image with MATLAB # 2. MATLAB Integration for Jupyter -# on a base image of jupyter/base-notebook. +# on a base image of jupyter/base-notebook:python-3.xx + +# NOTE: This Dockerfile can only build MATLAB releases which have system dependency lists available for 22.04 on container-images/matlab-deps. +# For complete listing, see https://github.com/mathworks-ref-arch/container-images/tree/main/matlab-deps ## Sample Build Command: -# docker build --build-arg MATLAB_RELEASE=r2023a \ -# --build-arg MATLAB_IMAGE_NAME=mathworks/matlab \ +# docker build --build-arg MATLAB_RELEASE=r2023b \ +# --build-arg PYTHON_VERSION=3.11 \ +# --build-arg MATLAB_IMAGE_NAME=mathworks/matlab:r2023b \ # --build-arg LICENSE_SERVER=12345@hostname.com \ # -t my_matlab_image_name -f Dockerfile.byoi . -# Specify release of MATLAB to build. (use lowercase, default is r2023a) -ARG MATLAB_RELEASE=r2023a - -ARG DEFAULT_IMAGE_FROM_DOCKERHUB=mathworks/matlab:${MATLAB_RELEASE} +## Support for MATLAB Engine for Python by Release +# For more information, see: https://mathworks.com/support/requirements/python-compatibility.html +# MATLAB RELEASE | Supported Python Versions | OS supported by matlab-deps|Supported by this Dockerfile | +# ---------------| (MATLAB Engine for Python) |----------------------------|---------------------------------| +# ---------------|----------------------------|----------------------------|---------------------------------| +# R2023b | 3.9, 3.10, 3.11 | Ubuntu 22.04 & 20.04 | Yes | +# R2023a | 3.8, 3.9, 3.10 | Ubuntu 22.04 & 20.04 | Yes | +# R2022b | 3.8, 3.9, 3.10 | Ubuntu 22.04 & 20.04 | Yes | +# R2022a | 3.8, 3.9 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile.byoi | +# R2021b | 3.8, 3.9 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile.byoi | +# R2021a | 3.8 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile.byoi | +# R2020b | 3.8 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile.byoi | + +# Specify release of MATLAB to build. (use lowercase, default is r2023b) +ARG MATLAB_RELEASE=r2023b + +# Specify version of python thats used by jupyter/base-notebbok +# Using python 3.10 as default as it is the latest version compatible with MATLAB Engine for Python in R2023b, R2023a & R2022b +ARG PYTHON_VERSION=3.10 # Specify name of Docker Image with MATLAB already installed. -ARG MATLAB_IMAGE_NAME=${DEFAULT_IMAGE_FROM_DOCKERHUB} +ARG MATLAB_IMAGE_NAME=mathworks/matlab:${MATLAB_RELEASE} # Optional Network License Server information ARG LICENSE_SERVER @@ -48,11 +67,11 @@ RUN export ML_INSTALL_LOC=$(which matlab) \ echo "Proceeding with user provided path to MATLAB installation: ${BASE_ML_INSTALL_LOC}"; \ fi -# Base Jupyter image without LICENSE_SERVER -FROM jupyter/base-notebook:ubuntu-20.04 AS base_jupyter_image +# Base Jupyter ubuntu 22.04 image without LICENSE_SERVER +FROM jupyter/base-notebook:python-${PYTHON_VERSION} AS base_jupyter_image -# Base Jupyter image with LICENSE_SERVER -FROM jupyter/base-notebook:ubuntu-20.04 AS base_jupyter_image_with_lm +# Base Jupyter ubuntu 22.04 image with LICENSE_SERVER +FROM jupyter/base-notebook:python-${PYTHON_VERSION} AS base_jupyter_image_with_lm ARG LICENSE_SERVER # If license server information is available, then use it to set environment variable ENV MLM_LICENSE_FILE=${LICENSE_SERVER} @@ -74,38 +93,28 @@ COPY --from=matlab-install-stage ${BASE_ML_INSTALL_LOC} ${MATLAB_INSTALL_LOCATIO # Put MATLAB on the PATH RUN ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab -## Installing Dependencies for Ubuntu 20.04 +## Installing Dependencies for Ubuntu 22.04 # For MATLAB : Get base-dependencies.txt from matlab-deps repository on GitHub +# For mpm : wget, unzip, ca-certificates # For MATLAB Integration for Jupyter : xvfb - -# List of MATLAB Dependencies for Ubuntu 20.04 and specified MATLAB_RELEASE -ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu20.04/base-dependencies.txt" +# List of MATLAB Dependencies for Ubuntu 22.04 and specified MATLAB_RELEASE +ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu22.04/base-dependencies.txt" ARG MATLAB_DEPS_REQUIREMENTS_FILE_NAME="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt" # Install dependencies -RUN wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} \ - && export DEBIAN_FRONTEND=noninteractive && apt-get update \ - && xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ + && apt-get install --no-install-recommends -y \ wget \ unzip \ ca-certificates \ xvfb \ + git \ + && wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} \ + && xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ && apt-get clean \ && apt-get -y autoremove \ && rm -rf /var/lib/apt/lists/* ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -# Install patched glibc - See https://github.com/mathworks/build-glibc-bz-19329-patch -WORKDIR /packages -RUN export DEBIAN_FRONTEND=noninteractive && \ - apt-get update && apt-get clean && apt-get autoremove && \ - wget -q https://github.com/mathworks/build-glibc-bz-19329-patch/releases/download/ubuntu-focal/all-packages.tar.gz && \ - tar -x -f all-packages.tar.gz \ - --exclude glibc-*.deb \ - --exclude libc6-dbg*.deb && \ - apt-get install --yes --no-install-recommends --allow-downgrades ./*.deb && \ - rm -fr /packages -WORKDIR / - # Optional: Install MATLAB Engine for Python, if possible. # Note: Failure to install does not stop the build. RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ @@ -123,8 +132,6 @@ WORKDIR /home/${NB_USER} # Install integration RUN python -m pip install jupyter-matlab-proxy - - # Make JupyterLab the default environment ENV JUPYTER_ENABLE_LAB="yes" diff --git a/matlab/Dockerfile.mounted b/matlab/Dockerfile.mounted index d2ef037..ec3a706 100644 --- a/matlab/Dockerfile.mounted +++ b/matlab/Dockerfile.mounted @@ -1,17 +1,38 @@ # Copyright 2021-2023 The MathWorks, Inc. -# Builds Docker image with +# Builds Docker image on Ubuntu 22.04 with: # 1. MATLAB Integration for Jupyter -# on a base image of jupyter/base-notebook. +# on a base image of jupyter/base-notebook:python-3.xx # Folder with the MATLAB installation needs to be mounted into the image at /opt/matlab +# NOTE: This Dockerfile can only build MATLAB releases which have system dependency lists available for 22.04 on container-images/matlab-deps. +# For complete listing, see https://github.com/mathworks-ref-arch/container-images/tree/main/matlab-deps + ## Sample Build Command: -# docker build --build-arg MATLAB_RELEASE=r2023a \ +# docker build --build-arg MATLAB_RELEASE=r2023b \ +# --build-arg PYTHON_VERSION=3.11 \ # --build-arg LICENSE_SERVER=12345@hostname.com \ # -t my_matlab_image_name . -# Specify release of MATLAB being mounted. (use lowercase, default is r2023a) +## Support for MATLAB Engine for Python by Release +# For more information, see: https://mathworks.com/support/requirements/python-compatibility.html +# MATLAB RELEASE | Supported Python Versions | OS supported by matlab-deps|Supported by this Dockerfile | +# ---------------| (MATLAB Engine for Python) |----------------------------|---------------------------------| +# ---------------|----------------------------|----------------------------|---------------------------------| +# R2023b | 3.9, 3.10, 3.11 | Ubuntu 22.04 & 20.04 | Yes | +# R2023a | 3.8, 3.9, 3.10 | Ubuntu 22.04 & 20.04 | Yes | +# R2022b | 3.8, 3.9, 3.10 | Ubuntu 22.04 & 20.04 | Yes | +# R2022a | 3.8, 3.9 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile.mounted | +# R2021b | 3.8, 3.9 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile.mounted | +# R2021a | 3.8 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile.mounted | +# R2020b | 3.8 | Ubuntu 20.04 | No, use ubuntu20.04/Dockerfile.mounted | + +# Specify release of MATLAB being mounted. (use lowercase, default is r2023b) # Used to fetch & install MATLAB's s/w dependencies -ARG MATLAB_RELEASE=r2023a +ARG MATLAB_RELEASE=r2023b + +# Specify version of python thats used by jupyter/base-notebbok +# Using python 3.10 as default as it is the latest version compatible with MATLAB Engine for Python in R2023b, R2023a & R2022b +ARG PYTHON_VERSION=3.10 # Optional Network License Server information in the form of port@hostname ARG LICENSE_SERVER @@ -23,10 +44,10 @@ ARG SHOULD_USE_LICENSE_SERVER=${LICENSE_SERVER:+"_with_lm"} ARG MW_CONTEXT_TAGS=MATLAB_PROXY:JUPYTER:MOUNTED:V1 # Base Jupyter image without LICENSE_SERVER -FROM jupyter/base-notebook:ubuntu-20.04 AS base_image +FROM jupyter/base-notebook:python-${PYTHON_VERSION} AS base_image # Base Jupyter image with LICENSE_SERVER -FROM jupyter/base-notebook:ubuntu-20.04 AS base_image_with_lm +FROM jupyter/base-notebook:python-${PYTHON_VERSION} AS base_image_with_lm ARG LICENSE_SERVER # If license server information is available, then use it to set environment variable ENV MLM_LICENSE_FILE=${LICENSE_SERVER} @@ -43,35 +64,26 @@ ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" # Put MATLAB on the PATH RUN ln -s /opt/matlab/bin/matlab /usr/local/bin/matlab -## Installing Dependencies for Ubuntu 20.04: +## Installing Dependencies for Ubuntu 22.04: # For MATLAB : Get base-dependencies.txt from matlab-deps repository on GitHub # For MATLAB Integration for Jupyter : xvfb -# List of MATLAB Dependencies for Ubuntu 20.04 and specified MATLAB_RELEASE -ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu20.04/base-dependencies.txt" +# List of MATLAB Dependencies for Ubuntu 22.04 and specified MATLAB_RELEASE +ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu22.04/base-dependencies.txt" ARG MATLAB_DEPS_REQUIREMENTS_FILE_NAME="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt" # Install dependencies -RUN wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} && \ - export DEBIAN_FRONTEND=noninteractive && apt-get update && \ - xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ + && apt-get install --no-install-recommends -y \ + wget \ xvfb \ + git \ + && wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} \ + && xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ && apt-get clean \ && apt-get -y autoremove \ && rm -rf /var/lib/apt/lists/* ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -# Install patched glibc - See https://github.com/mathworks/build-glibc-bz-19329-patch -WORKDIR /packages -RUN export DEBIAN_FRONTEND=noninteractive && \ - apt-get update && apt-get clean && apt-get autoremove && \ - wget -q https://github.com/mathworks/build-glibc-bz-19329-patch/releases/download/ubuntu-focal/all-packages.tar.gz && \ - tar -x -f all-packages.tar.gz \ - --exclude glibc-*.deb \ - --exclude libc6-dbg*.deb && \ - apt-get install --yes --no-install-recommends --allow-downgrades ./*.deb && \ - rm -fr /packages -WORKDIR / - # Switch back to notebook user USER $NB_USER WORKDIR /home/${NB_USER} @@ -79,8 +91,6 @@ WORKDIR /home/${NB_USER} # Install integration RUN python -m pip install jupyter-matlab-proxy - - # Make JupyterLab the default environment ENV JUPYTER_ENABLE_LAB="yes" diff --git a/matlab/Dockerfile.ubuntu-22.04 b/matlab/Dockerfile.ubuntu-22.04 deleted file mode 100644 index 13b3913..0000000 --- a/matlab/Dockerfile.ubuntu-22.04 +++ /dev/null @@ -1,102 +0,0 @@ -# Copyright 2023 The MathWorks, Inc. -# Builds Docker image with -# 1. MATLAB - Using MPM -# 2. MATLAB Integration for Jupyter -# on a base image of jupyter/base-notebook:ubuntu-22.04 - -## Sample Build Command: -# docker build --build-arg MATLAB_RELEASE=r2023a \ -# --build-arg MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Symbolic_Math_Toolbox"\ -# --build-arg LICENSE_SERVER=12345@hostname.com \ -# -t my_matlab_image_name . - -# Specify release of MATLAB to build. (use lowercase, default is r2023a) -ARG MATLAB_RELEASE=r2023a - -# Specify the list of products to install into MATLAB, -ARG MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Image_Processing_Toolbox Statistics_and_Machine_Learning_Toolbox Simulink" -# Optional Network License Server information -ARG LICENSE_SERVER - -# If LICENSE_SERVER is provided then SHOULD_USE_LICENSE_SERVER will be set to "_use_lm" -ARG SHOULD_USE_LICENSE_SERVER=${LICENSE_SERVER:+"_with_lm"} - -# Default DDUX information -ARG MW_CONTEXT_TAGS=MATLAB_PROXY:JUPYTER:MPM:V1 - - -## jupyter/base-notebook:python-3.10 is based on Ubuntu 22.04 and is being used as, -## the matlabengineforpython for R2023a only supports upto python v3.10 -# Base Jupyter image without LICENSE_SERVER -FROM jupyter/base-notebook:python-3.10 AS base_jupyter_image - -# Base Jupyter image with LICENSE_SERVER -FROM jupyter/base-notebook:python-3.10 AS base_jupyter_image_with_lm -ARG LICENSE_SERVER -# If license server information is available, then use it to set environment variable -ENV MLM_LICENSE_FILE=${LICENSE_SERVER} - -# Select base Jupyter image based on whether LICENSE_SERVER is provided -FROM base_jupyter_image${SHOULD_USE_LICENSE_SERVER} -ARG MW_CONTEXT_TAGS -ARG MATLAB_RELEASE -ARG MATLAB_PRODUCT_LIST - -# Switch to root user -USER root -ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" - -# List of MATLAB Dependencies for Ubuntu 22.04 and MATLAB R2023a -ARG MATLAB_DEPS_REQUIREMENTS="ca-certificates libasound2 libc6 libcairo-gobject2 libcairo2 libcap2 libcrypt1 libcups2 libdrm2 libgbm1 libgdk-pixbuf-2.0-0 libgl1 libglib2.0-0 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libgtk-3-0 libice6 libnspr4 libnss3 libodbc2 libodbcinst2 libpam0g libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libsndfile1 libuuid1 libwayland-client0 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxft2 libxinerama1 libxrandr2 libxt6 libxtst6 libxxf86vm1 locales locales-all make net-tools procps sudo unzip zlib1g" -ARG MATLAB_DEPS_REQUIREMENTS_FILE_NAME="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt" - -## Install dependencies -## MATLAB versions older than 22b need libpython3.9 which is only present in the deadsnakes PPA on ubuntu:22.04 -RUN echo ${MATLAB_DEPS_REQUIREMENTS} > ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} \ - && apt-get update \ - && export isJammy=`cat /etc/lsb-release | grep DISTRIB_RELEASE=22.04 | wc -l` \ - && export needsPy39=`cat ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} | grep libpython3.9 | wc -l` \ - && if [[ isJammy -eq 1 && needsPy39 -eq 1 ]] ; then apt-get install -y software-properties-common && add-apt-repository ppa:deadsnakes/ppa ; fi \ - && xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ - unzip \ - ca-certificates \ - xvfb \ - git \ - && apt-get clean \ - && apt-get -y autoremove \ - && rm -rf /var/lib/apt/lists/* ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} - -# Note on glibc patch - See https://github.com/mathworks/build-glibc-bz-19329-patch -# Installation is skipped on Ubuntu 22.04 (Jammy) as it already contains the glibc fix - -# Run mpm to install MATLAB in the target location and delete the mpm installation afterwards -RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm && \ - chmod +x mpm && \ - ./mpm install \ - --release=${MATLAB_RELEASE} \ - --destination=/opt/matlab \ - --products ${MATLAB_PRODUCT_LIST} && \ - rm -f mpm /tmp/mathworks_root.log && \ - ln -s /opt/matlab/bin/matlab /usr/local/bin/matlab - -# Optional: Install MATLAB Engine for Python, if possible. -# Note: Failure to install does not stop the build. -RUN apt-get update \ - && apt-get install --no-install-recommends -y python3-distutils \ - && apt-get clean \ - && apt-get -y autoremove \ - && rm -rf /var/lib/apt/lists/* \ - && cd /opt/matlab/extern/engines/python \ - && python setup.py install - -# Switch back to notebook user -USER $NB_USER -WORKDIR /home/${NB_USER} - -# Install integration -RUN python -m pip install jupyter-matlab-proxy - -# Make JupyterLab the default environment -ENV JUPYTER_ENABLE_LAB="yes" - -ENV MW_CONTEXT_TAGS=${MW_CONTEXT_TAGS} \ No newline at end of file diff --git a/matlab/README-byoi.md b/matlab/README-byoi.md index 06f4467..10b0937 100644 --- a/matlab/README-byoi.md +++ b/matlab/README-byoi.md @@ -2,22 +2,29 @@ `Dockerfile.byoi` showcases a multi-stage build which extracts MATLAB from an existing image that contains MATLAB. +`Dockerfile.byoi` is based on jupyter/base-notebook:python-{python version number}, which is based on **ubuntu22.04**. + +Look in the directory `matlab/ubuntu20.04` for Dockerfiles that are based on `ubuntu20.04`. + Pass the name of your existing MATLAB image to docker build using the `build-time` variable `MATLAB_IMAGE_NAME`. `Dockerfile.byoi` supports the following build-time variables: | Argument Name | Default value | Effect | |---|---|---| -| **MATLAB_IMAGE_NAME** | mathworks/matlab:r2023a | Specify the name of the Docker image that MATLAB should be extracted from. | -| [MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab) | r2023a | The MATLAB release you are using. Used to install its software dependencies.| +| [MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab) | r2023b | The MATLAB release you are using. Used to install its software dependencies.| +| [PYTHON_VERSION](#choose-version-of-python) | 3.10 | Select version of Python used by Jupyter. See [here](https://hub.docker.com/r/jupyter/base-notebook/tags?page=1&name=python-), for list of Python tags available for use. | +| **MATLAB_IMAGE_NAME** | mathworks/matlab:r2023b | Specify the name of the Docker image that MATLAB should be extracted from. | | [LICENSE_SERVER](#build-an-image-with-license-server-information) | *unset* | The port and hostname of the machine that is running the Network License Manager, using the `port@hostname` syntax. For Example: `27000@MyServerName`.
Click [Using the Network License Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile#use-the-network-license-manager) to learn more.| -To build the Docker image, follow these steps: +Listed below is an example of the command to build a Docker image that extracts MATLAB from the image `mathworks/matlab:r2023b` on DockerHub and installs it into `jupyter/base-notebook:python-3.10` with a License Server. ```bash -docker build --build-arg MATLAB_RELEASE=r2023a \ - --build-arg MATLAB_IMAGE_NAME=mathworks/matlab \ - --build-arg LICENSE_SERVER=12345@hostname.com \ - -t maltab-notebook -f Dockerfile.byoi . +docker build --build-arg MATLAB_RELEASE=r2023b \ + --build-arg PYTHON_VERSION=3.10 \ + --build-arg MATLAB_IMAGE_NAME=mathworks/matlab:r2023b \ + --build-arg LICENSE_SERVER=12345@hostname.com \ + -t matlab-notebook -f Dockerfile.byoi . ``` + Start the container using ```bash docker run -it --rm -p 8888:8888 matlab-notebook diff --git a/matlab/README-mounted.md b/matlab/README-mounted.md index fd75d03..f1f0a05 100644 --- a/matlab/README-mounted.md +++ b/matlab/README-mounted.md @@ -2,20 +2,29 @@ To provide a MATLAB installation to the container via a volume or bind mount, instead of installing MATLAB inside the image, follow the instructions below. +`Dockerfile.mounted` is based on jupyter/base-notebook:python-{python version number}, which is based on **ubuntu22.04**. + +Look in the directory `matlab/ubuntu20.04` for Dockerfiles that are based on `ubuntu20.04`. + ### Build the Docker Image -Build a Docker image called `matlab-notebook-nomatlab`, using the file `Dockerfile.mounted`: +Build a Docker image called `matlab-notebook-nomatlab`, using the file `Dockerfile.mounted`. +Listed below is an example of the command to build a Docker image that extracts MATLAB from the image `mathworks/matlab:r2023b` on DockerHub and installs it into `jupyter/base-notebook:python-3.10` with a License Server. ```bash -docker build -f Dockerfile.mounted -t matlab-notebook-nomatlab . +docker build --build-arg MATLAB_RELEASE=r2023b \ + --build-arg PYTHON_VERSION=3.10 \ + --build-arg MATLAB_IMAGE_NAME=mathworks/matlab:r2023b \ + --build-arg LICENSE_SERVER=12345@hostname.com \ + -t matlab-notebook-nomatlab -f Dockerfile.mounted . ``` ### Start the Docker Container -Execute the command below to start a Docker container, bind mount the directory `/usr/local/MATLAB/R2020b` (which must contain a MATLAB R2020b or later 64 bit Linux installation) into the directory `/opt/matlab` inside the container, and bind port 8888 on the host to port 8888 of the container (by default, Jupyter's app-server runs on port 8888 inside the container): +Execute the command below to start a Docker container, bind mount the directory `/usr/local/MATLAB/R2023b` (which must contain a MATLAB R2023b or later 64 bit Linux installation) into the directory `/opt/matlab` inside the container, and bind port 8888 on the host to port 8888 of the container (by default, Jupyter's app-server runs on port 8888 inside the container): ```bash -docker run -it -v /usr/local/MATLAB/R2020b:/opt/matlab:ro -p 8888:8888 matlab-notebook-nomatlab +docker run -it -v /usr/local/MATLAB/R2023b:/opt/matlab:ro -p 8888:8888 matlab-notebook-nomatlab ``` Access the Jupyter Notebook by following one of the URLs displayed in the output of the ```docker run``` command. diff --git a/matlab/README.md b/matlab/README.md index 077e229..16380bd 100644 --- a/matlab/README.md +++ b/matlab/README.md @@ -4,6 +4,10 @@ The `Dockerfile` in this repository builds a Docker® image based on `jupyter/ba The resulting Jupyter environment enables you to start MATLAB in a web browser tab from a Jupyter® notebook. +This `Dockerfile` is based on jupyter/base-notebook:python-{python version number}, which is based on Ubuntu22.04. + +Look in the directory `matlab/ubuntu20.04` for Dockerfiles that are based on `ubuntu20.04`. + If you want to install the MATLAB Integration for Jupyter without using Docker, use the installation instructions in the repository [MATLAB Integration for Jupyter](https://github.com/mathworks/jupyter-matlab-proxy) instead. @@ -40,8 +44,9 @@ The [Dockerfile](https://github.com/mathworks-ref-arch/matlab-integration-for-ju | Argument Name | Default value | Effect | |---|---|---| +| [MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab) | r2023b | The MATLAB release you want to install. **MUST** be newer than `r2020b` and specified in lower-case| | [MATLAB_PRODUCT_LIST](#customize-products-to-install) | MATLAB | Specify the list of products to install using product names separated by spaces. Replace spaces within names with underscores. For example: `MATLAB Simulink Deep_Learning_Toolbox Parallel_Computing_Toolbox`
See [MPM Documentation](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md) for more information.| -| [MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab) | r2023a | The MATLAB release you want to install. **MUST** be newer than `r2020b` and specified in lower-case| +| [PYTHON_VERSION](#choose-version-of-python) | 3.10 | Select version of Python used by Jupyter. See [here](https://hub.docker.com/r/jupyter/base-notebook/tags?page=1&name=python-), for list of Python tags available for use. | | [LICENSE_SERVER](#build-an-image-with-license-server-information) | *unset* | The port and hostname of the machine that is running the Network License Manager, using the `port@hostname` syntax. For Example: `27000@MyServerName`.
Click [Using the Network License Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile#use-the-network-license-manager) to learn more.| ### Customize Products to Install @@ -50,13 +55,21 @@ The [Dockerfile](https://github.com/mathworks-ref-arch/matlab-integration-for-ju To customize the build, use the Docker [build-time variable](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg) `MATLAB_PRODUCT_LIST` to specify the list of products you want to install into the Image. ```bash -docker build --build-arg MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox" -t matlab-notebook . +docker build --build-arg MATLAB_PRODUCT_LIST="MATLAB Symbolic_Math_Toolbox" -t matlab-notebook . ``` ### Build an Image for a Different Release of MATLAB ```bash -# Builds an image with MATLAB R2020b -docker build --build-arg MATLAB_RELEASE=r2020b -t matlab-notebook . +# Builds an image with MATLAB R2023b +docker build --build-arg MATLAB_RELEASE=r2023b -t matlab-notebook . +``` + +### Build an Image with a different version of Python. +The base image used by this Dockerfile is `jupyter/base-notebook:python-{PYTHON_VERSION}` +The full list of the tags available can be found [here](https://hub.docker.com/r/jupyter/base-notebook/tags?page=1&name=python-). +```bash +# Builds an image based on jupyter/base-notebook:python-3.11.5 +docker build --build-arg PYTHON_VERSION=3.11.5 ``` ### Build an Image with License Server Information @@ -76,6 +89,8 @@ To make the image smaller, you can give the Docker container access to a MATLAB * Use `Dockerfile.byoi` to build an image based on an existing Docker image with MATLAB in it. See [README-byoi.md](/matlab/README-byoi.md) +* Images built with this Dockerfile can be downloaded from [here](https://github.com/mathworks-ref-arch/matlab-integration-for-jupyter/pkgs/container/matlab-integration-for-jupyter%2Fjupyter-matlab-notebook/versions?filters%5Bversion_type%5D=tagged). + ## Feedback We encourage you to try this repository with your environment and provide feedback – the technical team is monitoring this repository. If you encounter a technical issue or have an enhancement request, send an email to `jupyter-support@mathworks.com`. \ No newline at end of file diff --git a/matlab/ubuntu20.04/Dockerfile b/matlab/ubuntu20.04/Dockerfile new file mode 100644 index 0000000..7c4be98 --- /dev/null +++ b/matlab/ubuntu20.04/Dockerfile @@ -0,0 +1,128 @@ +# Copyright 2023 The MathWorks, Inc. +# Builds Docker image on Ubuntu 20.04 with: +# 1. MATLAB - Using MPM +# 2. MATLAB Integration for Jupyter +# on a base image of jupyter/base-notebook:ubuntu-20.04 + +## Sample Build Command: +# docker build --build-arg MATLAB_RELEASE=r2023b \ +# --build-arg MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Symbolic_Math_Toolbox"\ +# --build-arg LICENSE_SERVER=12345@hostname.com \ +# -t my_matlab_image_name . + +# This Dockerfile uses jupyter/base-notebook:ubuntu-20.04 as its base layer +# This image only ships with Python 3.10, which limits the versions of the MATLAB Engine for Python that can be installed. +# NOTE: The MATLAB Integration for Jupyter itself will work for any version of MATLAB newer than R2020b. + +## Support for MATLAB Engine for Python by Release +# For more information, see: https://mathworks.com/support/requirements/python-compatibility.html +# MATLAB RELEASE | Supported Python Versions | OS supported by matlab-deps| Notes | +# ---------------|---------------------------|----------------------------|---------------------------------| +# R2023b | 3.9, 3.10, 3.11 | Ubuntu 22.04 & 20.04 | Use Dockerfile for ubuntu-22.04 | +# R2023a | 3.8, 3.9, 3.10 | Ubuntu 22.04 & 20.04 | Use Dockerfile for ubuntu-22.04 | +# R2022b | 3.8, 3.9, 3.10 | Ubuntu 22.04 & 20.04 | Use Dockerfile for ubuntu-22.04 | +# R2022a | 3.8, 3.9 | Ubuntu 20.04 | Cannot install MATLAB Engine for python | +# R2021b | 3.8, 3.9 | Ubuntu 20.04 | Cannot install MATLAB Engine for python | +# R2021a | 3.8 | Ubuntu 20.04 | Cannot install MATLAB Engine for python | +# R2020b | 3.8 | Ubuntu 20.04 | Cannot install MATLAB Engine for python | + +# Specify release of MATLAB to build. (use lowercase, default is r2023b) +ARG MATLAB_RELEASE=r2023b + +# Specify the list of products to install into MATLAB, +ARG MATLAB_PRODUCT_LIST="MATLAB" + +# Optional Network License Server information +ARG LICENSE_SERVER + +# If LICENSE_SERVER is provided then SHOULD_USE_LICENSE_SERVER will be set to "_use_lm" +ARG SHOULD_USE_LICENSE_SERVER=${LICENSE_SERVER:+"_with_lm"} + +# Default DDUX information +ARG MW_CONTEXT_TAGS=MATLAB_PROXY:JUPYTER:MPM:V1 + +# Base Jupyter ubuntu 20.04 image without LICENSE_SERVER +FROM jupyter/base-notebook:ubuntu-20.04 AS base_jupyter_image + +# Base Jupyter ubuntu 20.04 image with LICENSE_SERVER +FROM jupyter/base-notebook:ubuntu-20.04 AS base_jupyter_image_with_lm +ARG LICENSE_SERVER +# If license server information is available, then use it to set environment variable +ENV MLM_LICENSE_FILE=${LICENSE_SERVER} + +# Select base Jupyter image based on whether LICENSE_SERVER is provided +FROM base_jupyter_image${SHOULD_USE_LICENSE_SERVER} +ARG MW_CONTEXT_TAGS +ARG MATLAB_RELEASE +ARG MATLAB_PRODUCT_LIST + +# Switch to root user +USER root +ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" + +## Installing Dependencies for Ubuntu 20.04 +# For MATLAB : Get base-dependencies.txt from matlab-deps repository on GitHub +# For mpm : wget, unzip, ca-certificates +# For MATLAB Integration for Jupyter : xvfb +# List of MATLAB Dependencies for Ubuntu 20.04 and specified MATLAB_RELEASE +ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu20.04/base-dependencies.txt" +ARG MATLAB_DEPS_REQUIREMENTS_FILE_NAME="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt" + +# Install dependencies +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ + && apt-get install --no-install-recommends -y \ + wget \ + unzip \ + ca-certificates \ + xvfb \ + git \ + && wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} \ + && xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ + && apt-get clean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} + +# Run mpm to install MATLAB in the target location and delete the mpm installation afterwards +RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm && \ + chmod +x mpm && \ + ./mpm install \ + --release=${MATLAB_RELEASE} \ + --destination=/opt/matlab \ + --products ${MATLAB_PRODUCT_LIST} && \ + rm -f mpm /tmp/mathworks_root.log && \ + ln -s /opt/matlab/bin/matlab /usr/local/bin/matlab + +# Install patched glibc - See https://github.com/mathworks/build-glibc-bz-19329-patch +WORKDIR /packages +RUN export DEBIAN_FRONTEND=noninteractive && \ + apt-get update && apt-get clean && apt-get autoremove && \ + wget -q https://github.com/mathworks/build-glibc-bz-19329-patch/releases/download/ubuntu-focal/all-packages.tar.gz && \ + tar -x -f all-packages.tar.gz \ + --exclude glibc-*.deb \ + --exclude libc6-dbg*.deb && \ + apt-get install --yes --no-install-recommends --allow-downgrades ./*.deb && \ + rm -fr /packages +WORKDIR / + +# The default Python 3.10 used in this image is only supported for MATLAB releases R2023b, R2023a, R2022b. +# Optional: Install MATLAB Engine for Python, if possible. +# Note: Failure to install does not stop the build. +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ + && apt-get install --no-install-recommends -y python3-distutils \ + && apt-get clean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* \ + && cd /opt/matlab/extern/engines/python \ + && python setup.py install || true + +# Switch back to notebook user +USER $NB_USER +WORKDIR /home/${NB_USER} + +# Install integration +RUN python -m pip install jupyter-matlab-proxy + +# Make JupyterLab the default environment +ENV JUPYTER_ENABLE_LAB="yes" + +ENV MW_CONTEXT_TAGS=${MW_CONTEXT_TAGS} \ No newline at end of file diff --git a/matlab/ubuntu20.04/Dockerfile.byoi b/matlab/ubuntu20.04/Dockerfile.byoi new file mode 100644 index 0000000..aa79e5d --- /dev/null +++ b/matlab/ubuntu20.04/Dockerfile.byoi @@ -0,0 +1,150 @@ +# Copyright 2023 The MathWorks, Inc. +# Builds Docker image with +# 1. MATLAB - Your existing image with MATLAB +# 2. MATLAB Integration for Jupyter +# on a base image of jupyter/base-notebook:ubuntu-20.04 + +## Sample Build Command: +# docker build --build-arg MATLAB_RELEASE=r2023b \ +# --build-arg MATLAB_IMAGE_NAME=mathworks/matlab \ +# --build-arg LICENSE_SERVER=12345@hostname.com \ +# -t my_matlab_image_name -f Dockerfile.byoi . + +# This Dockerfile uses jupyter/base-notebook:ubuntu-20.04 as its base layer +# This image only ships with Python 3.10, which limits the versions of the MATLAB Engine for Python that can be installed. +# NOTE: The MATLAB Integration for Jupyter itself will work for any version of MATLAB newer than R2020b. + +## Support for MATLAB Engine for Python by Release +# For more information, see: https://mathworks.com/support/requirements/python-compatibility.html +# MATLAB RELEASE | Supported Python Versions | OS supported by matlab-deps| Notes | +# ---------------|---------------------------|----------------------------|---------------------------------| +# R2023b | 3.9, 3.10, 3.11 | Ubuntu 22.04 & 20.04 | Use Dockerfile for ubuntu-22.04 | +# R2023a | 3.8, 3.9, 3.10 | Ubuntu 22.04 & 20.04 | Use Dockerfile for ubuntu-22.04 | +# R2022b | 3.8, 3.9, 3.10 | Ubuntu 22.04 & 20.04 | Use Dockerfile for ubuntu-22.04 | +# R2022a | 3.8, 3.9 | Ubuntu 20.04 | Cannot install MATLAB Engine for python | +# R2021b | 3.8, 3.9 | Ubuntu 20.04 | Cannot install MATLAB Engine for python | +# R2021a | 3.8 | Ubuntu 20.04 | Cannot install MATLAB Engine for python | +# R2020b | 3.8 | Ubuntu 20.04 | Cannot install MATLAB Engine for python | + +# Specify release of MATLAB to build. (use lowercase, default is r2023b) +ARG MATLAB_RELEASE=r2023b + +# See https://hub.docker.com/r/jupyter/base-notebook/tags to pick the appropriate tag. +ARG BASE_NOTEBOOK_TAG=ubuntu-20.04 + +ARG DEFAULT_IMAGE_FROM_DOCKERHUB=mathworks/matlab:${MATLAB_RELEASE} + +# Specify name of Docker Image with MATLAB already installed. +ARG MATLAB_IMAGE_NAME=${DEFAULT_IMAGE_FROM_DOCKERHUB} + +# Optional Network License Server information +ARG LICENSE_SERVER + +# If LICENSE_SERVER is provided then SHOULD_USE_LICENSE_SERVER will be set to "_use_lm" +ARG SHOULD_USE_LICENSE_SERVER=${LICENSE_SERVER:+"_with_lm"} + +# Default DDUX information, BYOI = Bring your own MATLAB Image +ARG MW_CONTEXT_TAGS=MATLAB_PROXY:JUPYTER:BYOI:V1 + +# Argument shared across multi-stage build to hold location of installed MATLAB +ARG BASE_ML_INSTALL_LOC=/tmp/matlab-install-location + +# Locating MATLAB in the provided image. +# MATLAB should be available on the path in the Docker image +FROM ${MATLAB_IMAGE_NAME} AS matlab-install-stage +ARG BASE_ML_INSTALL_LOC + +# Run code to locate a MATLAB install in the base image and softlink +# to BASE_ML_INSTALL_LOC for a latter stage to copy +RUN export ML_INSTALL_LOC=$(which matlab) \ + && if [ ! -z "$ML_INSTALL_LOC" ]; then \ + ML_INSTALL_LOC=$(dirname $(dirname $(readlink -f ${ML_INSTALL_LOC}))); \ + echo "soft linking: " $ML_INSTALL_LOC " to" ${BASE_ML_INSTALL_LOC}; \ + ln -s ${ML_INSTALL_LOC} ${BASE_ML_INSTALL_LOC}; \ + elif [ $BASE_ML_INSTALL_LOC = '/tmp/matlab-install-location' ]; then \ + echo "MATLAB was not found in your image."; exit 1; \ + else \ + echo "Proceeding with user provided path to MATLAB installation: ${BASE_ML_INSTALL_LOC}"; \ + fi + +# Base Jupyter image without LICENSE_SERVER +FROM jupyter/base-notebook:${BASE_NOTEBOOK_TAG} AS base_jupyter_image + +# Base Jupyter image with LICENSE_SERVER +FROM jupyter/base-notebook:${BASE_NOTEBOOK_TAG} AS base_jupyter_image_with_lm +ARG LICENSE_SERVER +# If license server information is available, then use it to set environment variable +ENV MLM_LICENSE_FILE=${LICENSE_SERVER} + +# Select base Jupyter image based on whether LICENSE_SERVER is provided +FROM base_jupyter_image${SHOULD_USE_LICENSE_SERVER} +ARG MW_CONTEXT_TAGS +ARG MATLAB_RELEASE +ARG BASE_ML_INSTALL_LOC + +# Switch to root user +USER root +ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" + +# Copy MATLAB install from supplied Docker image +ARG MATLAB_INSTALL_LOCATION="/opt/matlab" +COPY --from=matlab-install-stage ${BASE_ML_INSTALL_LOC} ${MATLAB_INSTALL_LOCATION} + +# Put MATLAB on the PATH +RUN ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab + +## Installing Dependencies for Ubuntu 20.04 +# For MATLAB : Get base-dependencies.txt from matlab-deps repository on GitHub +# For MATLAB Integration for Jupyter : xvfb + +# List of MATLAB Dependencies for Ubuntu 20.04 and specified MATLAB_RELEASE +ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu20.04/base-dependencies.txt" +ARG MATLAB_DEPS_REQUIREMENTS_FILE_NAME="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt" + +# Install dependencies +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ + && apt-get install --no-install-recommends -y \ + wget \ + unzip \ + ca-certificates \ + xvfb \ + git \ + && wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} \ + && xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ + && apt-get clean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} + +# Install patched glibc - See https://github.com/mathworks/build-glibc-bz-19329-patch +WORKDIR /packages +RUN export DEBIAN_FRONTEND=noninteractive && \ + apt-get update && apt-get clean && apt-get autoremove && \ + wget -q https://github.com/mathworks/build-glibc-bz-19329-patch/releases/download/ubuntu-focal/all-packages.tar.gz && \ + tar -x -f all-packages.tar.gz \ + --exclude glibc-*.deb \ + --exclude libc6-dbg*.deb && \ + apt-get install --yes --no-install-recommends --allow-downgrades ./*.deb && \ + rm -fr /packages +WORKDIR / + +# Optional: Install MATLAB Engine for Python, if possible. +# Note: Failure to install does not stop the build. +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ + && apt-get install --no-install-recommends -y python3-distutils \ + && apt-get clean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* \ + && cd ${MATLAB_INSTALL_LOCATION}/extern/engines/python \ + && python setup.py install || true + +# Switch back to notebook user +USER $NB_USER +WORKDIR /home/${NB_USER} + +# Install integration +RUN python -m pip install jupyter-matlab-proxy + +# Make JupyterLab the default environment +ENV JUPYTER_ENABLE_LAB="yes" + +ENV MW_CONTEXT_TAGS=${MW_CONTEXT_TAGS} \ No newline at end of file diff --git a/matlab/ubuntu20.04/Dockerfile.mounted b/matlab/ubuntu20.04/Dockerfile.mounted new file mode 100644 index 0000000..fde9a03 --- /dev/null +++ b/matlab/ubuntu20.04/Dockerfile.mounted @@ -0,0 +1,111 @@ +# Copyright 2023 The MathWorks, Inc. +# Builds Docker image with +# 1. MATLAB Integration for Jupyter +# on a base image of jupyter/base-notebook:ubuntu-20.04 +# Folder with the MATLAB installation needs to be mounted into the image at /opt/matlab + +## Sample Build Command: +# docker build --build-arg MATLAB_RELEASE=r2023b \ +# --build-arg LICENSE_SERVER=12345@hostname.com \ +# -t my_matlab_image_name . + +## Support for MATLAB Engine for Python by Release +# For more information, see: https://mathworks.com/support/requirements/python-compatibility.html +# MATLAB RELEASE | Supported Python Versions | OS supported by matlab-deps|Supported by this Dockerfile | +# ---------------|---------------------------|----------------------------|-----------------------------| +# R2023b | 3.9, 3.10, 3.11 | Ubuntu 22.04 & 20.04 | Yes | +# R2023a | 3.8, 3.9, 3.10 | Ubuntu 22.04 & 20.04 | Yes | +# R2022b | 3.8, 3.9, 3.10 | Ubuntu 22.04 & 20.04 | Yes | +# R2022a | 3.8, 3.9 | Ubuntu 20.04 | Yes | +# R2021b | 3.8, 3.9 | Ubuntu 20.04 | Yes | +# R2021a | 3.8 | Ubuntu 20.04 | Yes | +# R2020b | 3.8 | Ubuntu 20.04 | Yes | + +# Specify release of MATLAB being mounted. (use lowercase, default is r2023b) +# Used to fetch & install MATLAB's s/w dependencies +ARG MATLAB_RELEASE=r2023b + +# Optional Network License Server information in the form of port@hostname +ARG LICENSE_SERVER + +# If LICENSE_SERVER is provided then SHOULD_USE_LICENSE_SERVER will be set to "_use_lm" +ARG SHOULD_USE_LICENSE_SERVER=${LICENSE_SERVER:+"_with_lm"} + +# Default DDUX information +ARG MW_CONTEXT_TAGS=MATLAB_PROXY:JUPYTER:MOUNTED:V1 + +# Base Jupyter image without LICENSE_SERVER +FROM jupyter/base-notebook:ubuntu-20.04 AS base_image + +# Base Jupyter image with LICENSE_SERVER +FROM jupyter/base-notebook:ubuntu-20.04 AS base_image_with_lm +ARG LICENSE_SERVER +# If license server information is available, then use it to set environment variable +ENV MLM_LICENSE_FILE=${LICENSE_SERVER} + +# Select base Jupyter image based on whether LICENSE_SERVER is provided +FROM base_image${SHOULD_USE_LICENSE_SERVER} +ARG MW_CONTEXT_TAGS +ARG MATLAB_RELEASE + +# Switch to root user +USER root +ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" + +# Put MATLAB on the PATH +RUN ln -s /opt/matlab/bin/matlab /usr/local/bin/matlab + +## Installing Dependencies for Ubuntu 20.04: +# For MATLAB : Get base-dependencies.txt from matlab-deps repository on GitHub +# For MATLAB Integration for Jupyter : xvfb + +# List of MATLAB Dependencies for Ubuntu 20.04 and specified MATLAB_RELEASE +ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu20.04/base-dependencies.txt" +ARG MATLAB_DEPS_REQUIREMENTS_FILE_NAME="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt" + +# Install dependencies +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ + && apt-get install --no-install-recommends -y \ + wget \ + xvfb \ + git \ + && wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} \ + && xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \ + && apt-get clean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} + +# Install patched glibc - See https://github.com/mathworks/build-glibc-bz-19329-patch +WORKDIR /packages +RUN export DEBIAN_FRONTEND=noninteractive && \ + apt-get update && apt-get clean && apt-get autoremove && \ + wget -q https://github.com/mathworks/build-glibc-bz-19329-patch/releases/download/ubuntu-focal/all-packages.tar.gz && \ + tar -x -f all-packages.tar.gz \ + --exclude glibc-*.deb \ + --exclude libc6-dbg*.deb && \ + apt-get install --yes --no-install-recommends --allow-downgrades ./*.deb && \ + rm -fr /packages +WORKDIR / + +# The default Python 3.10 used in this image is only supported for MATLAB releases R2023b, R2023a, R2022b. +# Optional: Install MATLAB Engine for Python, if possible. +# Note: Failure to install does not stop the build. +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ + && apt-get install --no-install-recommends -y python3-distutils \ + && apt-get clean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* \ + && cd /opt/matlab/extern/engines/python \ + && python setup.py install || true + +# Switch back to notebook user +USER $NB_USER +WORKDIR /home/${NB_USER} + +# Install integration +RUN python -m pip install jupyter-matlab-proxy + +# Make JupyterLab the default environment +ENV JUPYTER_ENABLE_LAB="yes" + +ENV MW_CONTEXT_TAGS=${MW_CONTEXT_TAGS}