I have created a Dockerfile for serving an AI application.
FROM python:3.10-slim
RUN apt-get update &&
apt-get install -y default-jre ca-certificates-java &&
apt-get install -y gcc libgdal-dev g++ &&
apt-get clean &&
update-ca-certificates -f
WORKDIR /home/model-server
COPY requirements.txt .
ENV GDAL_VERSION 3.3.0
ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-arm64/
RUN pip install -r requirements.txt
COPY model_store /home/model-server/model_store/
COPY config.properties /home/model-server/config.properties
COPY deploy.sh /home/model-server/deploy.sh
EXPOSE 8080
CMD torchserve --model-store model_store --start --models my_model=Unet.mar --ts-config config.properties
My start command is docker run --name platerra -p 8080:8080 platerra-ai
The docker image build fine but the final step in launching the application results in the container exiting and the final start command does not execute not even with an sh file that has the same command.
Keeping the container running by adding tail -f /dev/null
and going inside the container and running torchserve --model-store model_store --start --models my_model=Unet.mar --ts-config config.properties
or bash deploy.sh
works as expected and the server starts running. But why can I not achieve this from the Dockerfile. Going in manually and starting the server is not the best option for wanting to automate deployment.