File size: 1,446 Bytes
22dcdfd 4eda213 22dcdfd 4eda213 22dcdfd 18f8f55 22dcdfd 4eda213 9dfaae7 22dcdfd 18f8f55 |
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 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# Stage 1: Get the official Ollama binary
FROM ollama/ollama:latest AS ollama_source
# Stage 2: Final Image
FROM python:3.12.3-slim
# Install system dependencies (curl for health, socat for port mapping)
RUN apt-get update && apt-get install -y \
curl \
socat \
&& rm -rf /var/lib/apt/lists/*
# Copy Ollama from the official image
COPY --from=ollama_source /usr/bin/ollama /usr/bin/ollama
# Also copy the libraries which are necessary for Ollama to run
COPY --from=ollama_source /usr/lib/ollama /usr/lib/ollama
# Set up the non-root user
RUN useradd -m -u 1000 user
WORKDIR /app
RUN chown user:user /app
# Install uv and dependencies
RUN pip install --no-cache-dir uv
USER user
COPY --chown=user:user pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev --no-install-project
# Copy app code
COPY --chown=user:user src/agents/ ./agents/
COPY --chown=user:user src/core/ ./core/
COPY --chown=user:user src/memory/ ./memory/
COPY --chown=user:user src/schema/ ./schema/
COPY --chown=user:user src/service/ ./service/
COPY --chown=user:user src/run_service.py ./run_service.py
COPY --chown=user:user entrypoint.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh
# Environment variables
ENV HOST=0.0.0.0
ENV PORT=7860
ENV OLLAMA_HOST=0.0.0.0:11434
ENV OLLAMA_KEEP_ALIVE=24h
ENV OLLAMA_BASE_URL=http://localhost:11434
EXPOSE 7860
EXPOSE 11434
RUN mkdir -p /home/user/.ollama
VOLUME ["/home/user/.ollama"]
CMD ["./entrypoint.sh"]
|