Run Microservice Docker Image without waiting for argument.

3 次查看(过去 30 天)
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

回答(1 个)

Nicole Bonfatti
Nicole Bonfatti 2023-6-9
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.

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB Compiler SDK 的更多信息

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by