Spaces:
Sleeping
Sleeping
File size: 1,557 Bytes
656ea8a 3ab509c d895233 3ab509c 656ea8a 4fa97a7 656ea8a 4fa97a7 656ea8a 4fa97a7 37b4054 4fa97a7 c8ffee8 d895233 830142a d895233 3ab509c 830142a c8ffee8 09b7376 cd31f41 d895233 cd31f41 c8ffee8 370b9ad 656ea8a cd31f41 656ea8a 830142a 656ea8a 75b2025 d895233 656ea8a d895233 3ab509c 830142a cd31f41 3ab509c 370b9ad cd31f41 |
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
wget \
gnupg \
chromium \
chromium-sandbox \
fonts-liberation \
fonts-noto \
fonts-noto-cjk \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libcups2 \
libdbus-1-3 \
libdrm2 \
libgbm1 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxkbcommon0 \
libxrandr2 \
xdg-utils \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js 20
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/*
# Create user (required for HF Spaces)
RUN useradd -m -u 1000 user
# Copy dependency files
COPY --chown=user requirements.txt package.json ./
# Install Python and Node dependencies
RUN pip install --no-cache-dir -r requirements.txt
RUN npm install
# Copy application files and the startup script
COPY --chown=user app.py puppeteer_pdf.js ./
COPY --chown=user start.sh ./
# Make scripts executable
RUN chmod +x puppeteer_pdf.js
RUN chmod +x start.sh
# Set permissions
RUN mkdir -p /tmp && chmod 777 /tmp
# Switch to user
USER user
# Environment variables
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium \
PYTHONUNBUFFERED=1
# Expose port
EXPOSE 7860
# Start application using the script
CMD ["./start.sh"] |