ManuelZafra commited on
Commit
c7eaf38
·
verified ·
1 Parent(s): 3ece7d4

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +43 -42
Dockerfile CHANGED
@@ -1,46 +1,47 @@
1
- FROM python:3.10
2
 
3
- # 🔹 Instalar dependencias necesarias
4
  RUN apt-get update && apt-get install -y \
5
  wget \
6
- curl \
7
  unzip \
8
- google-chrome-stable \
9
- && rm -rf /var/lib/apt/lists/*
10
-
11
- # 🔹 Obtener la versión correcta de Chrome
12
- RUN CHROME_VERSION=$(google-chrome --version | awk '{print $3}' | cut -d'.' -f1) && \
13
- echo "Instalando Chromedriver para Chrome v$CHROME_VERSION" && \
14
- wget -O /tmp/chromedriver.zip "https://chromedriver.storage.googleapis.com/${CHROME_VERSION}.0.5735.90/chromedriver_linux64.zip" && \
15
- unzip /tmp/chromedriver.zip -d /usr/bin/ && \
16
- rm /tmp/chromedriver.zip && \
17
- chmod +x /usr/bin/chromedriver
18
-
19
- # 🔹 Verificación de instalación
20
- RUN which google-chrome && which chromedriver && ls -l /usr/bin/chromedriver
21
-
22
-
23
- # 🔹 Definir variables de entorno
24
- ENV CHROME_BIN=/usr/bin/google-chrome
25
- ENV CHROMEDRIVER_PATH=/usr/local/bin/chromedriver
26
-
27
- # 🔹 Instalar dependencias de Python
28
- COPY requirements.txt /tmp/requirements.txt
29
- RUN pip install --no-cache-dir -r /tmp/requirements.txt
30
-
31
- # 🔹 Copiar código del repositorio
32
- WORKDIR /home/user/app
33
- COPY . /home/user/app
34
-
35
- # 🔹 Mostrar rutas antes de ejecutar la app
36
- RUN echo "=== Verificando rutas de Chrome y Chromedriver ===" && \
37
- which google-chrome
38
- which chromedriver
39
- ls -l /usr/bin/ | grep chromedriver
40
- ls -l /usr/local/bin/ | grep chromedriver
41
-
42
-
43
-
44
-
45
- # 🔹 Ejecutar la aplicación
46
- CMD ["python", "app.py"]
 
 
1
+ FROM python:3.9-slim
2
 
3
+ # Instalar dependencias necesarias
4
  RUN apt-get update && apt-get install -y \
5
  wget \
6
+ gnupg \
7
  unzip \
8
+ xvfb \
9
+ libxi6 \
10
+ libgconf-2-4 \
11
+ curl \
12
+ git
13
+
14
+ # Instalar Google Chrome
15
+ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
16
+ && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \
17
+ && apt-get update \
18
+ && apt-get install -y google-chrome-stable
19
+
20
+ # Verificar la instalación de Chrome y su versión
21
+ RUN google-chrome --version
22
+
23
+ # Instalar ChromeDriver correspondiente a la versión de Chrome
24
+ RUN CHROME_VERSION=$(google-chrome --version | awk '{print $3}' | cut -d. -f1) \
25
+ && wget -q "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION" -O /tmp/chromedriver_version \
26
+ && CHROMEDRIVER_VERSION=$(cat /tmp/chromedriver_version) \
27
+ && echo "Using ChromeDriver version: $CHROMEDRIVER_VERSION" \
28
+ && wget -q "https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip" -O /tmp/chromedriver.zip \
29
+ && unzip /tmp/chromedriver.zip -d /usr/local/bin/ \
30
+ && rm /tmp/chromedriver.zip /tmp/chromedriver_version \
31
+ && chmod +x /usr/local/bin/chromedriver
32
+
33
+ # Verificar la instalación de ChromeDriver
34
+ RUN chromedriver --version
35
+
36
+ # Configurar variables de entorno
37
+ ENV PYTHONUNBUFFERED=1
38
+ ENV PATH="/usr/local/bin:${PATH}"
39
+ ENV CHROME_DRIVER_PATH=/usr/local/bin/chromedriver
40
+ ENV DISPLAY=:99
41
+
42
+ # Instalar las dependencias de Python
43
+ COPY requirements.txt .
44
+ RUN pip install --no-cache-dir -r requirements.txt
45
+
46
+ # Comando para ejecutar la aplicación
47
+ CMD ["python", "app.py"]