Run Microservice Docker Image without waiting for argument.

1 visualizzazione (ultimi 30 giorni)
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

Risposte (1)

Nicole Bonfatti
Nicole Bonfatti il 9 Giu 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.

Categorie

Scopri di più su MATLAB Compiler SDK in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by