forked from prebid/salesagent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.fly.processgroups
More file actions
64 lines (48 loc) · 2.16 KB
/
Dockerfile.fly.processgroups
File metadata and controls
64 lines (48 loc) · 2.16 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
# Fly.io optimized Dockerfile for AdCP Sales Agent with Process Groups
FROM python:3.12-slim AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
gcc \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Install uv
RUN pip install uv
# Set up caching for uv
ENV UV_CACHE_DIR=/cache/uv
ENV UV_TOOL_DIR=/cache/uv-tools
ENV UV_PYTHON_PREFERENCE=only-system
# Copy project files
WORKDIR /app
COPY pyproject.toml uv.lock ./
# Install dependencies
RUN --mount=type=cache,target=/cache/uv \
--mount=type=cache,target=/root/.cache/pip \
uv sync --frozen
# Runtime stage
FROM python:3.12-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libpq5 \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy virtual environment from builder
COPY --from=builder /app/.venv /app/.venv
# Copy application code
COPY . .
# Add .venv to PATH
ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONUNBUFFERED=1
# Fly.io specific environment
ENV ADCP_SALES_PORT=8080
ENV ADMIN_UI_PORT=8001
# Create entrypoint script for Fly.io with process group support
RUN echo '#!/bin/bash\nset -e\n\n# Create required directories\nmkdir -p /data/logs /data/uploads\n\n# Run migrations only for MCP process\nif [ "$FLY_PROCESS_GROUP" = "mcp" ]; then\n echo "Running database migrations..."\n python scripts/ops/migrate.py || echo "Migration failed, continuing..."\nfi\n\n# Check FLY_PROCESS_GROUP and run appropriate service\nif [ "$FLY_PROCESS_GROUP" = "admin" ]; then\n echo "Starting Admin UI on port 8001..."\n exec python scripts/run_admin_ui.py\nelse\n echo "Starting MCP Server on port 8080..."\n # Use run_server.py which handles the proper binding\n exec python scripts/run_server.py\nfi' > /app/fly-entrypoint.sh && \
chmod +x /app/fly-entrypoint.sh
# Health check will be different per process
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD if [ "$FLY_PROCESS_GROUP" = "admin" ]; then curl -f http://localhost:8001/health || exit 1; else curl -f http://localhost:8080/health || exit 1; fi
# Expose both ports
EXPOSE 8080 8001
# Use the fly-specific entrypoint
CMD ["/app/fly-entrypoint.sh"]