I've a python script that executes a matlab script inside it with matlab.engine().This works on my machine but I'm not able to dockerize it.
The dockerfile will need two images -Matlab and Python. The Matlab needs to initialize with the license file and then the python setup script inside the Matlab folder is to be executed. After that, python script will be able to access Matlab.
Any help on creating the Dockerfile is appreciated. Or any leads to where can I find something like this. Thanks..
Tried with this:
Python code:
import matlab.engine
from flask import Flask
@app.route("/matlab")
def matlab_execute():
eng = matlab.engine.start_matlab()
eng.myscript(nargout=0)
return "success"
if __name__ == "__main__":
app.run()
Dockerfile:
FROM mathworks/matlab:r2021a as matlab_image
WORKDIR /matlab
FROM python:3.8
COPY --from=matlab_image /matlab /
COPY myscript.m /
COPY py_script.py /
WORKDIR /
RUN pip install FLASK
CMD [ "python", "./py_script.py" ]
But I get, "no module named matlab" when i run the container. How can I pass the matlab credentials to this ?