Spaces:
No application file
No application file
| # Use Python slim image as base | |
| FROM python:3.11-slim | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # Install system dependencies for Chrome and Selenium | |
| RUN apt-get update && apt-get install -y \ | |
| wget \ | |
| gnupg \ | |
| unzip \ | |
| curl \ | |
| xvfb \ | |
| && 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.list \ | |
| && apt-get update \ | |
| && apt-get install -y google-chrome-stable \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install ChromeDriver | |
| RUN CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` \ | |
| && wget -N http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip \ | |
| && unzip chromedriver_linux64.zip \ | |
| && rm chromedriver_linux64.zip \ | |
| && mv chromedriver /usr/local/bin/chromedriver \ | |
| && chmod +x /usr/local/bin/chromedriver | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy requirements first for better caching | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application code | |
| COPY . . | |
| # Expose port | |
| EXPOSE 7860 | |
| # Create non-root user for security | |
| RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app | |
| USER appuser | |
| # Run the application | |
| CMD ["python", "app.py"] |