필터 지우기
필터 지우기

Run Microservice Docker Image without waiting for argument.

조회 수: 3 (최근 30일)
Colby Osborn
Colby Osborn 2023년 2월 22일
답변: Nicole Bonfatti 2023년 6월 9일
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