Files
archon/python/Dockerfile.server
DIY Smart Code 3168c8b69f fix: Set explicit PLAYWRIGHT_BROWSERS_PATH to fix browser installation (#765)
* fix: Set explicit PLAYWRIGHT_BROWSERS_PATH to fix browser installation

Fixes Playwright browser not found error during web crawling.

The issue was introduced in the uv migration (9f22659) where the
browser installation path was not explicitly set as a persistent
environment variable.

Changes:
- Add ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
- Add --with-deps flag to playwright install command
- Add comprehensive root cause analysis document

Without this fix, Playwright installed browsers to a default location
at build time but couldn't find them at runtime, causing crawling
operations to fail with "Executable doesn't exist" errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: Remove --with-deps flag to prevent build conflicts

The --with-deps flag was causing build failures on some systems because:
- We already manually install all Playwright dependencies (lines 26-49)
- --with-deps attempts to reinstall these packages
- This causes package conflicts and build failures on Windows/WSL

The core fix (ENV PLAYWRIGHT_BROWSERS_PATH) remains the same.

* Delete PLAYWRIGHT_FIX_ANALYSIS.md

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Cole Medin <cole@dynamous.ai>
2025-10-10 17:11:52 -05:00

79 lines
2.0 KiB
Docker

# 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 pyproject.toml .
# Install server dependencies to a virtual environment using uv
RUN uv venv /venv && \
. /venv/bin/activate && \
uv pip install --group server --group server-reranking
# Runtime stage
FROM python:3.12-slim
WORKDIR /app
# Install runtime dependencies for Playwright (minimal set)
RUN apt-get update && apt-get install -y \
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 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Copy the virtual environment from builder
COPY --from=builder /venv /venv
# Install Playwright browsers
ENV PATH=/venv/bin:$PATH
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN playwright install chromium
# Copy server code and tests
COPY src/server/ src/server/
COPY src/__init__.py src/
COPY tests/ tests/
# Set environment variables
ENV PYTHONPATH="/app:$PYTHONPATH"
ENV PYTHONUNBUFFERED=1
ENV PATH="/venv/bin:$PATH"
# Expose Server port
ARG ARCHON_SERVER_PORT=8181
ENV ARCHON_SERVER_PORT=${ARCHON_SERVER_PORT}
EXPOSE ${ARCHON_SERVER_PORT}
# 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')\""
# Run the Server service
CMD sh -c "python -m uvicorn src.server.main:socket_app --host 0.0.0.0 --port ${ARCHON_SERVER_PORT} --workers 1"