GPTImageGen / Dockerfile
ByFlown's picture
Update Dockerfile
3150af7 verified
# Fresh build 2025-04-23 v6 to force rebuild
FROM ubuntu:20.04
# Set working directory
WORKDIR /app
# Set environment variables to avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
ENV PATH=/usr/local/bin:/usr/bin:/bin:/usr/lib/chromium-browser:$PATH
ENV BUILD_ID=2025-04-23-v6
# Install system dependencies for Chrome and ChromeDriver
RUN apt-get update && apt-get install -y \
wget \
unzip \
curl \
python3 \
python3-pip \
libglib2.0-0 \
libnss3 \
libgconf-2-4 \
libfontconfig1 \
libxrender1 \
libxtst6 \
libxi6 \
libgbm-dev \
libasound2 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libpango-1.0-0 \
libcairo2 \
libgtk-3-0 \
libcups2 \
libxss1 \
libappindicator3-1 \
libindicator3-7 \
libstdc++6 \
zlib1g \
libncurses5 \
libx11-6 \
libxext6 \
libxcomposite1 \
libxrandr2 \
libgcc1 \
&& rm -rf /var/lib/apt/lists/*
# Install Google Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update \
&& apt-get install -y google-chrome-stable \
&& rm -rf /var/lib/apt/lists/* \
|| (echo "Chrome installation failed" && exit 1)
# Verify Chrome installation and binary location
RUN which google-chrome || (echo "google-chrome binary not found" && exit 1)
RUN google-chrome --version || (echo "Cannot run google-chrome" && exit 1)
# Install ChromeDriver matching Chrome version
RUN CHROME_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+') \
&& CHROMEDRIVER_VERSION=$(curl -sS https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | grep -oP '"version":"${CHROME_VERSION}\.[0-9]+"' | grep -oP '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1) \
&& wget -q https://storage.googleapis.com/chrome-for-testing-public/${CHROMEDRIVER_VERSION}/linux64/chromedriver-linux64.zip \
&& unzip chromedriver-linux64.zip \
&& mv chromedriver-linux64/chromedriver /usr/local/bin/ \
&& chmod +x /usr/local/bin/chromedriver \
&& rm chromedriver-linux64.zip \
|| (echo "ChromeDriver installation failed" && exit 1)
# Verify ChromeDriver installation
RUN which chromedriver || (echo "chromedriver binary not found" && exit 1)
RUN chromedriver --version || (echo "Cannot run chromedriver" && exit 1)
# Clear Selenium cache to avoid outdated ChromeDriver
RUN rm -rf /home/user/.cache/selenium
# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
# Copy the app code
COPY app.py .
# Expose the port Gradio will run on
EXPOSE 7860
# Run the Gradio app
CMD ["python3", "app.py"]