-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (39 loc) · 1.71 KB
/
Dockerfile
File metadata and controls
49 lines (39 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Usar imagem base do Python
FROM python:3.11-slim
# 1. Instalar apenas utilitários básicos para download
# O apt resolverá automaticamente as dependências do Chrome ao instalar o .deb
RUN apt-get update && apt-get install -y \
wget \
curl \
gnupg \
unzip \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/*
# 2. Baixar e instalar Google Chrome Stable diretamente via .deb
# O comando 'apt-get install -y ./google-chrome-stable_current_amd64.deb'
# resolve as dependências (alsa, nss, x11, etc.) automaticamente
# Isso evita erros de pacotes obsoletos como libgconf-2-4
RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
apt-get update && \
apt-get install -y ./google-chrome-stable_current_amd64.deb && \
rm google-chrome-stable_current_amd64.deb && \
rm -rf /var/lib/apt/lists/*
# 3. Configurar variáveis de ambiente para Chrome em containers
ENV CHROME_BIN=/usr/bin/google-chrome
ENV CHROMEDRIVER_PATH=/usr/local/bin/chromedriver
ENV DISPLAY=:99
# Definir diretório de trabalho
WORKDIR /app
# Copiar arquivo de dependências
COPY requirements.txt .
# Instalar dependências
RUN pip install --no-cache-dir -r requirements.txt
# Copiar código da aplicação
COPY . .
# Expor a porta da aplicação (Cloud Run define dinamicamente via variável PORT)
EXPOSE ${PORT:-3000}
# Comando para executar a aplicação usando a porta definida pelo Cloud Run
# IMPORTANTE: Use 0.0.0.0 para tornar acessível do host, não localhost
# --timeout-keep-alive garante que conexões sejam mantidas
# --log-level info para logs mais detalhados durante startup
CMD sh -c "uvicorn main:app --host 0.0.0.0 --port ${PORT:-3000} --timeout-keep-alive 30 --log-level info"