67 lines
1.4 KiB
Docker
67 lines
1.4 KiB
Docker
|
|
# Multi-stage build for LangChain Learning Kit
|
||
|
|
FROM python:3.11-slim as base
|
||
|
|
|
||
|
|
# Set environment variables
|
||
|
|
ENV PYTHONUNBUFFERED=1 \
|
||
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
||
|
|
PIP_NO_CACHE_DIR=1 \
|
||
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1
|
||
|
|
|
||
|
|
# Install system dependencies
|
||
|
|
RUN apt-get update && apt-get install -y \
|
||
|
|
gcc \
|
||
|
|
g++ \
|
||
|
|
&& rm -rf /var/lib/apt/lists/*
|
||
|
|
|
||
|
|
# Set working directory
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
# Copy requirements
|
||
|
|
COPY requirements.txt .
|
||
|
|
|
||
|
|
# Install Python dependencies
|
||
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
||
|
|
|
||
|
|
|
||
|
|
# Production stage
|
||
|
|
FROM base as production
|
||
|
|
|
||
|
|
# Copy application code
|
||
|
|
COPY src/ ./src/
|
||
|
|
COPY scripts/ ./scripts/
|
||
|
|
|
||
|
|
# Create directories for FAISS indexes
|
||
|
|
RUN mkdir -p /app/data/faiss_indexes
|
||
|
|
|
||
|
|
# Expose port
|
||
|
|
EXPOSE 8000
|
||
|
|
|
||
|
|
# Health check
|
||
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||
|
|
CMD python -c "import requests; requests.get('http://localhost:8000/health')"
|
||
|
|
|
||
|
|
# Run application
|
||
|
|
CMD ["python", "-m", "uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||
|
|
|
||
|
|
|
||
|
|
# Development stage
|
||
|
|
FROM base as development
|
||
|
|
|
||
|
|
# Install development dependencies
|
||
|
|
RUN pip install --no-cache-dir \
|
||
|
|
pytest>=7.4.0 \
|
||
|
|
pytest-asyncio>=0.21.0 \
|
||
|
|
pytest-cov>=4.1.0 \
|
||
|
|
black>=23.7.0 \
|
||
|
|
flake8>=6.1.0 \
|
||
|
|
mypy>=1.5.0
|
||
|
|
|
||
|
|
# Copy application code
|
||
|
|
COPY . .
|
||
|
|
|
||
|
|
# Expose port
|
||
|
|
EXPOSE 8000
|
||
|
|
|
||
|
|
# Run application with reload
|
||
|
|
CMD ["python", "-m", "uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|