mirror of
https://github.com/aljazceru/enclava.git
synced 2025-12-17 07:24:34 +01:00
51 lines
1.5 KiB
Docker
51 lines
1.5 KiB
Docker
FROM python:3.11-slim
|
|
|
|
# Set environment variables
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV PYTHONPATH=/app
|
|
|
|
# Set work directory
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies
|
|
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \
|
|
build-essential \
|
|
libpq-dev \
|
|
postgresql-client \
|
|
curl \
|
|
ffmpeg \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install CPU-only PyTorch and compatible numpy first (faster download)
|
|
RUN pip install --no-cache-dir torch==2.5.1+cpu torchaudio==2.5.1+cpu --index-url https://download.pytorch.org/whl/cpu -f https://download.pytorch.org/whl/torch_stable.html
|
|
|
|
# Copy requirements and install Python dependencies
|
|
COPY requirements.txt .
|
|
COPY tests/requirements-test.txt ./tests/
|
|
RUN pip install --no-cache-dir -r requirements.txt && \
|
|
pip install --no-cache-dir -r tests/requirements-test.txt
|
|
|
|
# Optional: Download spaCy English model for NLP processing (commented out for faster builds)
|
|
# Uncomment if you install requirements-nlp.txt and need entity extraction
|
|
# RUN python -m spacy download en_core_web_sm
|
|
|
|
# Copy application code
|
|
COPY . .
|
|
|
|
# Copy and make migration script executable
|
|
COPY scripts/migrate.sh /usr/local/bin/migrate.sh
|
|
RUN chmod +x /usr/local/bin/migrate.sh
|
|
|
|
# Create logs directory
|
|
RUN mkdir -p logs
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8000/health || exit 1
|
|
|
|
# Run the application
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"] |