File size: 1,199 Bytes
7c4cf70
 
 
 
 
a66bba3
7c4cf70
 
 
 
93c0ec9
 
7c4cf70
 
d078b16
7c4cf70
 
 
 
 
39dcb26
 
7c4cf70
 
 
39dcb26
7c4cf70
 
 
 
 
 
 
 
 
 
 
 
 
aaf1548
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Start from the official Ollama base image
FROM ollama/ollama

# --- BUILD ARGUMENT ---
# Allows you to specify the model to download when building the image.
ENV OLLAMA_MODEL=qwen3:1.7b

# --- ENVIRONMENT VARIABLES ---
ENV OLLAMA_HOST=0.0.0.0
ENV OLLAMA_ORIGINS='*'
# Optional: Set your own API key as environment variable, otherwise one will be auto-generated
# ENV OLLAMA_API_KEY=your_secure_api_key_here

# 1. Install Python and PIP
RUN apt-get update && apt-get install -y python3 python3-pip curl

# 2. Copy your application files into the container
WORKDIR /app
COPY ./main.py /app/main.py
COPY ./start.sh /app/start.sh
COPY ./chat.html /app/chat.html
COPY ./static /app/static
RUN chmod +x /app/start.sh

# 3. Install Python dependencies for the FastAPI gateway
RUN pip3 install fastapi uvicorn requests --break-system-packages

# Expose the port the FastAPI gateway will listen on
EXPOSE 7860

# Pre-pull the specified LLM model during the build process
RUN if [ -n "$OLLAMA_MODEL" ]; then \
        ollama serve & \
        sleep 5 && \
        ollama pull $OLLAMA_MODEL && \
        pkill ollama; \
    fi

# Set the command to run when the container starts
ENTRYPOINT ["/app/start.sh"]