File size: 1,728 Bytes
c8e875f
 
 
 
 
 
 
 
 
e9ea563
 
c8e875f
 
 
 
 
 
 
 
 
092a7e6
c8e875f
 
092a7e6
 
c8e875f
 
 
 
 
 
 
092a7e6
 
c8e875f
 
71a4080
 
c8e875f
 
3d3a4fd
 
 
 
 
 
 
 
 
 
c8e875f
c507052
c8e875f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
76
77
78
FROM python:3.10-slim as builder

WORKDIR /app

# Install build dependencies and runtime dependencies 
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    gcc \
    g++ \
    libgl1 \
    libglib2.0-0 \
    python3-dev \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements file
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt
    # pip install --no-cache-dir --prefix=/install -r requirements.txt
    # pip install --no-cache-dir --user -r requirements.txt



# Second stage: runtime image
FROM python:3.10-slim

WORKDIR /app

# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    libgl1 \
    libglib2.0-0 \
    poppler-utils \
    tesseract-ocr \
    # libreoffice \
    libtesseract5 \
    && rm -rf /var/lib/apt/lists/*

# --- Test on HFSpace ---
# Copy requirements file
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt
    # pip install --no-cache-dir --user -r requirements.txt
# ---

# Copy the installed packages from the builder stage
# COPY --from=builder /root/.local /root/.local

# Make sure scripts in .local are usable:
ENV PATH=/root/.local/bin:$PATH

# Copy application code
COPY . .

# Create necessary directories
RUN mkdir -p /app/data/temp

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PORT=8000

# Expose the port
EXPOSE 8000

# Set a non-root user
RUN useradd -m appuser
RUN chown -R appuser:appuser /app
USER appuser

# Run the application
CMD ["python", "app.py"]