Skip to content

Commit 9847abc

Browse files
committed
Update minimum node requirement to Node 24, with faster builds, and introduces devcontainer configurations to develop on CodeSpaces or VSCode DevContainers.
1 parent 77ebce0 commit 9847abc

File tree

15 files changed

+2168
-1613
lines changed

15 files changed

+2168
-1613
lines changed

.devcontainer/Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2025 The MathWorks, Inc.
2+
3+
# Light weight image only to test builds of matlab-proxy
4+
5+
ARG PYTHON_VERSION=3.11
6+
ARG NODE_VERSION=20
7+
ARG NVM_VERSION="0.40.3"
8+
9+
FROM ubuntu:24.04
10+
11+
ARG NVM_VERSION
12+
ARG PYTHON_VERSION
13+
ARG NODE_VERSION
14+
15+
ENV DEBIAN_FRONTEND=noninteractive
16+
# Install build dependencies, install UV (for python) and NVM (for nodejs)
17+
RUN apt-get update && \
18+
apt-get install -y --no-install-recommends \
19+
git \
20+
wget \
21+
curl \
22+
unzip \
23+
ca-certificates && \
24+
rm -rf /var/lib/apt/lists/*
25+
26+
USER ubuntu
27+
28+
# Updates the default shell to bash instead of sh
29+
SHELL ["/bin/bash", "-c"]
30+
31+
WORKDIR /home/ubuntu
32+
# Set up development environment for ubuntu user with UV and NVM
33+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
34+
source ${HOME}/.local/bin/env && \
35+
uv python install ${PYTHON_VERSION} && \
36+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh | bash && \
37+
export NVM_DIR="/home/ubuntu/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
38+
nvm install ${NODE_VERSION}
39+
40+
# Now the matlab-proxy directory can be mounted and tested for build
41+
42+

.devcontainer/devcontainer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "Only build MATLAB Proxy",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": ".",
6+
"args": {
7+
"PYTHON_VERSION" : "3.11",
8+
"NVM_VERSION" : "0.40.3",
9+
"NODE_VERSION" : "24"
10+
}
11+
},
12+
"containerEnv": {
13+
"NPM_CONFIG_REGISTRY": "${localEnv:NPM_CONFIG_REGISTRY}"
14+
},
15+
"customizations": {
16+
"vscode": {
17+
"extensions": [
18+
"ms-python.python"
19+
],
20+
"settings": {
21+
"python.terminal.activateEnvInCurrentTerminal": true,
22+
"python.defaultInterpreterPath": ".venv/bin/python"
23+
}
24+
}
25+
},
26+
"postCreateCommand": "uv venv --clear && . .venv/bin/activate && uv pip install . --cache-dir ./__uvcache__",
27+
"waitFor": "postCreateCommand"
28+
29+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copyright 2025 The MathWorks, Inc.
2+
3+
# Full image, with MATLAB and MATLAB Proxy
4+
5+
ARG PYTHON_VERSION=3.11
6+
ARG NODE_VERSION=20
7+
ARG NVM_VERSION="0.40.3"
8+
ARG MATLAB_RELEASE="R2025b"
9+
ARG UBUNTU_VERSION="24.04"
10+
# Default installation directory for MATLAB
11+
ARG MATLAB_INSTALL_LOCATION="/opt/matlab"
12+
ARG MATLAB_PRODUCT_LIST="MATLAB"
13+
14+
FROM ubuntu:${UBUNTU_VERSION}
15+
16+
ARG NVM_VERSION
17+
ARG PYTHON_VERSION
18+
ARG NODE_VERSION
19+
ARG MATLAB_RELEASE
20+
ARG UBUNTU_VERSION
21+
ARG MATLAB_INSTALL_LOCATION
22+
ARG MATLAB_PRODUCT_LIST
23+
24+
ENV DEBIAN_FRONTEND=noninteractive
25+
# Install build dependencies, install UV (for python) and NVM (for nodejs)
26+
RUN apt-get update && \
27+
apt-get install -y --no-install-recommends \
28+
git \
29+
wget \
30+
curl \
31+
unzip \
32+
xvfb \
33+
fluxbox \
34+
ca-certificates && \
35+
rm -rf /var/lib/apt/lists/*
36+
37+
USER ubuntu
38+
39+
# Updates the default shell to bash instead of sh
40+
SHELL ["/bin/bash", "-c"]
41+
42+
WORKDIR /home/ubuntu
43+
# Set up development environment for ubuntu user with UV and NVM
44+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
45+
source ${HOME}/.local/bin/env && \
46+
uv python install ${PYTHON_VERSION} && \
47+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh | bash && \
48+
export NVM_DIR="/home/ubuntu/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
49+
nvm install ${NODE_VERSION}
50+
51+
# Now the matlab-proxy directory can be mounted and tested for build
52+
53+
USER root
54+
55+
# Install MATLAB dependencies and MATLAB using MPM
56+
ARG MATLAB_DEPS_URL="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu${UBUNTU_VERSION}/base-dependencies.txt"
57+
ARG MATLAB_DEPENDENCIES="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt"
58+
ARG ADDITIONAL_PACKAGES="wget curl unzip ca-certificates xvfb git vim fluxbox gettext"
59+
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \
60+
&& apt-get install --no-install-recommends -y ${ADDITIONAL_PACKAGES}\
61+
&& wget $(echo ${MATLAB_DEPS_URL} | tr "[:upper:]" "[:lower:]") -O ${MATLAB_DEPENDENCIES} \
62+
&& xargs -a ${MATLAB_DEPENDENCIES} -r apt-get install --no-install-recommends -y \
63+
&& apt-get clean \
64+
&& apt-get -y autoremove \
65+
&& rm -rf /var/lib/apt/lists/* ${MATLAB_DEPENDENCIES}
66+
67+
WORKDIR /matlab-install
68+
ARG MSH_MANAGED_INSTALL_ROOT=/usr/local/MathWorks/ServiceHost/
69+
ARG MSH_DOWNLOAD_LOCATION=/tmp/Downloads/MathWorks/ServiceHost
70+
# Dont need to set HOME to install Support packages as jupyter images set HOME to NB_USER in all images, even for ROOT.
71+
RUN echo "Installing MATLAB using MPM..."
72+
RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm && \
73+
chmod +x mpm \
74+
&& ./mpm install --release=${MATLAB_RELEASE} --destination=${MATLAB_INSTALL_LOCATION} \
75+
--products ${MATLAB_PRODUCT_LIST} \
76+
|| (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false)\
77+
&& rm -f mpm /tmp/mathworks_root.log \
78+
&& ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab \
79+
&& git clone https://github.com/mathworks-ref-arch/administer-mathworks-service-host.git \
80+
&& cd /matlab-install/administer-mathworks-service-host/admin-scripts/linux/admin-controlled-installation \
81+
&& ./download_msh.sh --destination ${MSH_DOWNLOAD_LOCATION} \
82+
&& ./install_msh.sh --source ${MSH_DOWNLOAD_LOCATION} --destination ${MSH_MANAGED_INSTALL_ROOT} --no-update-environment \
83+
&& ./cleanup_default_msh_installation_location.sh --for-all-users \
84+
&& cd / && rm -rf /matlab-install ${MSH_DOWNLOAD_LOCATION}
85+
86+
ENV MATHWORKS_SERVICE_HOST_MANAGED_INSTALL_ROOT=${MSH_MANAGED_INSTALL_ROOT}
87+
88+
USER ubuntu
89+
WORKDIR /home/ubuntu
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "MATLAB & MATLAB Proxy",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": ".",
6+
"args": {
7+
"PYTHON_VERSION" : "3.11",
8+
"NVM_VERSION" : "0.40.3",
9+
"NODE_VERSION" : "24",
10+
"MATLAB_RELEASE" : "R2025b",
11+
"UBUNTU_VERSION" : "24.04",
12+
"MATLAB_PRODUCT_LIST" : "MATLAB"
13+
}
14+
},
15+
"containerEnv": {
16+
"NPM_CONFIG_REGISTRY": "${localEnv:NPM_CONFIG_REGISTRY}",
17+
"MWI_SESSION_NAME": "DevContainer"
18+
},
19+
"customizations": {
20+
"vscode": {
21+
"extensions": [
22+
"ms-python.python",
23+
"MathWorks.language-matlab"
24+
],
25+
"settings": {
26+
"MATLAB.signIn": true,
27+
"python.terminal.activateEnvInCurrentTerminal": true,
28+
"python.defaultInterpreterPath": ".venv/bin/python"
29+
}
30+
}
31+
},
32+
"postCreateCommand": "uv venv --clear && . .venv/bin/activate && uv pip install . --cache-dir ./__uvcache__",
33+
"waitFor": "postCreateCommand"
34+
}

.githooks/pre-commit

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh
2+
# Copyright 2025 The MathWorks, Inc.
3+
# Pre-commit hook to run all scripts in the scripts folder
4+
# Called by "git commit" with no arguments.
5+
6+
# Path to the scripts directory
7+
# Get the directory where this script is located
8+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
9+
SCRIPTS_DIR="$SCRIPT_DIR/scripts"
10+
11+
# Check if the scripts directory exists
12+
if [ ! -d "$SCRIPTS_DIR" ]; then
13+
echo "Error: Scripts directory not found at $SCRIPTS_DIR"
14+
exit 1
15+
fi
16+
17+
echo "Running pre-commit scripts from $SCRIPTS_DIR"
18+
19+
# Find all executable scripts in the scripts directory and sort them alphabetically
20+
for script in $(find "$SCRIPTS_DIR" -type f -executable | sort); do
21+
script_name=$(basename "$script")
22+
echo "Running $script_name..."
23+
24+
# Execute the script
25+
sh "$script"
26+
27+
# Check the exit code
28+
if [ $? -ne 0 ]; then
29+
echo "Error: $script_name failed. Commit aborted."
30+
exit 1
31+
fi
32+
33+
echo "$script_name completed successfully."
34+
done
35+
36+
echo "All pre-commit scripts completed successfully."
37+
exit 0
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
# Copyright 2025 The MathWorks, Inc.
3+
# Pre-commit hook to replace MathWorks NPM registry URLs with public NPM registry
4+
5+
# Find all package.json, .npmrc, and other relevant files
6+
echo "Executing pre-commit hook: sanitize-npm-registry"
7+
FILES=$( git diff --cached --name-only --diff-filter=ACM | grep -E '(.*.json)')
8+
9+
if [ -z "$FILES" ]; then
10+
exit 0
11+
fi
12+
13+
# Replace the MathWorks NPM registry URL with the public NPM registry
14+
for FILE in $FILES; do
15+
# Skip if file doesn't exist (it may have been deleted)
16+
[ -f "$FILE" ] || continue
17+
18+
echo "Sanitizing NPM registry URL in $FILE"
19+
20+
# Replace the URL in the file
21+
sed -i.bak 's|https://.*/artifactory/api/npm/npm-repos/|https://registry.npmjs.org/|g' "$FILE"
22+
23+
# Remove backup file
24+
rm -f "${FILE}.bak"
25+
26+
# Stage the modified file
27+
git add "$FILE"
28+
29+
echo "Sanitization complete for $FILE"
30+
done
31+
32+
exit 0

