File size: 1,018 Bytes
bfab5ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Use an official Python runtime as a parent image
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9

# Set the working directory in the container
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install necessary system packages
RUN apt-get update && apt-get install -y \
    tesseract-ocr \
    libtesseract-dev \
    poppler-utils

# Install Python dependencies
RUN pip install \
    fastapi \
    uvicorn \
    PyMuPDF \
    torch torchvision\
    tensorflow\
    tf-keras\
    flax\
    pytesseract \
    Pillow \
    llama-index \
    transformers

# Create a non-root user
RUN useradd -ms /bin/bash myuser

# Create cache directory with appropriate permissions under user's home directory
RUN mkdir -p /home/myuser/.cache/huggingface/hub && \
    chown -R myuser /home/myuser/.cache

# Switch to the non-root user
USER myuser

# Expose port 80
EXPOSE 80

# Command to run FastAPI using Uvicorn server
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]