File size: 1,114 Bytes
0e66ecd
d991fac
 
a215c4a
0e66ecd
 
 
 
d991fac
 
0e66ecd
d991fac
 
0e66ecd
d991fac
0e66ecd
d991fac
0e66ecd
d991fac
 
0e66ecd
d991fac
 
0e66ecd
 
d991fac
 
0e66ecd
d991fac
 
0e66ecd
 
d991fac
0e66ecd
d991fac
 
0e66ecd
d991fac
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
# Use a standard Python 3.11 slim image
FROM python:3.11-slim

RUN apt-get update && \
    apt-get install -y tesseract-ocr poppler-utils libglib2.0-0 libsm6 libxext6 libxrender1 libgl1 && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# Set up a new user named "user" with user ID 1000 (required by HF Spaces)
RUN useradd -m -u 1000 user

# Switch to the "user" user
USER user

# Set home to the user's home directory
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Set the working directory to the user's home directory
WORKDIR $HOME/app

# Copy the requirements file first to leverage Docker layer caching
COPY --chown=user requirements.txt .

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

# Copy all your project files into the container with proper ownership
COPY --chown=user . .

# Make our startup script executable
RUN chmod +x ./start.sh

# Hugging Face Spaces will set PORT env; default to 7860 if not set
EXPOSE 7860

# Run the startup script when the container starts
CMD ["./start.sh"]