.github/actions/generate-code-coverage/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ runs:
1717
with:
1818
python-version: '3.8'
1919

20-
- name: Use Node.js 18.x
21-
uses: actions/setup-node@v4
20+
- name: Use Node.js 24
21+
uses: actions/setup-node@v6
2222
with:
23-
node-version: 18
23+
node-version: 24
2424

2525
- name: Install Python build dependencies
2626
run: |

.github/workflows/run-integration-tests.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023-2024 The MathWorks, Inc.
1+
# Copyright 2023-2025 The MathWorks, Inc.
22

33
# Workflow to run MATLAB-Proxy integration tests
44
name: Integration testing for MATLAB Proxy
@@ -24,6 +24,7 @@ jobs:
2424
os: [ubuntu-latest, windows-latest]
2525
matlab-release: [R2020b, latest]
2626
python-version: ['3.8', '3.11']
27+
node-version: ['24']
2728

2829
runs-on: ${{ matrix.os }}
2930

@@ -36,10 +37,10 @@ jobs:
3637
with:
3738
release: ${{ matrix.matlab-release }}
3839

39-
- name: Setup nodejs
40-
uses: actions/setup-node@v4
40+
- name: Setup Node.js ${{ matrix.node-version }}
41+
uses: actions/setup-node@v6
4142
with:
42-
node-version: 18
43+
node-version: ${{ matrix.node-version }}
4344

