multilabel-news-classifier / Dockerfile.api
Solareva Taisia
feat(deploy): add Railway.app support
1b82a45
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"]