Skip to content

Commit

Permalink
Change MATLAB license file mounting (#149)
Browse files Browse the repository at this point in the history
Co-authored-by: Joe Naegele <[email protected]>
  • Loading branch information
johnstairs and naegelejd authored May 15, 2024
1 parent f1fb00f commit 0b74fc9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm \
|| (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false) \
&& sudo rm -f mpm /tmp/mathworks_root.log \
&& sudo ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab \
&& sudo ln -s ${MATLAB_INSTALL_LOCATION} /opt/matlab/latest
&& sudo ln -s ${MATLAB_INSTALL_LOCATION} /opt/matlab/latest \
&& sudo mkdir -p ${MATLAB_INSTALL_LOCATION}/licenses

# Install workaround run-matlab-command script to unify local and CI invocations of `matlab -batch`
# See https://github.com/matlab-actions/run-command/issues/53
Expand Down
11 changes: 11 additions & 0 deletions .devcontainer/devcontainer-on-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /usr/bin/env bash

set -euo pipefail

host_license_file="/tmp/matlab.host.lic"

if [ -s "${host_license_file}" ]; then
# We don't bind mount directly to $MATLAB_LICENSE_FILE so that we can write
# to it later without affecting the host.
sudo cp "${host_license_file}" "${MATLAB_LICENSE_FILE}"
fi
13 changes: 10 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@
"dockerfile": "Dockerfile",
"context": ".."
},
"runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
"--network=host"
],
"overrideCommand": false,
"mounts": [
// Bind mount docker socket under an alias to support docker-from-docker
"source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind",
"source=${localEnv:MATLAB_LICENSE_FILE:/dev/null},target=/opt/matlab/latest/licenses/license.lic,type=bind"
"source=${localEnv:MATLAB_LICENSE_FILE:/dev/null},target=/tmp/matlab.host.lic,type=bind,readonly"
],
"onCreateCommand": ".devcontainer/devcontainer-on-create.sh",
"remoteUser": "vscode",

// Configure tool-specific properties.
Expand Down Expand Up @@ -120,6 +126,7 @@

"containerEnv": {
"PYTHONPATH": "/workspaces/yardl/python",
"CGO_ENABLED": "0"
"CGO_ENABLED": "0",
"MATLAB_LICENSE_FILE": "/opt/matlab/latest/licenses/license.lic"
}
}

0 comments on commit 0b74fc9

Please sign in to comment.