4445
- name: Set up Python ${{ matrix.python-version }}
4546
uses: actions/setup-python@v5

.github/workflows/run-unit-tests.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2024 The MathWorks, Inc.
1+
# Copyright 2020-2025 The MathWorks, Inc.
22

33
# Workflow that contains jobs to run MATLAB-Proxy unit tests
44

@@ -35,7 +35,7 @@ jobs:
3535

3636
matrix:
3737
os: [ubuntu-latest, windows-latest, macos-latest]
38-
node-version: ['18.x']
38+
node-version: ['24']
3939

4040
runs-on: ${{ matrix.os }}
4141

@@ -49,7 +49,7 @@ jobs:
4949
uses: actions/checkout@v4
5050

5151
- name: Use Node.js ${{ matrix.node-version }}
52-
uses: actions/setup-node@v4
52+
uses: actions/setup-node@v6
5353
with:
5454
node-version: ${{ matrix.node-version }}
5555

@@ -72,6 +72,7 @@ jobs:
7272
matrix:
7373
os: [ubuntu-latest, windows-latest, macos-latest]
7474
python-version: ['3.8', '3.9', '3.10', '3.11']
75+
node-version: ['24']
7576
exclude:
7677
- os: macos-latest
7778
python-version: '3.8'
@@ -89,10 +90,10 @@ jobs:
8990
with:
9091
python-version: ${{ matrix.python-version }}
9192

92-
- name: Use Node.js 18.x
93-
uses: actions/setup-node@v4
93+
- name: Use Node.js ${{ matrix.node-version }}
94+
uses: actions/setup-node@v6
9495
with:
95-
node-version: 18
96+
node-version: ${{ matrix.node-version }}
9697

9798
- name: Install dependencies
9899
run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*.egg-info/
22
.eggs/
33
__pycache__/
4+
__uvcache__/
45
build/
56
dist/
67
.venv*/

0 commit comments

Comments
 (0)