From 79cc150f3a864f20991e2423ce1af17892d0b505 Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Tue, 17 Mar 2026 10:22:40 +0200 Subject: [PATCH 1/3] feat(docker): add VERSION label and warm cache during build Pre-render the playground sample during Docker build to populate .facet/ with resolved node_modules, making first user request fast. Pass package.json version as build-arg for image labeling. --- .github/workflows/docker-build.yml | 11 +++++++++++ Dockerfile | 10 +++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index f61c562..a04837f 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -30,6 +30,10 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Get package version + id: pkg + run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT + - name: Build image for testing (amd64 only) uses: docker/build-push-action@v5 with: @@ -40,6 +44,8 @@ jobs: tags: facet:test cache-from: type=gha cache-to: type=gha,mode=max + build-args: | + VERSION=${{ steps.pkg.outputs.version }} - name: Generate PDF from example template run: | @@ -118,6 +124,10 @@ jobs: type=sha type=raw,value=latest,enable={{is_default_branch}} + - name: Get package version + id: pkg + run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT + - name: Build and push Docker image id: build uses: docker/build-push-action@v5 @@ -131,3 +141,4 @@ jobs: cache-to: type=gha,mode=max build-args: | BUILDKIT_INLINE_CACHE=1 + VERSION=${{ steps.pkg.outputs.version }} diff --git a/Dockerfile b/Dockerfile index 662329b..0d55096 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,6 +36,8 @@ RUN cd cli && npm run build # Final stage with Chromium browser FROM node:20-bookworm-slim +ARG VERSION=dev + # Install Chromium browser and dependencies for Puppeteer # Using Chromium from Debian repos for better multi-arch support RUN apt-get update && apt-get install -y \ @@ -114,6 +116,12 @@ EXPOSE 3000 LABEL org.opencontainers.image.title="Facet" \ org.opencontainers.image.description="Generate beautiful PDFs and datasheets from React templates with Chrome" \ org.opencontainers.image.source="https://github.com/flanksource/facet" \ - org.opencontainers.image.vendor="Flanksource" + org.opencontainers.image.vendor="Flanksource" \ + org.opencontainers.image.version="${VERSION}" + +# Warm the node_modules / .facet cache by rendering the playground sample +RUN cd /app/examples && \ + facet pdf SimpleReport.tsx --data simple-data.json --output /tmp/warmup.pdf && \ + rm -f /tmp/warmup.pdf CMD ["facet", "serve", "--templates-dir", "/templates"] From a53b38fb7ccd31a5c3caeb4d6142f099f6281db1 Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Tue, 17 Mar 2026 11:08:11 +0200 Subject: [PATCH 2/3] feat(cli): add playground server with pdf timestamp and page size options Add `make serve` task to run playground server. Expand page size options with digital display formats (FHD, QHD, 4K, 5K). Add PDF timestamping support via TSA URL configuration. Make template discovery more resilient to inaccessible files. --- Makefile | 5 +- Taskfile.yml | 7 + cli/playground.html | 764 ------------------------------ cli/src/server/playground-html.ts | 22 +- cli/src/server/templates.ts | 7 +- 5 files changed, 37 insertions(+), 768 deletions(-) delete mode 100644 cli/playground.html diff --git a/Makefile b/Makefile index b848ad8..de9cfc7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build install test +.PHONY: build install test serve build: task build @@ -9,3 +9,6 @@ install: test: task test + +serve: + task serve diff --git a/Taskfile.yml b/Taskfile.yml index d8f8bb3..d8b067e 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -69,6 +69,13 @@ tasks: - echo "✓ Storybook build completed successfully" - echo "✓ All stories compiled without errors" + serve: + desc: "Build and start the playground server" + deps: + - build + cmds: + - ./dist/facet serve --templates-dir examples + default: desc: "Show available tasks" cmds: diff --git a/cli/playground.html b/cli/playground.html deleted file mode 100644 index 9697e3a..0000000 --- a/cli/playground.html +++ /dev/null @@ -1,764 +0,0 @@ - - - - - - Facet Playground - - - -
- Facet Playground -
- - - -
-
- Margins(mm): - - - - -
-
- -
- - -
- - -
-
-
-
-
-
- - - - - -
-
- - - - -
-
-
Click "Render" to preview your template
-
-
- -
-
-
- Render Log - - - -
-
- -
-
- - - - - diff --git a/cli/src/server/playground-html.ts b/cli/src/server/playground-html.ts index cbf4522..485fb4d 100644 --- a/cli/src/server/playground-html.ts +++ b/cli/src/server/playground-html.ts @@ -104,10 +104,15 @@ const HTML = ` @@ -120,6 +125,10 @@ const HTML = ` +
+ +