Skip to content

Production-ready animations, transitions, backgrounds, and scenes for Remotion

fix: ensure remotion browser

dev_wandryb87bdc379db8
diff --git a/Dockerfile b/Dockerfile
index fd68afdd..276630d8 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -44,7 +44,9 @@ COPY . .
RUN bun run build
# Bake the Chrome Headless Shell into the image (no slow runtime download).
-RUN bunx remotion browser ensure
+# Uses @remotion/renderer's ensureBrowser() — the `remotion` pkg has no CLI bin
+# (that's @remotion/cli, which we don't install), so `bunx remotion ...` fails.
+RUN bun run remotion:browser
# Pre-bundle the Remotion entry → .remotion-bundle/ (serveUrl ready at boot).
RUN bun run bundle:remotion
diff --git a/README.md b/README.md
index d5573caf..b38752e1 100644
--- a/README.md
+++ b/README.md
@@ -58,7 +58,7 @@ Remotion entry pre-bundled. Two deploy paths on Coolify:
**Nixpacks (Coolify default build pack)** — `nixpacks.toml` declares the Chromium
apt packages so Nixpacks installs them. Set the Coolify commands in the UI:
-- Build: `bun install && bun run build && bunx remotion browser ensure && bun run bundle:remotion`
+- Build: `bun install && bun run build && bun run remotion:browser && bun run bundle:remotion`
- Start: `bun run start`
Under Nixpacks the `Dockerfile` is **not** used.
diff --git a/nixpacks.toml b/nixpacks.toml
index a63bd053..c812709b 100644
--- a/nixpacks.toml
+++ b/nixpacks.toml
@@ -8,10 +8,11 @@
# IMPORTANT: the libs alone aren't enough. The Coolify BUILD command must also
# bake in the browser + the Remotion bundle, e.g.:
#
-# bun install && bun run build && bunx remotion browser ensure && bun run bundle:remotion
+# bun install && bun run build && bun run remotion:browser && bun run bundle:remotion
#
-# (`remotion browser ensure` downloads the Chrome Headless Shell; `bundle:remotion`
-# pre-builds .remotion-bundle/ so the serveUrl is ready at boot.)
+# (`remotion:browser` downloads the Chrome Headless Shell via @remotion/renderer's
+# ensureBrowser() — NOT `bunx remotion ...`, the `remotion` pkg has no CLI binary;
+# `bundle:remotion` pre-builds .remotion-bundle/ so the serveUrl is ready at boot.)
# Start command (Coolify UI): bun run start
#
# NOTE: the Nixpacks base image is Ubuntu Noble (24.04), where the time_t (t64)
diff --git a/package.json b/package.json
index 90126fa3..a4527df7 100644
--- a/package.json
+++ b/package.json
@@ -9,6 +9,7 @@
"lint": "biome check",
"format": "biome format --write",
"registry:build": "shadcn build",
+ "remotion:browser": "bun scripts/ensure-browser.mts",
"bundle:remotion": "bun scripts/bundle-remotion.mts",
"postinstall": "fumadocs-mdx"
},
diff --git a/scripts/ensure-browser.mts b/scripts/ensure-browser.mts
new file mode 100644
index 00000000..86b9603e
--- /dev/null
+++ b/scripts/ensure-browser.mts
@@ -0,0 +1,12 @@
+/**
+ * Download Remotion's Chrome Headless Shell ahead of time so the first render
+ * doesn't pay for it at runtime. Uses @remotion/renderer's `ensureBrowser()`
+ * directly — the `remotion` package has NO CLI binary (that's `@remotion/cli`,
+ * which we don't install), so `bunx remotion browser ensure` does not work here.
+ *
+ * Run: `bun run remotion:browser` (baked into the Docker / Coolify build).
+ */
+import { ensureBrowser } from "@remotion/renderer";
+
+await ensureBrowser();
+console.log("Remotion browser (Chrome Headless Shell) ensured.");