From 732af33dedbd5e5d3f1f0a0c685bf8d1175ed240 Mon Sep 17 00:00:00 2001 From: Jacek Wielemborek Date: Sat, 25 Oct 2025 18:20:01 +0200 Subject: [PATCH] =?UTF-8?q?refactor(docker):=20przenie=C5=9B=20skrypt=20st?= =?UTF-8?q?artowy=20do=20osobnego=20pliku?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Utworzono scripts/test_start_extension.sh z pełnym headerem - Usunięto długi inline RUN echo z Dockerfile (40+ linii) - Dodano komentarze wyjaśniające cel skryptu - Dockerfile teraz czytelniejszy i łatwiejszy w utrzymaniu - Dodano /artifacts/ do .gitignore (docker buildx output) Skrypt zawiera: - Wyjaśnienie czemu istnieje (header) - Uruchomienie Xvfb i web-ext - Weryfikację instalacji extensiona - Czytelne komunikaty sukcesu 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .gitignore | 1 + Dockerfile | 41 +++------------------------- scripts/test_start_extension.sh | 48 +++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 37 deletions(-) create mode 100644 scripts/test_start_extension.sh diff --git a/.gitignore b/.gitignore index 0f003b8..e2a5bd2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules sidebar.js /web-ext-artifacts/ +/artifacts/ lib/* /yarn-error.log /rentgen.zip diff --git a/Dockerfile b/Dockerfile index 9b858bf..ba58371 100644 --- a/Dockerfile +++ b/Dockerfile @@ -79,42 +79,9 @@ RUN apt-get update && apt-get install -y \ # Set display for Xvfb ENV DISPLAY=:99 -# Create startup script with verbose logging and verification -RUN echo '#!/bin/bash\n\ -set -e\n\ -echo "Starting Xvfb on display :99..."\n\ -Xvfb :99 -screen 0 1024x768x24 &\n\ -XVFB_PID=$!\n\ -sleep 2\n\ -\n\ -echo "Xvfb started with PID: $XVFB_PID"\n\ -echo "Starting web-ext run with verbose logging..."\n\ -echo "========================================"\n\ -\n\ -# Run web-ext with verbose logging and capture output\n\ -npx web-ext run --verbose 2>&1 | tee /tmp/web-ext.log &\n\ -WEBEXT_PID=$!\n\ -\n\ -# Wait for extension installation confirmation\n\ -echo "Waiting for extension to install..."\n\ -for i in {1..30}; do\n\ - if grep -q "Installed /app as a temporary add-on" /tmp/web-ext.log 2>/dev/null; then\n\ - echo "========================================"\n\ - echo "✓ SUCCESS: Extension installed!"\n\ - echo "✓ Firefox is running in headless mode"\n\ - echo "✓ Extension: rentgen@internet-czas-dzialac.pl"\n\ - echo "✓ Process info:"\n\ - ps aux | grep -E "(firefox|Xvfb)" | grep -v grep | head -3\n\ - echo "========================================"\n\ - echo "Extension is ready. Press Ctrl+C to stop."\n\ - break\n\ - fi\n\ - sleep 1\n\ -done\n\ -\n\ -# Keep container running and show logs\n\ -wait $WEBEXT_PID\n\ -' > /app/start.sh && chmod +x /app/start.sh +# Copy startup script for extension testing +COPY scripts/test_start_extension.sh /app/test_start_extension.sh +RUN chmod +x /app/test_start_extension.sh # Start script -CMD ["/app/start.sh"] +CMD ["/app/test_start_extension.sh"] diff --git a/scripts/test_start_extension.sh b/scripts/test_start_extension.sh new file mode 100644 index 0000000..a38dd0e --- /dev/null +++ b/scripts/test_start_extension.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# test_start_extension.sh - Uruchamia rozszerzenie Rentgen w headless Firefox z weryfikacją +# +# Ten skrypt jest używany przez Docker runtime stage do: +# 1. Uruchomienia Xvfb (wirtualny X server) na display :99 +# 2. Uruchomienia web-ext run z verbose loggingiem +# 3. Weryfikacji czy extension został poprawnie zainstalowany +# 4. Wyświetlenia czytelnego komunikatu o statusie +# +# Używany w Dockerfile dla łatwego testowania extensiona bez GUI. +# Przeniesiony z inline RUN echo do osobnego pliku dla czytelności. +# + +set -e + +echo "Starting Xvfb on display :99..." +Xvfb :99 -screen 0 1024x768x24 & +XVFB_PID=$! +sleep 2 + +echo "Xvfb started with PID: $XVFB_PID" +echo "Starting web-ext run with verbose logging..." +echo "========================================" + +# Run web-ext with verbose logging and capture output +npx web-ext run --verbose 2>&1 | tee /tmp/web-ext.log & +WEBEXT_PID=$! + +# Wait for extension installation confirmation +echo "Waiting for extension to install..." +for i in {1..30}; do + if grep -q "Installed /app as a temporary add-on" /tmp/web-ext.log 2>/dev/null; then + echo "========================================" + echo "✓ SUCCESS: Extension installed!" + echo "✓ Firefox is running in headless mode" + echo "✓ Extension: rentgen@internet-czas-dzialac.pl" + echo "✓ Process info:" + ps aux | grep -E "(firefox|Xvfb)" | grep -v grep | head -3 + echo "========================================" + echo "Extension is ready. Press Ctrl+C to stop." + break + fi + sleep 1 +done + +# Keep container running and show logs +wait $WEBEXT_PID