-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (48 loc) · 1.51 KB
/
Copy pathDockerfile
File metadata and controls
63 lines (48 loc) · 1.51 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
# Multi-stage build for OCR Agent
# Stage 1: Builder
FROM python:3.12-slim as builder
WORKDIR /build
# Install system dependencies for building
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy project files
COPY pyproject.toml setup.py* ./
COPY src ./src
# Build wheels for dependencies
RUN pip install --upgrade pip setuptools wheel && \
pip wheel --no-cache-dir --no-deps --wheel-dir /build/wheels -e .
# Stage 2: Runtime
FROM python:3.12-slim
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Copy wheels from builder
COPY --from=builder /build/wheels /wheels
# Install wheels
RUN pip install --upgrade pip && \
pip install --no-cache /wheels/* && \
rm -rf /wheels
# Copy application code
COPY src ./src
COPY docs ./docs
COPY examples ./examples
# Create directories for uploads and outputs
RUN mkdir -p /app/uploads /app/outputs
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Expose port for web service
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:8000/api/v1/health')" || exit 1
# Default command: start web service
CMD ["ocr-agent", "serve", "--host", "0.0.0.0", "--port", "8000"]