DR.LIOU_DEMO / Dockerfile
wanwanlin0521's picture
Update Dockerfile
90f54af verified
# Use the official Python image as the base
FROM python:3.10
# Set working directory
WORKDIR /app
# Install system dependencies required for wkhtmltopdf
RUN apt-get update && apt-get install -y \
libxrender1 \
libfontconfig1 \
libxext6 \
xvfb \
wget \
&& rm -rf /var/lib/apt/lists/*
# Manually download and install wkhtmltopdf 0.12.6
RUN wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_amd64.deb \
&& dpkg -i wkhtmltox_0.12.6-1.buster_amd64.deb || apt-get update && apt-get install -f -y \
&& rm wkhtmltox_0.12.6-1.buster_amd64.deb \
&& rm -rf /var/lib/apt/lists/*
# Debug: Verify wkhtmltopdf and wkhtmltoimage installation
RUN wkhtmltopdf --version || { echo "wkhtmltopdf installation failed"; exit 1; }
RUN wkhtmltoimage --version || { echo "wkhtmltoimage installation failed"; exit 1; }
# Debug: List wkhtmltoimage binary locations
RUN echo "Checking for wkhtmltoimage in common locations:" \
&& ls -l /usr/local/bin/wkhtmltoimage 2>/dev/null || echo "/usr/local/bin/wkhtmltoimage not found" \
&& ls -l /usr/bin/wkhtmltoimage 2>/dev/null || echo "/usr/bin/wkhtmltoimage not found" \
&& ls -l /bin/wkhtmltoimage 2>/dev/null || echo "/bin/wkhtmltoimage not found" \
&& find / -name wkhtmltoimage 2>/dev/null || echo "wkhtmltoimage not found anywhere"
# Ensure wkhtmltoimage is in /usr/bin for consistency
RUN if [ -f /usr/local/bin/wkhtmltoimage ]; then \
ln -sf /usr/local/bin/wkhtmltoimage /usr/bin/wkhtmltoimage && \
chmod +x /usr/bin/wkhtmltoimage; \
else \
echo "wkhtmltoimage not found in /usr/local/bin"; \
fi
# Verify wkhtmltoimage in /usr/bin
RUN ls -l /usr/bin/wkhtmltoimage 2>/dev/null || echo "/usr/bin/wkhtmltoimage not created"
# Copy requirements.txt and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the application code
COPY schedule_generator.py .
# Expose the port Gradio will run on
EXPOSE 7860
# Set environment variables for Gradio
ENV GRADIO_SERVER_NAME="0.0.0.0"
ENV GRADIO_SERVER_PORT=7860
# Command to run the application
CMD ["python", "schedule_generator.py"]