Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +25 -23
Dockerfile
CHANGED
|
@@ -1,29 +1,31 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
# The wkhtmltox "bullseye" package from this source is misconfigured and incorrectly
|
| 4 |
-
# depends on libssl1.1 instead of libssl3.
|
| 5 |
-
# We must manually install libssl1.1 from the older Debian "Buster" repository to satisfy this flawed dependency.
|
| 6 |
-
RUN apt-get update && \
|
| 7 |
-
apt-get install -y --no-install-recommends wget && \
|
| 8 |
-
# 1. Manually download and install the missing dependency
|
| 9 |
-
wget http://deb.debian.org/debian/pool/main/o/openssl/libssl1.1_1.1.1w-0+deb10u1_amd64.deb && \
|
| 10 |
-
dpkg -i libssl1.1_1.1.1w-0+deb10u1_amd64.deb && \
|
| 11 |
-
# 2. Download the user-specified wkhtmltox package
|
| 12 |
-
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.bullseye_amd64.deb && \
|
| 13 |
-
# 3. Install it. 'apt' will handle other dependencies and now finds the libssl1.1 we just added.
|
| 14 |
-
apt install -y ./wkhtmltox_0.12.6.1-2.bullseye_amd64.deb && \
|
| 15 |
-
# 4. Clean up all downloaded .deb files and temporary packages to keep the image small
|
| 16 |
-
rm ./*.deb && \
|
| 17 |
-
apt-get purge -y --auto-remove wget && \
|
| 18 |
-
rm -rf /var/lib/apt/lists/*
|
| 19 |
|
|
|
|
| 20 |
WORKDIR /app
|
|
|
|
|
|
|
| 21 |
COPY requirements.txt .
|
| 22 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 23 |
-
COPY . .
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
-
CMD ["
|
|
|
|
| 1 |
+
# Use a compatible Python base image
|
| 2 |
+
FROM python:3.9-slim-bookworm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
# Set the working directory inside the container
|
| 5 |
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# First, copy and install Python packages to leverage Docker layer caching
|
| 8 |
COPY requirements.txt .
|
| 9 |
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
| 10 |
|
| 11 |
+
# Now, install Playwright's system dependencies and the Chromium browser
|
| 12 |
+
# This is much cleaner and more reliable than the wkhtmltopdf process.
|
| 13 |
+
RUN playwright install-deps
|
| 14 |
+
RUN playwright install chromium
|
| 15 |
+
|
| 16 |
+
# Create non-root user as required by HF Spaces
|
| 17 |
+
RUN useradd -m -u 1000 user
|
| 18 |
+
|
| 19 |
+
# Copy application files (before switching user)
|
| 20 |
+
COPY --chown=1000:1000 app.py .
|
| 21 |
+
|
| 22 |
+
# Switch to non-root user and set environment
|
| 23 |
+
USER user
|
| 24 |
+
ENV HOME=/home/user \
|
| 25 |
+
PATH=/home/user/.local/bin:$PATH
|
| 26 |
+
|
| 27 |
+
# Expose the port
|
| 28 |
+
EXPOSE 7860
|
| 29 |
|
| 30 |
+
# Run with gunicorn
|
| 31 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]
|