AutoML_MLOps_PipeLine / Dockerfile
Abeshith's picture
Upload folder using huggingface_hub
aad6d02 verified
raw
history blame
1.46 kB
# Multi-stage build for minimal image size
FROM python:3.11-slim AS builder
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc g++ \
&& rm -rf /var/lib/apt/lists/*
# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt
# Runtime stage
FROM python:3.11-slim AS runtime
WORKDIR /app
# Install runtime dependencies for ML libraries
RUN apt-get update && apt-get install -y --no-install-recommends \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# Copy installed packages from builder
COPY --from=builder /root/.local /root/.local
# Copy application code (templates are in app/templates/)
COPY src/ ./src/
COPY app/ ./app/
COPY config/ ./config/
COPY monitoring/ ./monitoring/
COPY models/ ./models/
COPY setup.py ./
# Install the mlpipeline package
RUN pip install --no-cache-dir -e .
# Add .local/bin to PATH
ENV PATH=/root/.local/bin:$PATH
ENV PYTHONPATH=/app:$PYTHONPATH
# Set environment variables for CI/CD (override with docker-compose or --env-file)
ENV MLFLOW_TRACKING_URI=""
ENV DAGSHUB_TOKEN=""
# Expose FastAPI port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"
# Run FastAPI
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]