Skip to content

🎥 Make videos programmatically with React

bundle the installer

Jonny Burger0670e3d00f86
diff --git a/packages/cloudrun/gcpInstaller/gcpInstaller.tar b/packages/cloudrun/gcpInstaller/gcpInstaller.tar
index acf7b93322..97901d4e19 100644
Binary files a/packages/cloudrun/gcpInstaller/gcpInstaller.tar and b/packages/cloudrun/gcpInstaller/gcpInstaller.tar differ
diff --git a/packages/cloudrun/package.json b/packages/cloudrun/package.json
index 463c0c45c7..3f3784458f 100644
--- a/packages/cloudrun/package.json
+++ b/packages/cloudrun/package.json
@@ -6,7 +6,7 @@
"scripts": {
"build": "tsc -d && pnpm run buildContainer && pnpm run tarInstaller",
"buildContainer": "ts-node src/admin/bundle-renderLogic.ts",
- "tarInstaller": "mkdir ./temp && tar -cf ./temp/gcpInstaller.tar -C . --exclude='gcpInstaller/gcpInstaller.tar' gcpInstaller && mv ./temp/gcpInstaller.tar ./gcpInstaller && rmdir ./temp",
+ "tarInstaller": "ts-node src/admin/bundle-installer.ts",
"start": "functions-framework --target=TypescriptFunction",
"watch": "tsc -w",
"lint": "eslint src --ext ts,tsx"
diff --git a/packages/cloudrun/src/admin/bundle-installer.ts b/packages/cloudrun/src/admin/bundle-installer.ts
new file mode 100644
index 0000000000..fa31529078
--- /dev/null
+++ b/packages/cloudrun/src/admin/bundle-installer.ts
@@ -0,0 +1,39 @@
+import {BundlerInternals} from '@remotion/bundler';
+import {execSync} from 'child_process';
+import {copyFileSync, mkdirSync, rmSync} from 'fs';
+import path from 'path';
+
+const bundleInstaller = async () => {
+ const outdir = path.join(__dirname, '..', `build-installer`);
+ mkdirSync(outdir, {recursive: true});
+
+ const bundlemjs = path.join(outdir, 'bundled.mjs');
+ await BundlerInternals.esbuild.build({
+ platform: 'node',
+ target: 'node18',
+ bundle: true,
+ outfile: bundlemjs,
+ format: 'esm',
+ entryPoints: [path.resolve(__dirname, '../../gcpInstaller/install.mjs')],
+ });
+
+ const tfoutfile = path.join(outdir, 'main.tf');
+ copyFileSync(
+ path.resolve(__dirname, '../../gcpInstaller/main.tf'),
+ tfoutfile
+ );
+
+ execSync(
+ `tar -cf ../../gcpInstaller/gcpInstaller.tar -C . ${path.relative(
+ outdir,
+ bundlemjs
+ )} ${path.relative(outdir, tfoutfile)}`,
+ {
+ stdio: 'inherit',
+ cwd: outdir,
+ }
+ );
+ rmSync(outdir, {recursive: true});
+};
+
+bundleInstaller();