Skip to content

Commit

Permalink
Updates MATLAB installation paths to consistenly use "/opt/matlab/R20…
Browse files Browse the repository at this point in the history
…XXY" as the default installation path, Silent installer workflows will continue to use "/usr/local/MATLAB" to match the behavior of the standard GUI based installer.

fixes #107
  • Loading branch information
epaganon authored and Prabhakar Kumar committed Sep 2, 2024
1 parent 495630c commit cca0724
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 92 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Each time the image passes the qualification, it is pushed to the GitHub Contain

`ghcr.io/mathworks-ref-arch/matlab-dockerfile/matlab:${matlab-release}`

where `${matlab-release}` is a matlab release (e.g. `r2021a`, `r2021b`, etc..) .
where `${matlab-release}` is a matlab release (e.g. `R2021a`, `R2021b`, etc..) .

## Workflow Description

The workflow consists of a one-dimensional matrix of jobs. Each job builds, tests and publishes the container image for a different MATLAB release, starting from `r2020b`. To ensure that a failure in any job does not cancel other jobs, the `fail-fast` option is set to `false`.
The workflow consists of a one-dimensional matrix of jobs. Each job builds, tests and publishes the container image for a different MATLAB release, starting from `R2020b`. To ensure that a failure in any job does not cancel other jobs, the `fail-fast` option is set to `false`.

Each job consists of the following steps:

Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/build-test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- "Dockerfile"
- "tests/*"
- "tests/utils/**"
- ".github/workflows/build-test-publish.yml"
- "!**.md"
schedule:
# Run at 00:00 on every Monday (1st Day of the Week)
Expand All @@ -27,7 +28,7 @@ jobs:
strategy:
fail-fast: false
matrix:
matlab-release: [r2024a, r2023b, r2023a, r2022b, r2022a, r2021b, r2021a, r2020b]
matlab-release: [R2024a, R2023b, R2023a, R2022b, R2022a, R2021b, R2021a, R2020b]

steps:
- name: Checkout repo
Expand Down Expand Up @@ -70,7 +71,15 @@ jobs:
env:
IMAGE_NAME: ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }}
working-directory: tests
run: python -m unittest
run: python -m unittest -v

- name: Push the image to ghcr.io
run: docker push ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }}
env:
MATLAB_RELEASE: ${{ matrix.matlab-release }}
run: |
LOWERCASE_RELEASE=${MATLAB_RELEASE,,}
UPPERCASE_RELEASE=${LOWERCASE_RELEASE^}
docker tag ${{ env.IMAGE_BASE_NAME }}:${MATLAB_RELEASE} ${{ env.IMAGE_BASE_NAME }}:${LOWERCASE_RELEASE}
docker tag ${{ env.IMAGE_BASE_NAME }}:${MATLAB_RELEASE} ${{ env.IMAGE_BASE_NAME }}:${UPPERCASE_RELEASE}
docker push ${{ env.IMAGE_BASE_NAME }}:${LOWERCASE_RELEASE}
docker push ${{ env.IMAGE_BASE_NAME }}:${UPPERCASE_RELEASE}
3 changes: 2 additions & 1 deletion .github/workflows/from-matlab-docker-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- "alternates/building-on-matlab-docker-image/Dockerfile"
- "tests/alternates/building-on-matlab-docker-image/*"
- "tests/utils/**"
- ".github/workflows/from-matlab-docker-build-test.yml"
- "!**.md"
schedule:
# Run at 00:00 on every Monday (1st Day of the Week)
Expand All @@ -28,7 +29,7 @@ jobs:
strategy:
fail-fast: false
matrix:
matlab-release: [r2024a, r2023b, r2023a, r2022b, r2022a]
matlab-release: [R2024a, R2023b, R2023a, R2022b, R2022a]

steps:
- name: Checkout repo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- "alternates/matlab-container-offline-install/Dockerfile"
- "tests/alternates/matlab-container-offline-install/*"
- "tests/utils/**"
- ".github/workflows/matlab-container-offline-install-build-test.yml"
- "!**.md"
schedule:
# Run at 00:00 on every Monday (1st Day of the Week)
Expand All @@ -31,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
matlab-release: [r2024a, r2023b, r2023a, r2022b, r2022a, r2021b, r2021a, r2020b]
matlab-release: [R2024a, R2023b, R2023a, R2022b, R2022a, R2021b, R2021a, R2020b]

