File size: 1,031 Bytes
7be97ae
e0b5e14
 
7be97ae
e0b5e14
 
 
7be97ae
e0b5e14
 
f842a38
 
35ebafb
775f409
 
 
7be97ae
9068030
 
 
77d1114
4ff2350
 
f842a38
 
 
7be97ae
e0b5e14
 
 
77d1114
e0b5e14
7be97ae
 
 
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
# Use the official Python 3.9 image as the base image
FROM python:3.9

# Create a non-root user and switch to it
RUN useradd -m -u 1000 user
ENV PATH="/home/user/.local/bin:$PATH"

# Set the working directory
WORKDIR /app

# Install system dependencies (Tesseract OCR) as root
USER root
RUN apt-get update -y && \
    apt-get install -y tesseract-ocr && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*  # Clean up to reduce image size

# Ensure /app is writable by the non-root user
RUN chown user:user /app

# Create a directory for model weights (optional, if you plan to add models later)
RUN mkdir -p /app/models && chown user:user /app/models

# Switch back to the non-root user
USER user

# Copy and install Python dependencies
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Copy the rest of the application code
COPY --chown=user . /app

# Set the command to run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]