mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:21:09 +02:00
main.py's lifespan handler loads `Path(__file__).parent.parent / 'aliases.yaml'` (= /app/aliases.yaml) on startup. The Dockerfile only copied `src/`, so prod containers always crashlooped on first start with `AliasConfigError: alias config not found at /app/aliases.yaml` — which is why mana-llm has been silently absent from prod. Surfaced today after a manual `gh workflow run cd-macmini.yml -f service= mana-llm` actually attempted to start the container instead of relying on a long-stale image. Tested locally: container now starts cleanly, /health returns 200, and `/v1/aliases` lists the configured chains. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
49 lines
1.3 KiB
Docker
49 lines
1.3 KiB
Docker
# Build stage
|
|
FROM python:3.12-slim AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements first for caching
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir --user -r requirements.txt
|
|
|
|
# Production stage
|
|
FROM python:3.12-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Create non-root user
|
|
RUN useradd -m -u 1000 appuser
|
|
|
|
# Copy installed packages from builder
|
|
COPY --from=builder /root/.local /home/appuser/.local
|
|
|
|
# Copy application code + alias config. `aliases.yaml` is loaded by
|
|
# main.py's lifespan handler from `Path(__file__).parent.parent /
|
|
# 'aliases.yaml'` = /app/aliases.yaml. Without it the FastAPI app
|
|
# raises AliasConfigError on startup and the container crashloops.
|
|
COPY --chown=appuser:appuser src/ ./src/
|
|
COPY --chown=appuser:appuser aliases.yaml ./aliases.yaml
|
|
|
|
# Set environment
|
|
ENV PATH=/home/appuser/.local/bin:$PATH
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
|
|
# Switch to non-root user
|
|
USER appuser
|
|
|
|
# Expose port
|
|
EXPOSE 3025
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD python -c "import httpx; httpx.get('http://localhost:3025/health').raise_for_status()"
|
|
|
|
# Run application
|
|
CMD ["python", "-m", "uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "3025"]
|