steps:
- name: Checkout repo
Expand Down Expand Up @@ -87,6 +88,4 @@ jobs:
working-directory: tests
env:
IMAGE_NAME: ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }}
run: |
python -m unittest ${{ env.ALT_PATH }}/test_container.py
python -m unittest ${{ env.ALT_PATH }}/test_installed_products.py
run: python -m unittest -v ${{ env.ALT_PATH }}/*.py
5 changes: 3 additions & 2 deletions .github/workflows/matlab-installer-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- "alternates/matlab-installer/Dockerfile"
- "tests/alternates/matlab-installer/*"
- "tests/utils/**"
- ".github/workflows/matlab-installer-build-test.yml"
- "!**.md"
schedule:
# Run at 00:00 on every Monday (1st Day of the Week)
Expand All @@ -30,7 +31,7 @@ jobs:
strategy:
fail-fast: false
matrix:
matlab-release: [r2024a, r2023b, r2023a, r2022b, r2022a, r2021b, r2021a, r2020b]
matlab-release: [R2024a, R2023b, R2023a, R2022b, R2022a, R2021b, R2021a, R2020b]

steps:
- name: Checkout repo
Expand Down Expand Up @@ -71,4 +72,4 @@ jobs:
working-directory: tests
env:
IMAGE_NAME: ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }}
run: python -m unittest ${{ env.ALT_PATH }}/test_mock_matlab_container.py
run: python -m unittest -v ${{ env.ALT_PATH }}/*.py
21 changes: 16 additions & 5 deletions .github/workflows/non-interactive-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ on:
# Trigger the workflow when the Dockerfile or any file under tests/ is modified
paths:
- "alternates/non-interactive/Dockerfile"
- "alternates/non-interactive/MATLAB-BATCH.md"
- "tests/**"
- "tests/alternates/non-interactive/*"
- "tests/utils/**"
- ".github/workflows/non-interactive-build-test.yml"
- "!**.md"
schedule:
# Run at 00:00 on every Monday (1st Day of the Week)
- cron: "0 0 * * 1"

env:
IMAGE_BASE_NAME: matlab-non-interactive
IMAGE_BASE_NAME: ghcr.io/${{ github.repository }}/matlab-non-interactive
ALT_PATH: alternates/non-interactive

jobs:
Expand All @@ -28,7 +29,7 @@ jobs:
fail-fast: false
matrix:
matlab-release:
[r2024a, r2023b, r2023a, r2022b, r2022a, r2021b, r2021a, r2020b]
[R2024a, R2023b, R2023a, R2022b, R2022a, R2021b, R2021a, R2020b]

steps:
- name: Checkout repo
Expand Down Expand Up @@ -63,5 +64,15 @@ jobs:
env:
IMAGE_NAME: ${{ env.IMAGE_BASE_NAME }}:${{ matrix.matlab-release }}
BATCH_TOKEN: ${{ secrets.MATLAB_BATCH_TOKEN_EXPIRES_03_2025 }}
run: python -m unittest -v ${{ env.ALT_PATH }}/*.py

- name: Push the image to ghcr.io
env:
MATLAB_RELEASE: ${{ matrix.matlab-release }}
run: |
python -m unittest ${{ env.ALT_PATH }}/test_matlabbatch.py
LOWERCASE_RELEASE=${MATLAB_RELEASE,,}
UPPERCASE_RELEASE=${LOWERCASE_RELEASE^}
docker tag ${{ env.IMAGE_BASE_NAME }}:${MATLAB_RELEASE} ${{ env.IMAGE_BASE_NAME }}:${LOWERCASE_RELEASE}
docker tag ${{ env.IMAGE_BASE_NAME }}:${MATLAB_RELEASE} ${{ env.IMAGE_BASE_NAME }}:${UPPERCASE_RELEASE}
docker push ${{ env.IMAGE_BASE_NAME }}:${LOWERCASE_RELEASE}
docker push ${{ env.IMAGE_BASE_NAME }}:${UPPERCASE_RELEASE}
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# install, and the location at which to install MATLAB.

# Here is an example docker build command with the optional build arguments.
# docker build --build-arg MATLAB_RELEASE=r2024a
# docker build --build-arg MATLAB_RELEASE=R2024a
# --build-arg MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Symbolic_Math_Toolbox"
# --build-arg MATLAB_INSTALL_LOCATION="/opt/matlab/R2024a"
# --build-arg [email protected]
# -t my_matlab_image_name .

# To specify which MATLAB release to install in the container, edit the value of the MATLAB_RELEASE argument.
# Use lowercase to specify the release, for example: ARG MATLAB_RELEASE=r2021b
ARG MATLAB_RELEASE=r2024a
# Use uppercase to specify the release, for example: ARG MATLAB_RELEASE=R2021b
ARG MATLAB_RELEASE=R2024a

# Specify the list of products to install into MATLAB.
ARG MATLAB_PRODUCT_LIST="MATLAB"
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ cd matlab-dockerfile

Build container with a name and tag of your choice.
```bash
docker build -t matlab:r2024a .
docker build -t matlab:R2024a .
```

Run the container. Test the container by running an example MATLAB command such as ver.
```bash
docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab:r2024a -batch ver
docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab:R2024a -batch ver
```
The [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/Dockerfile) defaults to building a container for MATLAB R2024a.

Expand All @@ -57,9 +57,9 @@ The [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/ma

| Argument Name | Default value | Description |
|---|---|---|
| [MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab) | r2024a | The MATLAB release you want to install, in lower-case. For example: `r2019b`|
| [MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab) | R2024a | The MATLAB release you want to install, in lower-case. For example: `R2019b`|
| [MATLAB_PRODUCT_LIST](#build-an-image-with-a-specific-set-of-products) | MATLAB | Products to install as a space-separated list. For more information, see [MPM.md](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md). For example: `MATLAB Simulink Deep_Learning_Toolbox Fixed-Point_Designer`|
| [MATLAB_INSTALL_LOCATION](#build-an-image-with-matlab-installed-to-a-specific-location) | /opt/matlab/r2024a | The path to install MATLAB. |
| [MATLAB_INSTALL_LOCATION](#build-an-image-with-matlab-installed-to-a-specific-location) | /opt/matlab/R2024a | The path to install MATLAB. |
| [LICENSE_SERVER](#build-an-image-configured-to-use-a-license-server) | *unset* | The port and hostname of the machine that is running the Network License Manager, using the `port@hostname` syntax. For example: `27000@MyServerName` |

Use these arguments with the the `docker build` command to customize your image.
Expand All @@ -68,30 +68,30 @@ Alternatively, you can change the default values for these arguments directly in
#### Build an Image for a Different Release of MATLAB
For example, to build an image for MATLAB R2019b, use this command.
```bash
docker build --build-arg MATLAB_RELEASE=r2019b -t matlab:r2019b .
docker build --build-arg MATLAB_RELEASE=R2019b -t matlab:R2019b .
```

#### Build an Image with a specific set of products
For example, to build an image with MATLAB and Simulink®, use this command.
```bash
docker build --build-arg MATLAB_PRODUCT_LIST='MATLAB Simulink' -t matlab:r2024a .
docker build --build-arg MATLAB_PRODUCT_LIST='MATLAB Simulink' -t matlab:R2024a .
```

#### Build an Image with MATLAB installed to a specific location
For example, to build an image with MATLAB installed at /opt/matlab, use this command.
```bash
docker build --build-arg MATLAB_INSTALL_LOCATION='/opt/matlab' -t matlab:r2024a .
docker build --build-arg MATLAB_INSTALL_LOCATION='/opt/matlab' -t matlab:R2024a .
```

#### Build an Image Configured to Use a License Server

Including the license server information with the `docker build` command means you do not have to pass it when running the container.
```bash
# Build container with the License Server.
docker build --build-arg LICENSE_SERVER=27000@MyServerName -t matlab:r2024a .
docker build --build-arg LICENSE_SERVER=27000@MyServerName -t matlab:R2024a .

# Run the container, without needing to pass license information.
docker run --init --rm matlab:r2024a -batch ver
docker run --init --rm matlab:R2024a -batch ver
```

## Use the Network License Manager
Expand Down Expand Up @@ -124,7 +124,7 @@ With the `docker build` command, either:

```bash
# Example
docker build -t matlab:r2024a --build-arg LICENSE_SERVER=27000@MyServerName .
docker build -t matlab:R2024a --build-arg LICENSE_SERVER=27000@MyServerName .
```
- Use the `network.lic` file:
1. Place the `network.lic` file in the same folder as the Dockerfile.
Expand All @@ -133,41 +133,41 @@ With the `docker build` command, either:

```bash
# Example
docker build -t matlab:r2024a .
docker build -t matlab:R2024a .
```

With the `docker run` command, use the `MLM_LICENSE_FILE` environment variable. For example:

```bash
docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab:r2024a -batch ver
docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab:R2024a -batch ver
```

## Run the Container
If you did not provide the license server information when building the image, then provide it when running the container. Set the environment variable `MLM_LICENSE_FILE` using the `-e` flag, with the network license manager's location in the format `port@hostname`.
```bash
# Start MATLAB, print version information, and exit:
docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab:r2024a -batch ver
docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab:R2024a -batch ver
```
You can run the container **without** specifying `MLM_LICENSE_FILE` if you provided the license server information when building the image, as shown in the examples below.
### Run MATLAB in an Interactive Command Prompt
To start the container and run MATLAB in an interactive command prompt, execute:
```bash
docker run --init -it --rm matlab:r2024a
docker run --init -it --rm matlab:R2024a
```
### Run MATLAB in Batch Mode
To start the container, run a MATLAB command, and then exit, execute:
```bash
# Container runs the command RAND in MATLAB and exits.
docker run --init --rm matlab:r2024a -batch rand
docker run --init --rm matlab:R2024a -batch rand
```
### Run MATLAB with Startup Options
To override the default behavior of the container and run MATLAB with any set of arguments, such as `-logfile`, execute:
```bash
docker run --init -it --rm matlab:r2024a -logfile "logfilename.log"
docker run --init -it --rm matlab:R2024a -logfile "logfilename.log"
```
To learn more, see the documentation: [Commonly Used Startup Options](https://www.mathworks.com/help/matlab/matlab_env/commonly-used-startup-options.html).
Expand Down
4 changes: 2 additions & 2 deletions alternates/building-on-matlab-docker-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright 2023-2024 The MathWorks, Inc.

# To specify which MATLAB release to install in the container, edit the value of the MATLAB_RELEASE argument.
# Use lower case to specify the release, for example: ARG MATLAB_RELEASE=r2021b
ARG MATLAB_RELEASE=r2024a
# Use uppercase to specify the release, for example: ARG MATLAB_RELEASE=R2021b
ARG MATLAB_RELEASE=R2024a

# Specify the extra products to install into the image. These products can either be toolboxes or support packages.
ARG ADDITIONAL_PRODUCTS="Symbolic_Math_Toolbox Deep_Learning_Toolbox_Model_for_ResNet-50_Network"
Expand Down
18 changes: 9 additions & 9 deletions alternates/building-on-matlab-docker-image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ cd matlab-dockerfile/alternates/building-on-matlab-docker-image
### Quick start
Build a container with a name and tag.
```bash
docker build -t matlab_with_add_ons:r2024a .
docker build -t matlab_with_add_ons:R2024a .
```

You can then run the container with the "batch" option. Test the container by running an example MATLAB command such as `ver` to display the installed toolboxes.
```bash
docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab_with_add_ons:r2024a -batch ver
docker run --init --rm -e MLM_LICENSE_FILE=27000@MyServerName matlab_with_add_ons:R2024a -batch ver
```
You can check the installed support packages using the MATLAB command `matlabshared.supportpkg.getInstalled`.

You can also run the container with the "browser" option to access MATLAB in a browser.
```bash
docker run --init --rm -it -p 8888:8888 matlab_with_add_ons:r2024a -browser
docker run --init --rm -it -p 8888:8888 matlab_with_add_ons:R2024a -browser
```
For more information, see [Run the Container](#run-the-container).

Expand All @@ -51,7 +51,7 @@ The `ADDITIONAL_PRODUCTS` argument must be a space separated list surrounded by
By default, `ADDITIONAL_PRODUCTS` includes example products, which you can replace.
For example, to build an image containing MATLAB and the Deep Learning Toolbox™:
```bash
docker build --build-arg ADDITIONAL_PRODUCTS="Deep_Learning_Toolbox" -t matlab_with_add_ons:r2024a .
docker build --build-arg ADDITIONAL_PRODUCTS="Deep_Learning_Toolbox" -t matlab_with_add_ons:R2024a .
```

For a successful build, include at least one product.
Expand All @@ -67,7 +67,7 @@ The [Dockerfile](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/ma

| Argument Name | Default value | Effect |
|---|---|---|
| [MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab) | r2024a | The MATLAB release to install. Must be lower-case, for example: `r2020b`.|
| [MATLAB_RELEASE](#build-an-image-for-a-different-release-of-matlab) | R2024a | The MATLAB release to install. Must be lower-case, for example: `R2020b`.|
| [ADDITIONAL_PRODUCTS](#customize-products-to-install-using-matlab-package-manager-mpm) | "Symbolic_Math_Toolbox Deep_Learning_Toolbox_Model_for_ResNet-50_Network" | A space separated list of toolboxes and support packages to install. For more details, see [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md)|
| [LICENSE_SERVER](#build-an-image-with-license-server-information) | *unset* | The port and hostname of a machine that is running a Network License Manager, using the `port@hostname` syntax. For example: `27000@MyServerName`. To use this build argument, the corresponding lines must be uncommented in the Dockerfile. |

Expand All @@ -79,12 +79,12 @@ directly in the Dockerfile.

For example, to build an image for MATLAB R2022b, use the following command.
```bash
docker build --build-arg MATLAB_RELEASE=r2022b -t matlab_with_add_ons:r2022b .
docker build --build-arg MATLAB_RELEASE=R2022b -t matlab_with_add_ons:R2022b .
```

To build an image for MATLAB R2022b with Deep Learning Toolbox and Parallel Computing Toolbox™, use the following command.
```bash
docker build --build-arg MATLAB_RELEASE=r2022b --build-arg ADDITIONAL_PRODUCTS="Deep_Learning_Toolbox Parallel_Computing_Toolbox" -t matlab_with_add_ons:r2022b .
docker build --build-arg MATLAB_RELEASE=R2022b --build-arg ADDITIONAL_PRODUCTS="Deep_Learning_Toolbox Parallel_Computing_Toolbox" -t matlab_with_add_ons:R2022b .
```
For supported releases see [MATLAB Container Image on Docker Hub](https://hub.docker.com/r/mathworks/matlab).
### Build an Image with License Server Information
Expand All @@ -95,12 +95,12 @@ server or browser mode will not start successfully.

Build container with the License Server.
```bash
docker build -t matlab_with_add_ons:r2024a --build-arg LICENSE_SERVER=27000@MyServerName .
docker build -t matlab_with_add_ons:R2024a --build-arg LICENSE_SERVER=27000@MyServerName .
```

Run the container, without needing to pass license information.
```bash
docker run --init matlab_with_add_ons:r2024a -batch ver
docker run --init matlab_with_add_ons:R2024a -batch ver
```
## Run the Container
The Docker container you build using this Dockerfile inherits run options from its base image.
Expand Down
6 changes: 3 additions & 3 deletions alternates/matlab-container-offline-install/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# install, and the location at which to install MATLAB.

# Here is an example docker build command with the optional build arguments.
# docker build --build-arg MATLAB_RELEASE=r2024a
# docker build --build-arg MATLAB_RELEASE=R2024a
# --build-arg MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Symbolic_Math_Toolbox"
# --build-arg MATLAB_INSTALL_LOCATION="/opt/matlab/R2024a"
# -t my_matlab_image_name .

# To specify which MATLAB release to install in the container, edit the value of the MATLAB_RELEASE argument.
# Use lowercase to specify the release, for example: ARG MATLAB_RELEASE=r2021b
ARG MATLAB_RELEASE=r2024a
# Use uppercase to specify the release, for example: ARG MATLAB_RELEASE=R2021b
ARG MATLAB_RELEASE=R2024a

# Specify the list of products to install into MATLAB.
ARG MATLAB_PRODUCT_LIST="MATLAB"
Expand Down
Loading

0 comments on commit cca0724

Please sign in to comment.