Spaces:
Sleeping
Sleeping
| FROM python:3.9-slim | |
| # 1. Instalar dependências do sistema como ROOT | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| python3-dev \ | |
| libffi-dev \ | |
| libssl-dev \ | |
| wget \ | |
| gnupg \ | |
| ca-certificates \ | |
| libglib2.0-0 \ | |
| libnss3 \ | |
| libnspr4 \ | |
| libatk1.0-0 \ | |
| libatk-bridge2.0-0 \ | |
| libcups2 \ | |
| libdrm2 \ | |
| libdbus-1-3 \ | |
| libxcb1 \ | |
| libxkbcommon0 \ | |
| libx11-6 \ | |
| libxcomposite1 \ | |
| libxdamage1 \ | |
| libxext6 \ | |
| libxfixes3 \ | |
| libxrandr2 \ | |
| libgbm1 \ | |
| libpango-1.0-0 \ | |
| libcairo2 \ | |
| libasound2 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # 2. Configurar ambiente e caminhos | |
| ENV PLAYWRIGHT_BROWSERS_PATH=/usr/local/share/playwright | |
| WORKDIR /app | |
| # 3. Instalar dependências Python GLOBALMENTE | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # 4. Instalar navegadores globalmente | |
| RUN playwright install chromium | |
| # 5. Configurar usuário não-root para execução | |
| RUN useradd -m -u 1000 user && \ | |
| chown -R user:user /app && \ | |
| chmod -R 777 /usr/local/share/playwright | |
| # 6. Copiar código | |
| COPY --chown=user . . | |
| USER user | |
| EXPOSE 7860 | |
| # Rodar diretamente com python3 para suportar o loop assíncrono interno | |
| CMD ["python3", "app.py"] | |