-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (61 loc) · 2.25 KB
/
Copy pathDockerfile
File metadata and controls
73 lines (61 loc) · 2.25 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Multi-stage build for smaller final image
FROM python:3.13-slim AS builder
# Install build dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gcc \
g++ \
libc6-dev \
libffi-dev \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
# Final stage
FROM python:3.13-slim AS runtime
# Set the working directory in the container
WORKDIR /app
# Configure Debian mirror to use a more stable source and install dependencies
RUN echo "deb http://mirrors.ustc.edu.cn/debian/ trixie main contrib non-free non-free-firmware" > /etc/apt/sources.list \
&& echo "deb http://mirrors.ustc.edu.cn/debian/ trixie-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list \
&& echo "deb http://mirrors.ustc.edu.cn/debian-security trixie-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends -o Acquire::Retries=3 \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1 \
libgomp1 \
curl \
android-tools-adb \
iputils-ping \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Copy virtual environment from builder stage
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy application files (order optimized for caching)
# Copy less frequently changed files first
COPY core/ ./core/
COPY middleware/ ./middleware/
COPY static/ ./static/
COPY env/ ./env/
COPY utils/ ./utils/
COPY agents/ ./agents/
COPY agent_core.py .
COPY main.py .
# Create output directory
RUN mkdir -p agent_outputs
# Make port 8000 available to the world outside this container
EXPOSE 8000
# Add health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8000/ || exit 1
# Run main.py when the container launches
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]