File size: 1,291 Bytes
198ccb0 1b82a45 198ccb0 1b82a45 198ccb0 1b82a45 198ccb0 |
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 |
FROM python:3.10-slim
WORKDIR /app
# System deps: curl for healthchecks, build-essential for any compiled wheels
RUN apt-get update && apt-get install -y \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install Python deps
COPY requirements-api.txt requirements-api.txt
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements-api.txt
# Make local packages importable as top-level modules (api/, models/, utils/, etc.)
ENV PYTHONPATH=/app
# Copy code with directory structure intact (required for `uvicorn api.main:app`)
COPY api/ api/
COPY utils/ utils/
COPY analysis/ analysis/
COPY monitoring/ monitoring/
COPY models/ models/
COPY config/ config/
COPY scripts/ scripts/
# Note: Model download happens at runtime (in api/main.py startup) to avoid
# build-time complexity with Railway's build arg system. This is fine - first
# request will be slower, but subsequent requests are fast.
# Ensure monitoring output directory exists (so API can write logs in containers)
RUN mkdir -p monitoring/predictions
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000"]
|