ruslanmv commited on
Commit
807092d
1 Parent(s): a18417c
Files changed (2) hide show
  1. Dockerfile +22 -7
  2. start.sh +21 -0
Dockerfile CHANGED
@@ -1,11 +1,26 @@
1
  FROM python:3.10-slim-buster
2
- # Set up the working directory
3
- WORKDIR /
4
- SHELL ["/bin/bash", "-o", "pipefail", "-c"]
5
- # Copy a custom entrypoint script into the container
6
- COPY ollama_start.sh /
7
- RUN chmod +x /ollama_start.sh
8
- CMD ["ollama_start.sh"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  # Set the working directory
11
  WORKDIR /app
 
1
  FROM python:3.10-slim-buster
2
+
3
+ RUN apt update && apt install curl -y
4
+ RUN curl -fsSL https://ollama.com/install.sh | sh
5
+ ENV OLLAMA_HOST=0.0.0.0
6
+ RUN useradd -m app && chown -R app:app /home/app
7
+ # Create the directory and give appropriate permissions
8
+ RUN mkdir -p /home/app/.ollama && chmod 777 /home/app/.ollama
9
+ #RUN mkdir -p /home/app/.ollama/models &&
10
+ USER app
11
+ WORKDIR /home/app/.ollama
12
+ #Copy dossier de models
13
+ #COPY --chown=app models /.ollama
14
+ #RUN chmod 777 /home/app/.ollama/models
15
+ # Copy the entry point script
16
+ COPY --chown=app entrypoint.sh /entrypoint.sh
17
+ RUN chmod +x /start.sh
18
+ # Set the entry point script as the default command
19
+ CMD ["/start.sh"]
20
+ #ENV OLLAMA_MODELS="/home/app/.ollama/models"
21
+ # Expose the server port
22
+ EXPOSE 7860
23
+
24
 
25
  # Set the working directory
26
  WORKDIR /app
start.sh ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Starting server
4
+ echo "Starting server"
5
+ ollama serve &
6
+ sleep 1
7
+
8
+ # Splitting the models by comma and pulling each
9
+ IFS=',' read -ra MODELS <<< "$model"
10
+ for m in "${MODELS[@]}"; do
11
+ echo "Pulling $m"
12
+ ollama pull "$m"
13
+ sleep 5
14
+ ollama pull "$m"
15
+ # echo "Running $m"
16
+ # ollama run "$m"
17
+ # No need to sleep here unless you want to give some delay between each pull for some reason
18
+ done
19
+
20
+ # Keep the script running to prevent the container from exiting
21
+ wait