Run Microservice Docker Image without waiting for argument.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I'm trying to create a Docker image that will deploy from a private registry that expects data in a file that is mounted to the docker instance as a volume. Is there a way to build the microservice docker image such that it does not wait for request and just executes the MATLAB code I've written? The MATLAB code I've compiled knows where to expect the input data file. I'm trying to figure out how to make this work within an existing workflow without backend changes to the applilcation. Thanks!
Colby
Example function I want to compile
function examplefunction
%% Get environment variables from APP
SOURCE_FOLDER = getenv('SOURCE_FOLDER')
ANALYSIS_URL = getenv('ANALYSIS_URL')
%% read file with single integer value
uservalue = readtable([SOURCE_FOLDER,'\','UserValue.csv']);
%% Do something with the data
y = magic(uservalue);
disp(y)
%% Make http call to tell App the script is finished
import matlab.net.*
import matlab.net.http.*
r = RequestMessage;
resp = send(r,ANALYSIS_URL);
Example code I'm currently using to compile image
mpsResults = compiler.build.productionServerArchive('examplefunction.m',...
'ArchiveName','examplearchive','Verbose','on')
compiler.package.microserviceDockerImage(mpsResults,'ImageName','example-image')
After compiled and deployed it just waits for a request once running, instead of running the MATLAB code. Would greatly appreciate if someone could point out what I'm doing wrong.Thanks
0 comentarios
Respuestas (1)
Nicole Bonfatti
el 9 de Jun. de 2023
Hi Colby,
Microservice docker containers are to set up web services that respond to function calls that are submitted via REST API. It sounds like what you really want is a standalone application running in a docker container.
This video describes how to do that - Use MATLAB Compiler to package standalone applications into Docker containers
0 comentarios
Ver también
Categorías
Más información sobre MATLAB Compiler SDK en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!