Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +24 -6
Dockerfile
CHANGED
@@ -4,13 +4,31 @@ FROM ollama/ollama:latest
|
|
4 |
# Set the working directory inside the container
|
5 |
WORKDIR /app
|
6 |
|
7 |
-
#
|
8 |
-
#
|
|
|
9 |
|
10 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
EXPOSE 11434
|
12 |
|
13 |
-
#
|
14 |
-
# ENTRYPOINT ["
|
|
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
|
4 |
# Set the working directory inside the container
|
5 |
WORKDIR /app
|
6 |
|
7 |
+
# Define the model you want to download (replace with your chosen sub-500MB model)
|
8 |
+
# Examples: smollm:135m, smollm:360m, tinyllama:1.1b-chat-v1.0-q2_K
|
9 |
+
ENV OLLAMA_MODEL_NAME="smollm:135m"
|
10 |
|
11 |
+
# Pull the model during the Docker build process
|
12 |
+
# This ensures the model is present when the container starts,
|
13 |
+
# reducing startup time and avoiding dynamic downloads.
|
14 |
+
# The `ollama pull` command can be slow, so pulling it once here is efficient.
|
15 |
+
RUN ollama pull ${OLLAMA_MODEL_NAME}
|
16 |
+
|
17 |
+
# Set OLLAMA_HOST to listen on all network interfaces inside the container
|
18 |
+
# This is crucial for Hugging Face Spaces to be able to connect to Ollama.
|
19 |
+
# OLLAMA_ORIGINS allows cross-origin requests, useful if you build a web UI later.
|
20 |
+
ENV OLLAMA_HOST="0.0.0.0:11434"
|
21 |
+
ENV OLLAMA_ORIGINS="*" # Allow all origins for the API
|
22 |
+
|
23 |
+
# Expose the port Ollama listens on
|
24 |
EXPOSE 11434
|
25 |
|
26 |
+
# Command to start the Ollama server.
|
27 |
+
# The base image typically has ENTRYPOINT ["ollama"], so CMD just provides the argument.
|
28 |
+
CMD ["serve"]
|
29 |
|
30 |
+
# Optional: Add metadata for Hugging Face Spaces (improves discoverability)
|
31 |
+
LABEL org.opencontainers.image.title="Ollama with a tiny model"
|
32 |
+
LABEL org.opencontainers.image.description="Runs Ollama with a pre-loaded model less than 500MB"
|
33 |
+
LABEL org.opencontainers.image.licenses="MIT"
|
34 |
+
LABEL org.opencontainers.image.authors="Your Name/Org"
|