FROM python:3.9-slim WORKDIR /app # Ensure Chrome is detectable ENV CHROME_BIN=/usr/bin/google-chrome # Create user first RUN useradd -m -u 1000 user # Install Chrome dependencies RUN apt-get update && apt-get install -y \ wget \ gnupg \ && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg \ && echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] 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/* COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application with ownership COPY --chown=user . . # Grant write permission to root dir (fix for build failure & runtime lag) RUN chmod 777 /app USER user EXPOSE 7860 CMD ["python", "app.py"]