Update Dockerfile
Browse files- Dockerfile +18 -8
Dockerfile
CHANGED
|
@@ -1,5 +1,16 @@
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
### Set up user with permissions
|
| 4 |
# Set up a new user named "user" with user ID 1000
|
| 5 |
RUN useradd -m -u 1000 user
|
|
@@ -14,18 +25,17 @@ ENV HOME=/home/user \
|
|
| 14 |
# Set the working directory to the user's home directory
|
| 15 |
WORKDIR $HOME/app
|
| 16 |
|
| 17 |
-
# Copy
|
| 18 |
-
COPY --chown=user .
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
COPY
|
| 22 |
-
RUN pip3 install -r requirements.txt
|
| 23 |
-
|
| 24 |
-
COPY . .
|
| 25 |
|
| 26 |
### Update permissions for the app
|
|
|
|
| 27 |
USER root
|
| 28 |
-
RUN chmod 777
|
| 29 |
USER user
|
| 30 |
|
| 31 |
CMD ["python", "main.py"]
|
|
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
| 3 |
+
# -------------------------------------------------------
|
| 4 |
+
# NEW: Install System Dependencies for PDF Image Fallback
|
| 5 |
+
# This must run as root before creating the user.
|
| 6 |
+
# 'poppler-utils' is required for pdf2image to work.
|
| 7 |
+
# -------------------------------------------------------
|
| 8 |
+
USER root
|
| 9 |
+
RUN apt-get update && apt-get install -y \
|
| 10 |
+
poppler-utils \
|
| 11 |
+
libgl1 \
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
+
|
| 14 |
### Set up user with permissions
|
| 15 |
# Set up a new user named "user" with user ID 1000
|
| 16 |
RUN useradd -m -u 1000 user
|
|
|
|
| 25 |
# Set the working directory to the user's home directory
|
| 26 |
WORKDIR $HOME/app
|
| 27 |
|
| 28 |
+
# Copy requirements first to leverage Docker cache
|
| 29 |
+
COPY --chown=user requirements.txt requirements.txt
|
| 30 |
+
RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
|
| 31 |
|
| 32 |
+
# Copy the current directory contents into the container
|
| 33 |
+
COPY --chown=user . $HOME/app
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
### Update permissions for the app
|
| 36 |
+
# Temporarily switch to root to fix permissions (Hugging Face specific)
|
| 37 |
USER root
|
| 38 |
+
RUN chmod -R 777 $HOME/app
|
| 39 |
USER user
|
| 40 |
|
| 41 |
CMD ["python", "main.py"]
|