myrmidon / Dockerfile.server
tek Atrust
chore(deploy): build monolithic server for Hugging Face
d5ef46f
Raw
History Blame Contribute Delete
2.72 kB
# Server Service - Web crawling and document processing microservice
FROM python:3.12 AS builder
WORKDIR /build
# Install build dependencies and uv
RUN apt-get update && apt-get install -y \
build-essential \
&& rm -rf /var/lib/apt/lists/* \
&& pip install --no-cache-dir uv
# Copy pyproject.toml for dependency installation
COPY python/pyproject.toml .
# Install server dependencies to a virtual environment using uv
RUN uv venv /venv && \
. /venv/bin/activate && \
uv pip install --group server --group mcp --group agents
# Pre-download critical python wheels for offline self-expansion
COPY scripts/cache_offline_packages.py scripts/
RUN python scripts/cache_offline_packages.py --output /app/offline_wheels
# Phase 5.7.4: PyTorch removed. ONNX models will be fetched dynamically via huggingface-hub.
# Runtime stage
FROM python:3.12-slim
WORKDIR /app
# Install runtime dependencies for Playwright (minimal set)
RUN apt-get update && apt-get install -y \
git \
wget \
ca-certificates \
fonts-liberation \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libatspi2.0-0 \
libcups2 \
libdbus-1-3 \
libdrm2 \
libgbm1 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libwayland-client0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxkbcommon0 \
libxrandr2 \
xdg-utils \
fonts-noto-cjk \
fontconfig \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Copy the virtual environment from builder
COPY --from=builder /venv /venv
COPY --from=builder /app/offline_wheels /app/offline_wheels
# Install Playwright browsers
ENV PATH=/venv/bin:$PATH
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN playwright install chromium
# Copy backend source code, tests, and migration files
COPY python/src/ src/
COPY python/tests/ tests/
COPY migration/ migration/
# Set environment variables
ENV PYTHONPATH="/app/src:/app:$PYTHONPATH"
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PATH="/venv/bin:$PATH"
ENV ARCHON_SERVER_PORT=8181
ENV ARCHON_MCP_PORT=8051
ENV ARCHON_AGENTS_PORT=8052
ENV ARCHON_SERVER_HOST=127.0.0.1
# Expose Server port
EXPOSE 8181
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD sh -c "python -c \"import urllib.request; urllib.request.urlopen('http://localhost:${ARCHON_SERVER_PORT}/health')\""
# Copy start_all script and ensure entrypoints are executable
COPY python/start_all.sh /app/start_all.sh
COPY python/docker-entrypoint-mcp.sh /app/docker-entrypoint-mcp.sh
COPY python/docker-entrypoint-agents.sh /app/docker-entrypoint-agents.sh
RUN chmod -R 777 /app
# Run the Monolith service
CMD ["/app/start_all.sh"]