1
0
forked from icd/rentgen
rentgen/Dockerfile
Jacek Wielemborek 8bf58a2cb1 refactor(test): extract JavaScript test code to test-lib.js
- Created tests/test-lib.js with testBackgroundComputation() function
- Updated test_verify.py to load and execute test library via Marionette
- Modified Dockerfile to copy both test-lib.js and test_verify.py to /app/tests/
- Improved code organization and reusability

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 17:46:26 +01:00

92 lines
2.6 KiB
Docker

# Rentgen Browser Extension - Docker Build
# See README.md for detailed usage instructions
# Build stage
FROM node:lts AS builder
WORKDIR /app
# Copy package files for dependency installation (better layer caching)
COPY package.json package-lock.json ./
# Install dependencies
RUN npm install
# FIXME: COPY . . invalidates cache, so we need to optionally install Firefox
# and jump back to the correct stage. It might be too complex though, so we
# either need to use build args (if cache properly) or heavily document the
# stage transitions, maybe even with a graph.
# Copy source code (respecting .dockerignore)
COPY . .
# Build the extension for Firefox (default)
RUN npm run build
# Create the package
RUN npm run create-package
# Code quality stage - for running quality checks
FROM builder AS code_quality
RUN npm run typecheck && npm run lint
# Artifacts stage - only contains the built artifacts (for --output)
FROM scratch AS artifacts
# Copy only the built extension zip file to root
COPY --from=builder /app/web-ext-artifacts/*.zip /
# Default stage - full development environment
FROM builder
# Default command shows the built artifact
CMD ["ls", "-lh", "/app/web-ext-artifacts/"]
# Runtime stage - for running extension in Firefox
FROM node:lts AS runtime
WORKDIR /app
# Copy built extension from builder
COPY --from=builder /app /app
# Install Firefox and Xvfb for headless execution (cached layer)
RUN apt-get update && apt-get install -y \
firefox-esr \
xvfb \
procps \
&& rm -rf /var/lib/apt/lists/*
# Install Python and pip in a separate layer for better caching
RUN apt-get update && apt-get install -y \
python3-pip \
wget \
&& rm -rf /var/lib/apt/lists/*
# Install geckodriver for WebDriver protocol
RUN wget -q https://github.com/mozilla/geckodriver/releases/download/v0.34.0/geckodriver-v0.34.0-linux64.tar.gz \
&& tar -xzf geckodriver-v0.34.0-linux64.tar.gz \
&& mv geckodriver /usr/local/bin/ \
&& rm geckodriver-v0.34.0-linux64.tar.gz \
&& chmod +x /usr/local/bin/geckodriver
# Install Python dependencies for testing
RUN pip3 install --break-system-packages marionette_driver
# Set display for Xvfb
ENV DISPLAY=:99
# Start script (not used in verify stage)
CMD ["echo", "Use verify stage for testing"]
# Integration test stage - automated testing with exit code
FROM runtime AS integration_test
# Copy verification scripts
COPY tests/test_verify.py /app/tests/test_verify.py
COPY tests/test-lib.js /app/tests/test-lib.js
RUN chmod +x /app/tests/test_verify.py
# Run verification and exit with proper exit code
CMD ["python3", "/app/tests/test_verify.py"]