Is it possible to combine these two Dockerfiles so I can run it in one container? (Spring Boot Project and a Library Runtime)

Currently I have an algorithm in Matlab that I have successfully converted to a Jar file. This Jar file is included in a Spring Boot Project and my aim is to make this run in Docker. The issue I am facing right now is that I am possible to run this Spring Boot project locally where I have the Matlab Runtime Compiler installed. The second I build a Docker Container and deploy it I am unable to use the algorithm due missing libraries (referencing the Runtime Compiler). The following error is shown when I run a method that makes a call to the convert Matlab Algorithm:

[Handler dispatch failed; nested exception is java.lang.UnsatisfiedLinkError: Failed to find the required library libmwmclmcrrt.so.9.8 on java.library.path.

This library is typically installed along with MATLAB or the MATLAB Runtime. Its absence may indicate an issue with that installation or

the current path configuration, or a mismatch with the architecture of the Java interpreter on the path.

The reason this error occurs is that the Matlab Runtime Compiler is not installed within the Docker container.

Currently I have the following Dockerfile for the Spring Boot project:

FROM openjdk:8-jdk-alpine
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

In my search to find a way to run the Matlab Compiler in Docker I came across the following link:
https://github.com/demartis/matlab_runtime_docker

Based on that information I was able to create a Matlab Compiler image using the following Dockerfile:

FROM debian:stretch-slim
MAINTAINER Riccardo De Martis <[email protected]demartis.it>
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get -q update && 
    apt-get install -q -y --no-install-recommends 
      xorg 
      unzip 
      wget 
      curl && 
    apt-get clean && 
    rm -rf /var/lib/apt/lists/*

# Download the MCR from MathWorks site an install with -mode silent
RUN mkdir /mcr-install && 
    mkdir /opt/mcr && 
    cd /mcr-install && 
    wget --no-check-certificate -q http://ssd.mathworks.com/supportfiles/downloads/R2020a/Release/0/deployment_files/installer/complete/glnxa64/MATLAB_Runtime_R2020a_glnxa64.zip && 
    unzip -q MATLAB_Runtime_R2020a_glnxa64.zip && 
    rm -f MATLAB_Runtime_R2020a_glnxa64.zip && 
    ./install -destinationFolder /opt/mcr -agreeToLicense yes -mode silent && 
    cd / && 
    rm -rf mcr-install

# Configure environment variables for MCR
ENV LD_LIBRARY_PATH /opt/mcr/v98/runtime/glnxa64:/opt/mcr/v98/bin/glnxa64:/opt/mcr/v98/sys/os/glnxa64:/opt/mcr/v98/extern/bin/glnxa64
                    
ENV XAPPLRESDIR /etc/X11/app-defaults

The issue I have now is that I have two different images and ideally I’d like to combine them so that I can run the Spring Boot application with the Runtime Compiler so I can access the Matlab function but I have been unable to do so. I was wondering if it is possible to combine these two Dockerfiles.

Source: Docker Questions