1
0
forked from icd/rentgen
rentgen/Dockerfile
Jacek Wielemborek 732af33ded 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>
2025-10-25 18:20:01 +02:00

88 lines
2.3 KiB
Docker

# Rentgen Browser Extension - Docker Build
#
# Usage:
# Build and extract artifacts directly:
# docker buildx build . --output artifacts
#
# Build with tests (typecheck + lint):
# docker build --build-arg RUN_TESTS=true -t rentgen .
#
# Or traditional build (creates full development environment):
# docker build -t rentgen .
# docker run --rm rentgen ls -lh /app/web-ext-artifacts/
#
# Run commands in the container:
# docker run --rm rentgen npm run build:chrome
# docker run --rm rentgen npm run typecheck
#
# Run extension in Firefox (headless):
# docker build --target runtime -t rentgen-run .
# docker run --rm -it rentgen-run
#
# Using docker-compose:
# docker-compose up rentgen_check # Build only
# docker-compose up rentgen_run # Run in Firefox
# Build stage
FROM node:lts AS builder
# Optional: run tests during build (typecheck + lint)
ARG RUN_TESTS=false
WORKDIR /app
# Copy package files for dependency installation (better layer caching)
COPY package.json package-lock.json ./
# Install dependencies
RUN npm install
# Copy source code (respecting .dockerignore)
COPY . .
# Build the extension for Firefox (default)
RUN npm run build
# Create the package
RUN npm run create-package
# Optional: run quality checks
RUN if [ "$RUN_TESTS" = "true" ]; then \
echo "Running TypeScript type checking..."; \
npm run typecheck; \
echo "Running web-ext lint..."; \
npm run lint; \
fi
# 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 builder AS runtime
# Install Firefox and Xvfb for headless execution
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
# 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/test_start_extension.sh"]