-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (61 loc) · 1.86 KB
/
Dockerfile
File metadata and controls
75 lines (61 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Multi-stage build for smaller image size and better caching
FROM python:3.12-slim AS base
# Set working directory
WORKDIR /app
# Install system dependencies for OpenCV and PDF processing
RUN apt-get update && apt-get install -y --no-install-recommends \
# Build essentials
gcc \
g++ \
# OpenCV and image processing dependencies
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1 \
libgomp1 \
# PDF and OCR tools
poppler-utils \
tesseract-ocr \
tesseract-ocr-kor \
# Image format libraries
libjpeg62-turbo \
libpng16-16 \
libtiff6 \
libwebp7 \
libopenjp2-7 \
# Clean up
&& rm -rf /var/lib/apt/lists/*
# Copy only requirements first for better caching
COPY requirements.txt .
# Upgrade pip in a separate layer
RUN pip install --no-cache-dir --upgrade pip
# Install Python dependencies in a separate layer
# This layer is only rebuilt when requirements.txt changes
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code last to maximize cache usage
COPY . .
# Create directories for credentials and logs
RUN mkdir -p credentials logs
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
ENV PORT=8000
ENV HOST=0.0.0.0
# ChromaDB SQLite check bypass (for older SQLite versions)
ENV CHROMA_SERVER_NOFILE=1
ENV ALLOW_RESET=TRUE
# Expose port
EXPOSE 8000
# Create necessary directories
RUN mkdir -p temp data/vectorstore data/law_docs
# Add health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:8000/health')"
# Set environment variables for ChromaDB and warnings
ENV CHROMA_TELEMETRY_DISABLED=true
ENV TOKENIZERS_PARALLELISM=false
# Default number of workers
ENV WORKERS=3
# Default command (can be overridden by docker-compose)
CMD ["python", "-m", "app.main"]