diff --git a/Dockerfile b/Dockerfile index 7ba0ae6..9b858bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -73,10 +73,48 @@ FROM builder AS runtime RUN apt-get update && apt-get install -y \ firefox-esr \ xvfb \ + procps \ && rm -rf /var/lib/apt/lists/* # Set display for Xvfb ENV DISPLAY=:99 -# Start Xvfb and run extension in Firefox -CMD Xvfb :99 -screen 0 1024x768x24 & npm run ext-test +# 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 + +# Start script +CMD ["/app/start.sh"]