Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +17 -18
Dockerfile
CHANGED
@@ -1,14 +1,11 @@
|
|
1 |
# 1. Base Image
|
2 |
-
FROM python:3.
|
3 |
-
|
4 |
-
# Set the volume for Ollama data
|
5 |
-
# This is where Ollama will store its models and data
|
6 |
-
# VOLUME /root/.ollama
|
7 |
|
8 |
# 2. Set Environment Variables
|
9 |
ENV PYTHONUNBUFFERED=1
|
10 |
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
11 |
ENV OLLAMA_HOST="0.0.0.0:11434"
|
|
|
12 |
|
13 |
# 3. Set Working Directory
|
14 |
WORKDIR /app
|
@@ -23,29 +20,31 @@ RUN apt-get update && \
|
|
23 |
# 5. Install Ollama
|
24 |
RUN curl -fsSL https://ollama.com/install.sh | sh
|
25 |
|
26 |
-
# 6.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
COPY requirements.txt .
|
28 |
|
29 |
-
#
|
30 |
RUN pip install --no-cache-dir -r requirements.txt
|
31 |
|
32 |
-
#
|
33 |
COPY app.py .
|
34 |
COPY startup.sh .
|
35 |
-
|
36 |
-
# >>> ADD THIS LINE TO MAKE THE SCRIPT EXECUTABLE <<<
|
37 |
RUN chmod +x ./startup.sh
|
38 |
|
39 |
-
#
|
40 |
-
ARG OLLAMA_PULL_MODELS="
|
41 |
-
|
42 |
-
# Make the ARG available as an ENVironment variable for startup.sh
|
43 |
-
ENV OLLAMA_PULL_MODELS=${OLLAMA_PULL_MODELS}
|
44 |
|
45 |
-
#
|
46 |
EXPOSE 11434
|
47 |
EXPOSE 7860
|
48 |
|
49 |
-
#
|
50 |
-
# CMD ["./startup.sh"] # <-- CHANGE TO THIS
|
51 |
ENTRYPOINT ["./startup.sh"]
|
|
|
1 |
# 1. Base Image
|
2 |
+
FROM python:3.10-slim
|
|
|
|
|
|
|
|
|
3 |
|
4 |
# 2. Set Environment Variables
|
5 |
ENV PYTHONUNBUFFERED=1
|
6 |
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
7 |
ENV OLLAMA_HOST="0.0.0.0:11434"
|
8 |
+
ENV HOME=/root # Ollama will try to create ~/.ollama, which becomes /root/.ollama
|
9 |
|
10 |
# 3. Set Working Directory
|
11 |
WORKDIR /app
|
|
|
20 |
# 5. Install Ollama
|
21 |
RUN curl -fsSL https://ollama.com/install.sh | sh
|
22 |
|
23 |
+
# 6. Create the .ollama directory for the root user and set permissions
|
24 |
+
# Ollama needs to create its 'id_ed25519' key and 'models' subdir here.
|
25 |
+
# We ensure the base .ollama directory exists and is writable by root.
|
26 |
+
RUN mkdir -p /root/.ollama && \
|
27 |
+
chown -R root:root /root/.ollama && \
|
28 |
+
chmod -R 700 /root/.ollama # rwx for owner (root), no access for others
|
29 |
+
|
30 |
+
# 7. Copy Application Requirements
|
31 |
COPY requirements.txt .
|
32 |
|
33 |
+
# 8. Install Python Dependencies
|
34 |
RUN pip install --no-cache-dir -r requirements.txt
|
35 |
|
36 |
+
# 9. Copy Your Application Code AND startup script
|
37 |
COPY app.py .
|
38 |
COPY startup.sh .
|
|
|
|
|
39 |
RUN chmod +x ./startup.sh
|
40 |
|
41 |
+
# 10. Define Models to Pull (as an Argument with a default list)
|
42 |
+
ARG OLLAMA_PULL_MODELS="qwen2:7b mistral:7b" # Default models if not overridden
|
43 |
+
ENV OLLAMA_PULL_MODELS=${OLLAMA_PULL_MODELS} # For startup.sh
|
|
|
|
|
44 |
|
45 |
+
# 11. Expose Ports
|
46 |
EXPOSE 11434
|
47 |
EXPOSE 7860
|
48 |
|
49 |
+
# 12. Entrypoint/Startup Script
|
|
|
50 |
ENTRYPOINT ["./startup.sh"]
|