brendon-ai commited on
Commit
6da83c8
·
verified ·
1 Parent(s): 878b6a2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -29
Dockerfile CHANGED
@@ -1,35 +1,20 @@
1
- # Use the official Ollama Docker image
2
- FROM ollama/ollama:latest
3
 
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
- ENV OLLAMA_HOST="0.0.0.0:11434"
20
 
21
- # Allow all origins for the API (CORS configuration)
22
- ENV OLLAMA_ORIGINS="*"
23
-
24
- # Expose the port Ollama listens on
25
- EXPOSE 11434
26
-
27
- # Command to start the Ollama server.
28
- # The base image typically has ENTRYPOINT ["ollama"], so CMD just provides the argument.
29
- CMD ["serve"]
30
-
31
- # Optional: Add metadata for Hugging Face Spaces (improves discoverability)
32
- LABEL org.opencontainers.image.title="Ollama with a tiny model"
33
- LABEL org.opencontainers.image.description="Runs Ollama with a pre-loaded model less than 500MB"
34
- LABEL org.opencontainers.image.licenses="MIT"
35
- LABEL org.opencontainers.image.authors="Your Name/Org"
 
1
+ # Use a Python base image
2
+ FROM python:3.9-slim-buster
3
 
4
+ # Set working directory
5
  WORKDIR /app
6
 
7
+ # Install dependencies
8
+ COPY requirements.txt .
9
+ RUN pip install --no-cache-dir -r requirements.txt
10
 
11
+ # Copy your application code
12
+ COPY app.py .
 
 
 
13
 
14
+ # Expose the port your API will run on (Hugging Face Spaces uses 7860 by default for Gradio/Streamlit,
15
+ # but for custom Docker, you can choose, e.g., 8000 for FastAPI or 5000 for Flask).
16
+ EXPOSE 8000
17
 
18
+ # Command to run your FastAPI/Flask app
19
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] # For FastAPI
20
+ # CMD ["python", "app.py"] # For a simple Flask app