htmlpdf / Dockerfile
ABDALLALSWAITI's picture
Update Dockerfile
69c816c verified
FROM python:3.13.5-slim
WORKDIR /app
# Install Node.js and system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
chromium \
fonts-liberation \
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 \
ca-certificates \
fonts-freefont-ttf \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
# Create necessary directories with proper permissions
RUN mkdir -p /tmp/.streamlit /app/.streamlit && \
chmod -R 777 /tmp/.streamlit /app/.streamlit /tmp
# Copy package files
COPY requirements.txt ./
COPY package.json ./
# Install dependencies
RUN pip3 install -r requirements.txt
RUN npm install
# Copy Streamlit config
COPY .streamlit/ /app/.streamlit/
# Copy application files
COPY puppeteer_pdf.js ./
COPY api.py ./
COPY start.sh ./
COPY src/ ./src/
# Make start script executable
RUN chmod +x start.sh
# Set environment variables
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
ENV STREAMLIT_SERVER_HEADLESS=true
ENV STREAMLIT_SERVER_FILE_WATCHER_TYPE=none
ENV STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false
ENV STREAMLIT_SERVER_ENABLE_CORS=false
ENV HOME=/tmp
# Expose port 7860 for Hugging Face (FastAPI)
# Port 8501 for Streamlit (internal)
EXPOSE 7860 8501
# Health check on FastAPI port
HEALTHCHECK CMD curl --fail http://localhost:7860/health || exit 1
# Run startup script
CMD ["./start.sh"]