-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (52 loc) · 2 KB
/
Dockerfile
File metadata and controls
64 lines (52 loc) · 2 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
# Use Python 3.9 as the base image
FROM python:3.9-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app
# Install system dependencies for OCR and image processing
RUN apt-get update && apt-get install -y --no-install-recommends \
tesseract-ocr \
tesseract-ocr-eng \
tesseract-ocr-pol \
poppler-utils \
ghostscript \
libsm6 \
libxext6 \
libxrender-dev \
libgl1-mesa-glx \
python3-opencv \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy requirements files
COPY requirements.txt .
COPY examples/email-invoices/requirements.txt ./email-requirements.txt
COPY examples/web-invoices/requirements.txt ./web-requirements.txt
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt \
&& pip install --no-cache-dir -r email-requirements.txt \
&& pip install --no-cache.txt -r web-requirements.txt
# Copy application code
COPY . .
# Create directories for logs and output
RUN mkdir -p /app/logs \
&& mkdir -p /app/output
# Copy configuration files
COPY examples/email-invoices/.env.example /app/examples/email-invoices/.env
COPY examples/web-invoices/.env.example /app/examples/web-invoices/.env
COPY examples/email-invoices/process_invoices.yaml /app/config/email_invoices.yaml
COPY examples/web-invoices/process_web_invoices.yaml /app/config/web_invoices.yaml
# Set environment variables for configuration
ENV EMAIL_CONFIG=/app/config/email_invoices.yaml \
WEB_CONFIG=/app/config/web_invoices.yaml \
LOG_DIR=/app/logs \
OUTPUT_DIR=/app/output
# Create a non-root user and switch to it
RUN useradd -m appuser && chown -R appuser:appuser /app
USER appuser
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:8000/health', timeout=2)" || exit 1
# Default command (can be overridden)
CMD ["python", "-m", "taskinity.cli", "--config", "/app/config/email_invoices.yaml"]