51 lines
1.3 KiB
Docker
51 lines
1.3 KiB
Docker
# DiaryML Dockerfile
|
|
# Builds a containerized version of DiaryML for easy deployment
|
|
|
|
FROM python:3.11-slim
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Set environment variables
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1
|
|
|
|
# Install system dependencies
|
|
# Required for: SQLCipher, llama-cpp-python compilation, ML libraries
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
cmake \
|
|
git \
|
|
libsqlcipher-dev \
|
|
libssl-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements first for better layer caching
|
|
COPY requirements.txt .
|
|
|
|
# Install Python dependencies
|
|
# Note: llama-cpp-python may take a while to build from source
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY backend/ ./backend/
|
|
COPY frontend/ ./frontend/
|
|
|
|
# Create necessary directories
|
|
RUN mkdir -p models chroma_db uploads
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
|
CMD python -c "import requests; requests.get('http://localhost:8000/api/status')" || exit 1
|
|
|
|
# Set the working directory to backend for running the server
|
|
WORKDIR /app/backend
|
|
|
|
# Run the FastAPI server
|
|
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|