File size: 1,781 Bytes
f9dd127
 
 
 
 
 
eaae758
f9dd127
 
 
 
 
 
 
 
 
 
 
 
 
eaae758
 
 
f9dd127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
47
48
49
50
51
52
53
54
55
56
# Use the specific Python 3.10 image as base
FROM docker.io/library/python:3.10@sha256:d12ca2c8482a44ccd00661f0bbc502abf2e96c3bf46e3bdc8f8aeba2d29267f6

# Set the working directory to /home/user/app
WORKDIR /home/user/app

# Install necessary system dependencies including wkhtmltopdf
RUN apt-get update && apt-get install -y \
    git \
    git-lfs \
    ffmpeg \
    libsm6 \
    libxext6 \
    cmake \
    rsync \
    libgl1-mesa-glx \
    wkhtmltopdf \  # Adding wkhtmltopdf for PDF generation
    && rm -rf /var/lib/apt/lists/* \
    && git lfs install

# Check that wkhtmltopdf is correctly installed and print its path
RUN which wkhtmltopdf

# Install the necessary Python packages specified in the requirements.txt file
COPY --mount=target=/tmp/requirements.txt,source=requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt

# Install fakeroot for compatibility with certain builds
RUN apt-get update && apt-get install -y fakeroot && \
    mv /usr/bin/apt-get /usr/bin/.apt-get && \
    echo '#!/usr/bin/env sh\nfakeroot /usr/bin/.apt-get $@' > /usr/bin/apt-get && \
    chmod +x /usr/bin/apt-get && \
    rm -rf /var/lib/apt/lists/* && \
    useradd -m -u 1000 user

# Freeze installed package versions and save to /tmp/freeze.txt
RUN pip freeze > /tmp/freeze.txt

# Install additional dependencies
RUN pip install --no-cache-dir \
    gradio[oauth]==4.42.0 \
    "uvicorn>=0.14.0" \
    spaces

# Copy the rest of the application code into the working directory
COPY --link --chown=1000 ./ /home/user/app

# Copy the freeze.txt file for reference
COPY --from=pipfreeze --link --chown=1000 /tmp/freeze.txt /tmp/freeze.txt

# Set the user to 1000 (non-root user)
USER 1000

# Command to run the application
CMD ["python", "app.py"]