Dockerfile aktualisiert

This commit is contained in:
2025-07-16 12:06:12 +00:00
parent 4449f87ac4
commit fa7dcb6c9e

View File

@@ -1,43 +1,54 @@
# Basis-Image
FROM python:3.8-slim FROM python:3.8-slim
# Arbeitsverzeichnis setzen
WORKDIR /app
# Systemabhängigkeiten für Google Chrome installieren
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
wget \ wget \
unzip \ unzip \
gnupg \ gnupg \
ca-certificates \ ca-certificates \
fonts-liberation \ # Chrome-Bibliotheken
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libcups2 \
libdbus-1-3 \
libgdk-pixbuf2.0-0 \
libnspr4 \
libnss3 \ libnss3 \
libx11-xcb1 \ libxss1 \
libxcomposite1 \ libatk1.0-0 \
libxdamage1 \ libatk-bridge2.0-0 \
libxrandr2 \ libcups2 \
xdg-utils \ libdrm2 \
--no-install-recommends libdbus-1-3 \
libgbm1 \
libgdk-pixbuf2.0-0 \
libgtk-3-0 \
libatspi2.0-0 \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/*
# Google Chrome installieren # Google Chrome Stable installieren
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - && \ RUN 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-chrome.list && \ && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
apt-get update && \ && apt-get update \
apt-get install -y google-chrome-stable && apt-get install -y google-chrome-stable \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# Passenden Chromedriver installieren # Passenden Chromedriver installieren
RUN CHROME_VERSION=$(google-chrome --version | awk '{print $3}') && \ # Diese Methode ist robust und findet die passende Version dynamisch
CHROMEDRIVER_VERSION=$(wget -qO- https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION%.*}) && \ RUN CHROME_VERSION=$(google-chrome --version | cut -f 3 -d ' ' | cut -d '.' -f 1-3) \
wget -O /tmp/chromedriver.zip https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip && \ && DRIVER_VERSION=$(wget -qO- "https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build.json" | grep -A1 "\"${CHROME_VERSION}\"" | grep "version" | cut -d '"' -f 4) \
unzip /tmp/chromedriver.zip -d /usr/local/bin/ && \ && wget -q "https://storage.googleapis.com/chrome-for-testing-public/${DRIVER_VERSION}/linux64/chromedriver-linux64.zip" -O /tmp/chromedriver.zip \
chmod +x /usr/local/bin/chromedriver && \ && unzip /tmp/chromedriver.zip -d /usr/local/bin/ \
rm /tmp/chromedriver.zip && mv /usr/local/bin/chromedriver-linux64/chromedriver /usr/local/bin/ \
&& rm -rf /tmp/chromedriver.zip /usr/local/bin/chromedriver-linux64 \
&& chmod +x /usr/local/bin/chromedriver
WORKDIR /app # Python-Abhängigkeiten installieren
COPY requirements.txt . COPY app/requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python3", "test_selenium.py"] # Den App-Code in den Container kopieren
COPY app/ .
# Standard-Befehl zum Ausführen des Skripts
CMD ["python3", "scrape_fotograf.py"]