主要内容

Microservice Docker Image Compiler

R2026b

Package MATLAB programs for deployment as MATLAB microservices

Since R2026b

Description

The Microservice Docker Image Compiler packages MATLAB® programs into applications that can run outside of MATLAB. The interactive menus and dialog boxes used in the compiler apps build compiler.package commands that are customized to your specification.

Compiler app advantages include:

  • You can perform deployment tasks with a single intuitive interface.

  • You can organize your files in a MATLAB project.

  • Your project state persists between sessions.

  • You can load previously stored compiler tasks from a prepopulated menu.

  • You can package applications with an installer for distribution.

For more information, see Target-Specific Compiler Apps for MATLAB Code Deployment.

Open the Microservice Docker Image Compiler App

  • MATLAB toolstrip: On the Apps tab, under Application Deployment, click the app icon.

  • MATLAB command prompt: Enter microserviceCompiler.

Parameters

expand all

Functions

Files implementing MATLAB functions. Files must have one of the following extensions: .m, .p, .mlx, or .mexa64.

All files must be located in the project root folder to be added to the project. To add MATLAB functions to the microservice, click Add Exported Function and select your MATLAB file. In the Project panel, the file you selected gains the labels Design and Exported Function File.

Output Location

Path to folder where the build artifacts are generated.

Path to the build folder where the Docker® image is built. The path can be relative to the current working directory or absolute.

If no path is specified, the function creates a build folder named ImageNamedocker in the current working directory.

Data Types: char | string

Function Signatures

Path to a JSON file that details the signatures of all included functions. For information on specifying function signatures, see MATLAB Function Signatures in JSON (MATLAB Production Server).

Routes

JSON file that specifies custom URL routes on the server. For more information, configure archive-specific routes using the instructions on Handle Custom Routes and Payloads in HTTP Requests (MATLAB Production Server).

Build Settings

Name of the deployable archive.

Example: MyMagicArchive

Data Types: char | string

Obfuscate folder structures, file names, and user code in the microservice.

If you enable this property, then folder structures and file names in the microservice are obfuscated from the end user, and user code and data contained in .m, .mlapp, .p, .mat, MLX, SFX, and MEX files are placed into a user package within the archive. Additionally, all .m files are converted to P-files before packaging.

During runtime, MATLAB code and data is decrypted and loaded directly from the user package rather than extracted to the file system. MEX files are temporarily extracted from the user package before being loaded.

To manually include additional file types in the user package, add each file type in a separate extension tag to the file matlabroot/toolbox/compiler/advanced_package_supported_files.xml.

The following are not supported:

  • ver function

  • Calling external libraries such as DLLs

  • Out-of-process MATLAB Runtime (C++ shared library for MATLAB Data Array)

  • Out-of-process MEX file execution (mexhost, feval, matlab.mex.MexHost)

  • Before R2023b: .mat files other than v7.3

Enabling this option is equivalent to using mcc with -j and -s specified.

If you do not enable this property, then the microservice is not obfuscated. This is the default behavior.

Files Required for Archive to Run

Support packages to include in the microservice. The dependency analysis process detects and includes the required support packages automatically. Only the specified support packages are included. To list installed support packages or those used by a specific file, see compiler.codetools.deployableSupportPackages.

Additional files and folders to include in the microservice. To add the contents of a folder, click Add Folder. To add an individual file, click Add File.

Additional files to include in the microservice. The dependency analysis process detects and includes required data files automatically unless Automatically include data files that are provided as inputs to functions such as load and fopen is disabled.

To view the file analysis results, click View Analysis. To perform the dependency analysis process again, click Reanalyze.

Automatically include data files in the microservice.

  • If you enable this property, then data files that you provide as inputs to certain functions (such as load and fopen) are automatically included in the microservice. This is the default option.

  • If you disable this property, then you must add data files to the package in the Custom Requirements section.

Microservice Docker Image Settings

Name of the Docker image, specified as a character vector or a string scalar. The name must comply with Docker naming rules. Docker repository names must be lowercase. If the main executable or archive file is named using uppercase letters, then the uppercase letters are replaced with lowercase letters in the Docker image name.

Flag to build the Docker image.

  • If you enable this property, then the function will build the Docker image.

  • If you disable this property, then the function will populate the DockerContext folder without calling 'docker build'.

Data Types: logical

Name of the MATLAB Runtime image, specified as a character vector or a string scalar. You can use the compiler.runtime.createDockerImage function to create a custom MATLAB Runtime image that can run multiple applications. If not specified, MATLAB Compiler™ generates a selective MATLAB Runtime image that can only run the packaged application.

Additional Ubuntu® packages to install on the Docker image, specified as a comma-separated list of package names.

Additional commands to pass to the Docker image, , specified as text file with one instruction per line. Commands are added to the Dockerfile and execute during image generation.

For information on valid Dockerfile commands, see https://docs.docker.com/reference/dockerfile.

Name of the Linux user the Docker container will run as, specified as a string. The argument must comply with system user naming standards. If the specified user does not exist at the time of creation, a new user will be created with no permissions. If this property is not set, the container will run as the user appuser by default, or the user specified in the FROM command in the Dockerfile.

Version History

Introduced in R2026b