-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (53 loc) · 1.57 KB
/
Copy pathDockerfile
File metadata and controls
69 lines (53 loc) · 1.57 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
# Build stage
FROM python:3.11-slim as builder
WORKDIR /app
# Install build system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
make \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements
COPY requirements.txt .
COPY app/mineru_adapter/requirements.txt ./mineru-requirements.txt
# Install dependencies globally (not with --user)
# Install Mineru dependencies first (they are heavier)
RUN pip install --no-cache-dir -r mineru-requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Runtime stage
FROM python:3.11-slim
WORKDIR /app
# Install runtime system dependencies
RUN apt-get update && apt-get install -y \
poppler-utils \
tesseract-ocr \
tesseract-ocr-eng \
tesseract-ocr-deu \
tesseract-ocr-fra \
tesseract-ocr-spa \
libgl1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Copy installed packages from builder stage
COPY --from=builder /usr/local /usr/local
# Copy application code
COPY app/ ./app/
# Create necessary directories
RUN mkdir -p ./uploads ./processed ./app/temp
# Set environment variables
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
ENV OMP_NUM_THUMBNAILS=1
ENV OPENBLAS_NUM_THREADS=1
ENV MKL_NUM_THREADS=1
ENV TOKENIZERS_PARALLELISM=false
# Expose port
EXPOSE 8991
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8991/health || exit 1
# Run as non-root user for security
RUN useradd -m appuser && chown -R appuser:appuser /app
USER appuser
# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8991", "--workers", "2"]