Spaces:
Sleeping
Sleeping
File size: 1,217 Bytes
e1903b4 eef1dca 8b3e35d 7ee6d43 8b3e35d 37aaf51 8b3e35d eef1dca 8b3e35d 7ee6d43 eef1dca 8b3e35d eef1dca 8b3e35d eef1dca 8b3e35d eef1dca 8b3e35d eef1dca 7ee6d43 |
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 |
# Use a compatible Python base image
FROM python:3.9-slim-bookworm
# Set the working directory inside the container
WORKDIR /app
# Update package lists and install all system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
wget \
fontconfig \
libjpeg62-turbo \
libxext6 \
xfonts-75dpi \
xfonts-base \
libxrender1 \
libssl3 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Download and install the wkhtmltox package
RUN wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bookworm_amd64.deb && \
dpkg -i wkhtmltox_0.12.6.1-3.bookworm_amd64.deb && \
rm wkhtmltox_0.12.6.1-3.bookworm_amd64.deb
# Create non-root user as required by HF Spaces
RUN useradd -m -u 1000 user
# Copy application files (before switching user)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Switch to non-root user and set environment
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Copy app code with proper ownership
COPY --chown=1000:1000 app.py .
# Expose the port
EXPOSE 7860
# Run with gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"] |