-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (55 loc) · 1.75 KB
/
Dockerfile
File metadata and controls
73 lines (55 loc) · 1.75 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
# Multi-stage Dockerfile for EuroCV
# Optimized for size and security
# Stage 1: Builder
FROM python:3.11-slim AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy source code and project files
COPY src/ /app/src/
COPY pyproject.toml /app/
COPY setup.py /app/
COPY README.md /app/
WORKDIR /app
# Upgrade pip and setuptools to ensure pyproject.toml support
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
# Install the package with all dependencies from pyproject.toml
# Using verbose mode to see what's being installed
RUN pip install --no-cache-dir -v ".[ocr]"
# Stage 2: Runtime
FROM python:3.11-slim
# Install runtime dependencies including Tesseract for OCR
RUN apt-get update && apt-get install -y --no-install-recommends \
tesseract-ocr \
tesseract-ocr-eng \
tesseract-ocr-nld \
&& rm -rf /var/lib/apt/lists/*
# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
# Set environment variables
ENV PATH="/opt/venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Create non-root user for security
RUN useradd -m -u 1000 eurocv && \
mkdir -p /data && \
chown -R eurocv:eurocv /data
# Set working directory
WORKDIR /data
# Switch to non-root user
USER eurocv
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD python -c "import eurocv; print('OK')" || exit 1
# Default command
ENTRYPOINT ["eurocv"]
CMD ["--help"]
# Labels
LABEL maintainer="Emiel Kremers" \
description="Convert resumes to Europass format" \
version="0.1.0"