Make run model a oneshot service

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2024-07-01 18:14:10 +05:30
parent 3dcb3ce021
commit 55ce7d9fc2
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5
4 changed files with 28 additions and 8 deletions

View file

@ -25,18 +25,19 @@ gpgkey=https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.
RUN mv /tmp/oneAPI.repo /etc/yum.repos.d/oneAPI.repo && \ RUN mv /tmp/oneAPI.repo /etc/yum.repos.d/oneAPI.repo && \
dnf update && \ dnf update && \
dnf install intel-oneapi-mkl -y && \ dnf install intel-oneapi-mkl epel-release -y && \
dnf update && \
dnf install supervisor -y && \
mkdir /ollama mkdir /ollama
COPY --from=build /app/ollama /ollama COPY --from=build /app/ollama /ollama
COPY --from=build /app/serve.sh /ollama/serve.sh
ADD entrypoint.sh / COPY --from=build /app/run_model.sh /ollama/run_model.sh
COPY --from=build /app/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
ENV MODEL_NAME="llama" ENV MODEL_NAME="llama"
ENV OLLAMA_HOST="0.0.0.0:8080" ENV OLLAMA_HOST="0.0.0.0:8080"
EXPOSE 8080 EXPOSE 8080
ENTRYPOINT ["/entrypoint.sh"] CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
CMD ["/ollama/ollama", "run", "model"]

View file

@ -2,7 +2,7 @@
. /opt/intel/oneapi/setvars.sh . /opt/intel/oneapi/setvars.sh
/ollama/ollama serve & sleep 10
if [ -n "$INIT_MODELS" ]; then if [ -n "$INIT_MODELS" ]; then
/ollama/ollama rm model || true /ollama/ollama rm model || true
@ -10,4 +10,4 @@ if [ -n "$INIT_MODELS" ]; then
/ollama/ollama create -f /tmp/Modelfile model /ollama/ollama create -f /tmp/Modelfile model
fi fi
exec $@ /ollama/ollama run model

5
serve.sh Executable file
View file

@ -0,0 +1,5 @@
#! /usr/bin/env bash
. /opt/intel/oneapi/setvars.sh
/ollama/ollama serve

14
supervisord.conf Normal file
View file

@ -0,0 +1,14 @@
[supervisord]
nodaemon=true
[program:ollama]
command=/ollama/serve.sh
autostart=true
autorestart=true
[program:run_model]
command=/ollama/run_model.sh
autostart=true
autorestart=false
startsecs=0
exitcodes=0