brendon-ai commited on
Commit
b04e9f2
·
verified ·
1 Parent(s): 37c6f87

Update Dockerfile

Browse files
Files changed (1) hide show
  1. 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
- # Copy any necessary files or scripts
8
- # COPY ./your_scripts /app/
 
9
 
10
- # Start the Ollama API server
 
 
 
 
 
 
 
 
 
 
 
 
11
  EXPOSE 11434
12
 
13
- # Entrypoint script (optional, for initialization before the server starts)
14
- # ENTRYPOINT ["/bin/bash", "-c", "ollama serve"]
 
15
 
16
- CMD ["ollama", "serve"] # Start the Ollama server on boot
 
 
 
 
 
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"