Spaces:
Sleeping
Sleeping
Commit
·
5f5a1d2
1
Parent(s):
422f10d
Update PDF to Markdown converter API with NVIDIA L4 support
Browse files- Dockerfile +19 -5
- app/main.py +2 -2
Dockerfile
CHANGED
@@ -25,11 +25,25 @@ RUN apt-get update && \
|
|
25 |
|
26 |
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
|
27 |
|
28 |
-
# Create
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
WORKDIR /app
|
30 |
|
31 |
-
# Copy requirements first
|
32 |
-
COPY requirements.txt .
|
33 |
|
34 |
# Install PyTorch dependencies with explicit compatible versions for NVIDIA L4
|
35 |
RUN pip3 install --no-cache-dir --upgrade pip && \
|
@@ -37,8 +51,8 @@ RUN pip3 install --no-cache-dir --upgrade pip && \
|
|
37 |
pip3 install --no-cache-dir transformers==4.36.2 && \
|
38 |
pip3 install --no-cache-dir -r requirements.txt
|
39 |
|
40 |
-
# Copy the rest of the application
|
41 |
-
COPY . .
|
42 |
|
43 |
# Expose port
|
44 |
EXPOSE 7860
|
|
|
25 |
|
26 |
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
|
27 |
|
28 |
+
# Create user with UID 1000 (required for Hugging Face Spaces)
|
29 |
+
RUN useradd -m -u 1000 user
|
30 |
+
|
31 |
+
# Create necessary directories and set permissions
|
32 |
+
RUN mkdir -p /app /app/docker_mineru /app/docker_mineru/output /app/docker_mineru/output/images && \
|
33 |
+
chown -R user:user /app
|
34 |
+
|
35 |
+
# Switch to user
|
36 |
+
USER user
|
37 |
+
|
38 |
+
# Set home directory
|
39 |
+
ENV HOME=/home/user \
|
40 |
+
PATH=/home/user/.local/bin:$PATH
|
41 |
+
|
42 |
+
# Set working directory
|
43 |
WORKDIR /app
|
44 |
|
45 |
+
# Copy requirements first (with correct ownership)
|
46 |
+
COPY --chown=user requirements.txt .
|
47 |
|
48 |
# Install PyTorch dependencies with explicit compatible versions for NVIDIA L4
|
49 |
RUN pip3 install --no-cache-dir --upgrade pip && \
|
|
|
51 |
pip3 install --no-cache-dir transformers==4.36.2 && \
|
52 |
pip3 install --no-cache-dir -r requirements.txt
|
53 |
|
54 |
+
# Copy the rest of the application with correct ownership
|
55 |
+
COPY --chown=user . .
|
56 |
|
57 |
# Expose port
|
58 |
EXPOSE 7860
|
app/main.py
CHANGED
@@ -16,8 +16,8 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
16 |
from pdf_converter import convert_pdf_to_md
|
17 |
|
18 |
# --- Configuration for output directory ---
|
19 |
-
#
|
20 |
-
output_dir = "docker_mineru/output"
|
21 |
|
22 |
images_dir = os.path.join(output_dir, "images")
|
23 |
|
|
|
16 |
from pdf_converter import convert_pdf_to_md
|
17 |
|
18 |
# --- Configuration for output directory ---
|
19 |
+
# In Docker container, use /app prefix
|
20 |
+
output_dir = "/app/docker_mineru/output"
|
21 |
|
22 |
images_dir = os.path.join(output_dir, "images")
|
23 |
|