Qwen3xOllama / Dockerfile
ankanpy's picture
Update Dockerfile
5dddd3e verified
# 1. Base Image
FROM python:3.10-slim
# 2. Set Environment Variables
ENV PYTHONUNBUFFERED=1
ENV GRADIO_SERVER_NAME="0.0.0.0"
ENV OLLAMA_HOST="0.0.0.0:11434"
ENV HOME=/root
# 3. Set Working Directory
WORKDIR /app
# 4. Install System Dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# 5. Install Ollama
RUN curl -fsSL https://ollama.com/install.sh | sh
# 6. Create the .ollama directory for the root user and set permissions
# Ollama needs to create its 'id_ed25519' key and 'models' subdir here.
# We ensure the base .ollama directory exists and is writable by root.
RUN mkdir -p /root/.ollama && \
chown -R root:root /root/.ollama && \
chmod -R 700 /root/.ollama # rwx for owner (root), no access for others
# 7. Copy Application Requirements
COPY requirements.txt .
# 8. Install Python Dependencies
RUN pip install --no-cache-dir -r requirements.txt
# 9. Copy Your Application Code AND startup script
COPY app.py .
COPY startup.sh .
RUN chmod +x ./startup.sh
# 10. Define Models to Pull (as an Argument with a default list)
ARG OLLAMA_PULL_MODELS="qwen3:1.7b qwen3:0.6b"
ENV OLLAMA_PULL_MODELS=${OLLAMA_PULL_MODELS}
# 11. Expose Ports
EXPOSE 11434
EXPOSE 7860
# 12. Entrypoint/Startup Script
ENTRYPOINT ["./startup.sh"]