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..bfbc756 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,15 @@ 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
+
+HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
+ CMD curl -f http://localhost:3010/healthz || exit 1
CMD ["facet", "serve", "--templates-dir", "/templates"]
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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Click "Render" to preview your template
-
-
-
-
-
-
-
-
-
diff --git a/cli/src/bundler/vite-builder.ts b/cli/src/bundler/vite-builder.ts
index 5be0861..c7aa145 100644
--- a/cli/src/bundler/vite-builder.ts
+++ b/cli/src/bundler/vite-builder.ts
@@ -78,7 +78,8 @@ export async function buildTemplate(options: BuildOptions): Promise
const hash = depHash(pkgDeps);
if (!linkCachedNodeModules(facetRoot, hash, logger) && facetDir.needsInstall()) {
- logger.debug('Installing dependencies...');
+ logger.info('npm install...');
+ const npmStart = Date.now();
try {
const npmResult = await $`cd ${facetRoot} && npm install --ignore-scripts 2>&1`.quiet();
logger.debug(npmResult.stdout.toString());
@@ -86,8 +87,8 @@ export async function buildTemplate(options: BuildOptions): Promise
const output = error?.stdout?.toString?.() || error?.stderr?.toString?.() || error?.message || String(error);
throw new Error(`npm install failed in ${facetRoot}:\n${output}`);
}
+ logger.info(`npm install completed in ${Date.now() - npmStart}ms`);
promoteToCacheAfterInstall(facetRoot, hash, logger);
- logger.debug('Dependencies installed');
} else {
logger.debug('Dependencies up to date, skipping npm install');
}
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 = `
+
+
+