FROM ghcr.nju.edu.cn/astral-sh/uv:python3.12-bookworm

# Install uv.
COPY --from=ghcr.nju.edu.cn/astral-sh/uv:latest /uv /bin/uv

# 配置 apt 阿里云镜像源并安装系统依赖
RUN if [ -f /etc/apt/sources.list.d/debian.sources ]; then \
        sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources; \
    elif [ -f /etc/apt/sources.list ]; then \
        sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list; \
    fi && \
    apt-get update && apt-get install -y \
    libpq-dev git \
    && rm -rf /var/lib/apt/lists/*

# 配置 uv 使用阿里云 PyPI 镜像
ENV UV_INDEX_URL="https://mirrors.aliyun.com/pypi/simple/"

WORKDIR /app

# Copy the application into the container.
RUN git clone https://ghproxy.net/https://github.com/ModelEngine-Group/deer-flow.git /app
COPY runtime/deer-flow/.env /app/.env
COPY runtime/deer-flow/conf.yaml /app/conf.yaml

# Pre-cache the application dependencies.
RUN --mount=type=cache,target=/root/.cache/uv \
    uv sync --locked --no-install-project

# Install the application dependencies.
RUN --mount=type=cache,target=/root/.cache/uv \
    uv sync --locked

EXPOSE 8000

# Run the application.
CMD ["uv", "run", "--no-sync", "python", "server.py", "--host", "0.0.0.0", "--port", "8000"]
