refactor(docker): przenieś skrypt startowy do osobnego pliku

- 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 <noreply@anthropic.com>
This commit is contained in:
Jacek Wielemborek 2025-10-25 18:20:01 +02:00
parent 1f47574afe
commit 732af33ded
3 changed files with 53 additions and 37 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
node_modules
sidebar.js
/web-ext-artifacts/
/artifacts/
lib/*
/yarn-error.log
/rentgen.zip

View File

@ -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"]

View File

@ -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