From 6cf9701adca7236fb7dcbcc24d627aa3f38a0d7c Mon Sep 17 00:00:00 2001 From: Jonny Burger Date: Mon, 17 Jun 2024 10:09:30 +0200 Subject: [PATCH 01/11] Create README.md --- packages/dockerfiles/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 packages/dockerfiles/README.md diff --git a/packages/dockerfiles/README.md b/packages/dockerfiles/README.md new file mode 100644 index 00000000000..120b50a4890 --- /dev/null +++ b/packages/dockerfiles/README.md @@ -0,0 +1,3 @@ +Sample Dockerfiles for different operating systems that show how to install Remotion including the browser. + +Uses `npx remotion browser ensure` to install the browser, which requires some shared libraries. From 3201c13181f831bbb21d61ec3c7e88ea5ed2d303 Mon Sep 17 00:00:00 2001 From: Jonny Burger Date: Mon, 17 Jun 2024 11:31:19 +0200 Subject: [PATCH 02/11] add debian distro --- packages/dockerfiles/Dockerfile.debian | 10 ++++++++++ packages/dockerfiles/run.sh | 1 + 2 files changed, 11 insertions(+) create mode 100644 packages/dockerfiles/Dockerfile.debian create mode 100644 packages/dockerfiles/run.sh diff --git a/packages/dockerfiles/Dockerfile.debian b/packages/dockerfiles/Dockerfile.debian new file mode 100644 index 00000000000..ef49a0be31d --- /dev/null +++ b/packages/dockerfiles/Dockerfile.debian @@ -0,0 +1,10 @@ +FROM node:20-bookworm + +RUN apt-get update +WORKDIR /usr/app +RUN git clone https://github.com/remotion-dev/template-helloworld /usr/app +RUN cd /usr/app +RUN npm i +RUN npx remotion browser ensure +RUN apt install libnss3 libdbus-1-3 libatk1.0-0 libgbm-dev libasound2 libxrandr2 libxkbcommon-dev libxfixes3 libxcomposite1 libxdamage1 libatk-bridge2.0-0 -y +RUN npx remotion compositions diff --git a/packages/dockerfiles/run.sh b/packages/dockerfiles/run.sh new file mode 100644 index 00000000000..9edae015bb4 --- /dev/null +++ b/packages/dockerfiles/run.sh @@ -0,0 +1 @@ +docker build --file Dockerfile.debian . --output type=tar,dest=/dev/null --progress=plain From ed8da7439b7d5787c21162876ea68c9b83948fe0 Mon Sep 17 00:00:00 2001 From: Jonny Burger Date: Mon, 17 Jun 2024 12:01:30 +0200 Subject: [PATCH 03/11] add ubuntu way --- packages/dockerfiles/Dockerfile.debian | 13 ++++++++++++- packages/dockerfiles/Dockerfile.ubuntu | 24 ++++++++++++++++++++++++ packages/dockerfiles/run.sh | 2 ++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 packages/dockerfiles/Dockerfile.ubuntu diff --git a/packages/dockerfiles/Dockerfile.debian b/packages/dockerfiles/Dockerfile.debian index ef49a0be31d..e358c990611 100644 --- a/packages/dockerfiles/Dockerfile.debian +++ b/packages/dockerfiles/Dockerfile.debian @@ -6,5 +6,16 @@ RUN git clone https://github.com/remotion-dev/template-helloworld /usr/app RUN cd /usr/app RUN npm i RUN npx remotion browser ensure -RUN apt install libnss3 libdbus-1-3 libatk1.0-0 libgbm-dev libasound2 libxrandr2 libxkbcommon-dev libxfixes3 libxcomposite1 libxdamage1 libatk-bridge2.0-0 -y +RUN apt install -y \ + libnss3 \ + libdbus-1-3 \ + libatk1.0-0 \ + libgbm-dev \ + libasound2 \ + libxrandr2 \ + libxkbcommon-dev \ + libxfixes3 \ + libxcomposite1 \ + libxdamage1 \ + libatk-bridge2.0-0 RUN npx remotion compositions diff --git a/packages/dockerfiles/Dockerfile.ubuntu b/packages/dockerfiles/Dockerfile.ubuntu new file mode 100644 index 00000000000..cebe66eb109 --- /dev/null +++ b/packages/dockerfiles/Dockerfile.ubuntu @@ -0,0 +1,24 @@ +FROM ubuntu:22.04 + +RUN apt-get update +RUN apt-get install git curl make -y +RUN curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s 20 +WORKDIR /usr/app +RUN git clone https://github.com/remotion-dev/template-helloworld /usr/app +RUN cd /usr/app +RUN npm i +RUN npx remotion browser ensure +RUN apt install -y \ + libnss3 \ + libdbus-1-3 \ + libatk1.0-0 \ + libasound2 \ + libxrandr2 \ + libxkbcommon-dev \ + libxfixes3 \ + libxcomposite1 \ + libxdamage1 \ + libgbm-dev \ + libatk-bridge2.0-0 + +RUN npx remotion compositions diff --git a/packages/dockerfiles/run.sh b/packages/dockerfiles/run.sh index 9edae015bb4..bb21c0e7485 100644 --- a/packages/dockerfiles/run.sh +++ b/packages/dockerfiles/run.sh @@ -1 +1,3 @@ +set -e +docker build --file Dockerfile.ubuntu . --output type=tar,dest=/dev/null --progress=plain docker build --file Dockerfile.debian . --output type=tar,dest=/dev/null --progress=plain From 354b18ddcb3442b156ea350c2542ad95ec1b72d7 Mon Sep 17 00:00:00 2001 From: Jonny Burger Date: Mon, 17 Jun 2024 13:27:35 +0200 Subject: [PATCH 04/11] add amazon linux 2023 --- packages/dockerfiles/Dockerfile.al2023 | 12 ++++++++++++ packages/dockerfiles/run.sh | 1 + 2 files changed, 13 insertions(+) create mode 100644 packages/dockerfiles/Dockerfile.al2023 diff --git a/packages/dockerfiles/Dockerfile.al2023 b/packages/dockerfiles/Dockerfile.al2023 new file mode 100644 index 00000000000..f68b7989e14 --- /dev/null +++ b/packages/dockerfiles/Dockerfile.al2023 @@ -0,0 +1,12 @@ +FROM amazonlinux:2023 + +WORKDIR /usr/app +RUN yum install git -y +RUN git clone https://github.com/remotion-dev/template-helloworld /usr/app +RUN cd /usr/app +RUN yum install nodejs -y +RUN npm i +RUN npx remotion browser ensure +RUN yum install mesa-libgbm libX11 libXrandr libdrm libXdamage libXfixes dbus-libs libXcomposite alsa-lib nss dbus at-spi2-core atk at-spi2-atk -y +RUN ldd ./node_modules/.remotion/chrome-headless-shell/linux64/chrome-headless-shell-linux64/chrome-headless-shell +RUN npx remotion compositions diff --git a/packages/dockerfiles/run.sh b/packages/dockerfiles/run.sh index bb21c0e7485..780e2dfc4e7 100644 --- a/packages/dockerfiles/run.sh +++ b/packages/dockerfiles/run.sh @@ -1,3 +1,4 @@ set -e +docker build --file Dockerfile.al2023 . --output type=tar,dest=/dev/null --progress=plain docker build --file Dockerfile.ubuntu . --output type=tar,dest=/dev/null --progress=plain docker build --file Dockerfile.debian . --output type=tar,dest=/dev/null --progress=plain From 13abe4a1bc73cb10be7d4593d471de10a749b94e Mon Sep 17 00:00:00 2001 From: Jonny Burger Date: Mon, 17 Jun 2024 13:29:26 +0200 Subject: [PATCH 05/11] chef kiss! --- packages/dockerfiles/Dockerfile.al2023 | 2 -- packages/dockerfiles/Dockerfile.debian | 1 - packages/dockerfiles/Dockerfile.ubuntu | 1 - 3 files changed, 4 deletions(-) diff --git a/packages/dockerfiles/Dockerfile.al2023 b/packages/dockerfiles/Dockerfile.al2023 index f68b7989e14..bfc0f9dbea5 100644 --- a/packages/dockerfiles/Dockerfile.al2023 +++ b/packages/dockerfiles/Dockerfile.al2023 @@ -6,7 +6,5 @@ RUN git clone https://github.com/remotion-dev/template-helloworld /usr/app RUN cd /usr/app RUN yum install nodejs -y RUN npm i -RUN npx remotion browser ensure RUN yum install mesa-libgbm libX11 libXrandr libdrm libXdamage libXfixes dbus-libs libXcomposite alsa-lib nss dbus at-spi2-core atk at-spi2-atk -y -RUN ldd ./node_modules/.remotion/chrome-headless-shell/linux64/chrome-headless-shell-linux64/chrome-headless-shell RUN npx remotion compositions diff --git a/packages/dockerfiles/Dockerfile.debian b/packages/dockerfiles/Dockerfile.debian index e358c990611..a77be2c1f82 100644 --- a/packages/dockerfiles/Dockerfile.debian +++ b/packages/dockerfiles/Dockerfile.debian @@ -5,7 +5,6 @@ WORKDIR /usr/app RUN git clone https://github.com/remotion-dev/template-helloworld /usr/app RUN cd /usr/app RUN npm i -RUN npx remotion browser ensure RUN apt install -y \ libnss3 \ libdbus-1-3 \ diff --git a/packages/dockerfiles/Dockerfile.ubuntu b/packages/dockerfiles/Dockerfile.ubuntu index cebe66eb109..b1a9cd7ad90 100644 --- a/packages/dockerfiles/Dockerfile.ubuntu +++ b/packages/dockerfiles/Dockerfile.ubuntu @@ -7,7 +7,6 @@ WORKDIR /usr/app RUN git clone https://github.com/remotion-dev/template-helloworld /usr/app RUN cd /usr/app RUN npm i -RUN npx remotion browser ensure RUN apt install -y \ libnss3 \ libdbus-1-3 \ From 6ef0ee5eba54973172751457a36875f2105b5a03 Mon Sep 17 00:00:00 2001 From: Jonny Burger Date: Mon, 17 Jun 2024 14:02:11 +0200 Subject: [PATCH 06/11] explain in docs --- packages/dockerfiles/Dockerfile.al2023 | 16 ++++- packages/docs/docs/cli/browser/ensure.mdx | 5 +- .../docs/miscellaneous/linux-dependencies.mdx | 65 +++++++++++++++++++ packages/docs/sidebars.js | 1 + 4 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 packages/docs/docs/miscellaneous/linux-dependencies.mdx diff --git a/packages/dockerfiles/Dockerfile.al2023 b/packages/dockerfiles/Dockerfile.al2023 index bfc0f9dbea5..15156c55d25 100644 --- a/packages/dockerfiles/Dockerfile.al2023 +++ b/packages/dockerfiles/Dockerfile.al2023 @@ -6,5 +6,19 @@ RUN git clone https://github.com/remotion-dev/template-helloworld /usr/app RUN cd /usr/app RUN yum install nodejs -y RUN npm i -RUN yum install mesa-libgbm libX11 libXrandr libdrm libXdamage libXfixes dbus-libs libXcomposite alsa-lib nss dbus at-spi2-core atk at-spi2-atk -y +RUN yum install -y \ + mesa-libgbm \ + libX11 \ + libXrandr\ + libdrm \ + libXdamage \ + libXfixes \ + dbus -libs\ + libXcomposite \ + alsa -lib \ + nss \ + dbus \ + at-spi2-core \ + atk \ + at-spi2-atk RUN npx remotion compositions diff --git a/packages/docs/docs/cli/browser/ensure.mdx b/packages/docs/docs/cli/browser/ensure.mdx index 87cf0eb81d3..fe4c5b4ef6c 100644 --- a/packages/docs/docs/cli/browser/ensure.mdx +++ b/packages/docs/docs/cli/browser/ensure.mdx @@ -5,6 +5,8 @@ crumb: "@remotion/cli" sidebar_label: "ensure" --- +# npx remotion browser ensure + Ensures that Remotion has a browser it can use for rendering. ``` @@ -17,11 +19,12 @@ npx remotion browser ensure [Path to a custom Chrome executable](/docs/config#setbrowserexecutable). If not specified and Remotion cannot find one, one will be downloaded by this command. -### `--log` +### `--log` ## See also +- [Source code for this command](https://github.com/remotion-dev/remotion/blob/main/packages/cli/src/browser/ensure.ts) - [Chrome Headless Shell](/docs/miscellaneous/chrome-headless-shell) - [`ensureBrowser()`](/docs/renderer/ensure-browser) diff --git a/packages/docs/docs/miscellaneous/linux-dependencies.mdx b/packages/docs/docs/miscellaneous/linux-dependencies.mdx new file mode 100644 index 00000000000..64cd8d66d5e --- /dev/null +++ b/packages/docs/docs/miscellaneous/linux-dependencies.mdx @@ -0,0 +1,65 @@ +--- +sidebar_label: Linux Dependencies +title: Linux Dependencies +crumb: "FAQ" +--- + +If you are on Linux, Chrome requires some shared libraries to be installed. + +## Ubuntu + +```bash +RUN apt install -y \ + libnss3 \ + libdbus-1-3 \ + libatk1.0-0 \ + libasound2 \ + libxrandr2 \ + libxkbcommon-dev \ + libxfixes3 \ + libxcomposite1 \ + libxdamage1 \ + libgbm-dev \ + libatk-bridge2.0-0 +``` + +## Debian + +```bash +RUN apt install -y \ + libnss3 \ + libdbus-1-3 \ + libatk1.0-0 \ + libgbm-dev \ + libasound2 \ + libxrandr2 \ + libxkbcommon-dev \ + libxfixes3 \ + libxcomposite1 \ + libxdamage1 \ + libatk-bridge2.0-0 +``` + +## Amazon Linux 2023 + +```bash +RUN yum install -y \ + mesa-libgbm \ + libX11 \ + libXrandr\ + libdrm \ + libXdamage \ + libXfixes \ + dbus -libs\ + libXcomposite \ + alsa -lib \ + nss \ + dbus \ + at-spi2-core \ + atk \ + at-spi2-atk +``` + +## Alpine Linux + +Not supported due to to unsupported Libc symbols. diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js index 731220629e5..bd1c4e1aca2 100644 --- a/packages/docs/sidebars.js +++ b/packages/docs/sidebars.js @@ -913,6 +913,7 @@ module.exports = { "chromium-flags", "miscellaneous/changing-temp-dir", "miscellaneous/chrome-headless-shell", + "miscellaneous/linux-dependencies", "gl-options", "bun", "standalone", From 365e2b6ce9f7febd7c5afe3942da1a1921e37d13 Mon Sep 17 00:00:00 2001 From: Jonny Burger Date: Mon, 17 Jun 2024 14:10:59 +0200 Subject: [PATCH 07/11] linux dependencies page --- packages/docs/docs/getting-started.mdx | 56 ++++--------------- .../docs/miscellaneous/linux-dependencies.mdx | 2 +- .../docs/troubleshooting/browser-launch.mdx | 2 +- .../renderer/src/browser/BrowserRunner.ts | 2 +- 4 files changed, 13 insertions(+), 49 deletions(-) diff --git a/packages/docs/docs/getting-started.mdx b/packages/docs/docs/getting-started.mdx index eb40e2fd5a5..256923d7d96 100644 --- a/packages/docs/docs/getting-started.mdx +++ b/packages/docs/docs/getting-started.mdx @@ -16,7 +16,10 @@ To use Remotion, you need at least [Node](https://nodejs.org/en/download/) -```bash +```bash title="Use npm as the package manager" npx create-video@latest ``` -```bash +```bash title="Use pnpm as the package manager" pnpm create video ``` @@ -44,7 +47,7 @@ pnpm create video -```bash +```bash title="Use Yarn as the package manager" yarn create video ``` @@ -52,7 +55,7 @@ yarn create video -```bash +```bash title="Use Bun as the package manager and runtime" bun create video ``` @@ -63,7 +66,8 @@ Bun as a runtime is mostly supported. [Read more here](/docs/bun). -Choose the template that is most suitable for you. For your first project, we recommend the [Hello World](/templates/hello-world) template. +Choose the template that is most suitable for you. +For your first project, we recommend the [Hello World](/templates/hello-world) template. After the project has been scaffolded, we recommend to open the project in your text editor and starting the [Remotion Studio](/docs/studio): @@ -71,48 +75,8 @@ After the project has been scaffolded, we recommend to open the project in your npm start ``` -
- - -Additional information for Linux users - - -Linux users need to install some additional packages to get Chrome/Puppeteer working correctly. - - - - -```bash -pacman -S dconf alsa-lib atk glibc cairo libcups dbus expat fontconfig gcc gdk-pixbuf2 glib2 gtk3 nspr pango gcc-libs libx11 libxcomposite libxcursor libxdamage libxext libxfixes libxi libxrandr libxrender libxss libxtst ca-certificates ttf-liberation libappindicator-gtk3 nss lsb-release xdg-utils wget mesa -``` - - - - -```bash -apt install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libnss3 lsb-release xdg-utils wget libgbm-dev -``` - -:::note -Watch out for `apt` wanting to uninstall critical packages (e.g the Desktop) in order to install the Remotion dependencies. Abort the installation and seek help [in our Discord](https://remotion.dev/discord) if that happens! -::: - - - - - -Linux distros that use libc need at least version 2.31 of it. [Check here](https://github.com/remotion-dev/remotion/issues/2439) if your distro has it. - Got instructions for more Linux distributions? [Add them to this page](https://github.com/remotion-dev/remotion/edit/main/packages/docs/docs/getting-started.md)! -
- ## Installation in existing projects Want to install Remotion in an existing project? Go here instead: [Installation in existing projects](/docs/brownfield) diff --git a/packages/docs/docs/miscellaneous/linux-dependencies.mdx b/packages/docs/docs/miscellaneous/linux-dependencies.mdx index 64cd8d66d5e..16721224e49 100644 --- a/packages/docs/docs/miscellaneous/linux-dependencies.mdx +++ b/packages/docs/docs/miscellaneous/linux-dependencies.mdx @@ -4,7 +4,7 @@ title: Linux Dependencies crumb: "FAQ" --- -If you are on Linux, Chrome requires some shared libraries to be installed. +If you are on Linux, Chrome Headless Shell requires some shared libraries to be installed. ## Ubuntu diff --git a/packages/docs/docs/troubleshooting/browser-launch.mdx b/packages/docs/docs/troubleshooting/browser-launch.mdx index 16a01f3e0ed..5148b7cca38 100644 --- a/packages/docs/docs/troubleshooting/browser-launch.mdx +++ b/packages/docs/docs/troubleshooting/browser-launch.mdx @@ -16,7 +16,7 @@ it means the browser was not able to start. The most common reasons are ## Missing shared libraries -Visit the [installation docs](/docs/) and make sure you installed the libraries outlined in "Additional information for Linux users". +Install the [missing shared libraries for your OS](/docs/miscellaneous/linux-dependencies). ## Wrong OS or architecture diff --git a/packages/renderer/src/browser/BrowserRunner.ts b/packages/renderer/src/browser/BrowserRunner.ts index 76acde61bc8..1160a8ae93d 100644 --- a/packages/renderer/src/browser/BrowserRunner.ts +++ b/packages/renderer/src/browser/BrowserRunner.ts @@ -258,7 +258,7 @@ function waitForWSEndpoint( return new Promise((resolve, reject) => { browserStderr.addListener('data', onData); - browserProcess.addListener('close', onClose); + browserStderr.addListener('close', onClose); const listeners = [ () => browserStderr.removeListener('data', onData), () => browserStderr.removeListener('close', onClose), From 8f2f40607500bd3e99aa78ef16f60e9529e6f0d9 Mon Sep 17 00:00:00 2001 From: Jonny Burger Date: Mon, 17 Jun 2024 14:14:56 +0200 Subject: [PATCH 08/11] Update ssr-node.mdx --- packages/docs/docs/ssr-node.mdx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/docs/docs/ssr-node.mdx b/packages/docs/docs/ssr-node.mdx index 4521fbfcd62..6b107a143bf 100644 --- a/packages/docs/docs/ssr-node.mdx +++ b/packages/docs/docs/ssr-node.mdx @@ -6,7 +6,7 @@ crumb: "Server-side rendering" sidebar_label: Example --- -The NPM package [`@remotion/renderer`](/docs/renderer) provides you with an API for rendering media programmatically. +The NPM package [`@remotion/renderer`](/docs/renderer) provides you with "**S**erver-**S**ide **R**endering" APIs for rendering media programmatically. These functions can be used in Node.js and Bun. Rendering a video takes three steps: @@ -16,8 +16,8 @@ Rendering a video takes three steps: 2 Select the composition to render and calculate its metadata
3 Render the video, audio, still or image sequence. -
-
+ +## Example script Follow this commented example to see how to render a video: @@ -75,6 +75,10 @@ This flow is customizable. Click on one of the SSR APIs to read about its option - [`stitchFramesToVideo()`](/docs/renderer/stitch-frames-to-video) - Encode a video based on an image sequence - [`openBrowser()`](/docs/renderer/open-browser) - Share a browser instance across function calls for improved performance. +## Linux Dependencies + +If you are on Linux, Chrome Headless Shell requires some shared libraries to be installed. See [Linux Dependencies](/docs/miscellaneous/linux-dependencies). + ## SSR APIs in Next.js If you are using Next.js, you will not be able to use `@remotion/bundler` because of the limitations explained in [Can I render videos in Next.js?](https://www.remotion.dev/docs/miscellaneous/vercel-functions#can-i-render-videos-in-nextjs) Refer to the page for possible alternatives. From 10ce30d92307d7b3718d3c1a19ac4006d86ef1fa Mon Sep 17 00:00:00 2001 From: Jonny Burger Date: Mon, 17 Jun 2024 14:36:02 +0200 Subject: [PATCH 09/11] Support arm64 browser fetcher --- .../renderer/src/browser/BrowserFetcher.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/renderer/src/browser/BrowserFetcher.ts b/packages/renderer/src/browser/BrowserFetcher.ts index 00d380cff00..fe6459866e5 100644 --- a/packages/renderer/src/browser/BrowserFetcher.ts +++ b/packages/renderer/src/browser/BrowserFetcher.ts @@ -30,8 +30,10 @@ import type {DownloadBrowserProgressFn} from '../options/on-browser-download'; import {getDownloadsCacheDir} from './get-download-destination'; const TESTED_VERSION = '123.0.6312.86'; +// https://github.com/microsoft/playwright/tree/v1.42.0 +const PLAYWRIGHT_VERSION = '1105'; // 123.0.6312.4 -type Platform = 'linux64' | 'mac-x64' | 'mac-arm64' | 'win64'; +type Platform = 'linux64' | 'linux-arm64' | 'mac-x64' | 'mac-arm64' | 'win64'; function getChromeDownloadUrl({ platform, @@ -40,6 +42,10 @@ function getChromeDownloadUrl({ platform: Platform; version: string | null; }): string { + if (platform === 'linux-arm64') { + return `https://playwright.azureedge.net/builds/chromium/${version ?? PLAYWRIGHT_VERSION}/chromium-linux.zip`; + } + return `https://storage.googleapis.com/chrome-for-testing-public/${ version ?? TESTED_VERSION }/${platform}/chrome-headless-shell-${platform}.zip`; @@ -69,7 +75,7 @@ const getPlatform = (): Platform => { case 'darwin': return os.arch() === 'arm64' ? 'mac-arm64' : 'mac-x64'; case 'linux': - return 'linux64'; + return os.arch() === 'arm64' ? 'linux-arm64' : 'linux64'; case 'win32': return 'win64'; default: @@ -115,14 +121,14 @@ export const downloadBrowser = async ({ }); } - // Use system Chromium builds on Linux ARM devices - if (os.platform() !== 'darwin' && os.arch() === 'arm64') { + if ( + os.platform() !== 'darwin' && + os.platform() !== 'win32' && + os.arch() === 'arm64' + ) { throw new Error( [ - 'Chrome Headless Shell is not available for Linux for arm64 architecture.', - 'If you are on Ubuntu, you can install with:', - 'sudo apt install chromium', - 'sudo apt install chromium-browser', + 'Chrome Headless Shell is not available for Windows for arm64 architecture.', ].join('\n'), ); } From a7bcdec06218ee2ce7d09ac264657bf26713c8fe Mon Sep 17 00:00:00 2001 From: Jonny Burger Date: Mon, 17 Jun 2024 14:44:02 +0200 Subject: [PATCH 10/11] progress yes --- packages/dockerfiles/.gitignore | 1 + packages/dockerfiles/Dockerfile.al2023 | 9 ++++++--- packages/dockerfiles/ensure.mjs | 3 +++ packages/dockerfiles/run.sh | 4 ++++ packages/renderer/.gitignore | 1 + packages/renderer/build-browser-downloader.ts | 8 ++++++++ packages/renderer/src/browser/BrowserFetcher.ts | 2 +- 7 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 packages/dockerfiles/.gitignore create mode 100644 packages/dockerfiles/ensure.mjs create mode 100644 packages/renderer/build-browser-downloader.ts diff --git a/packages/dockerfiles/.gitignore b/packages/dockerfiles/.gitignore new file mode 100644 index 00000000000..8c022c039c9 --- /dev/null +++ b/packages/dockerfiles/.gitignore @@ -0,0 +1 @@ +ensure-browser.mjs diff --git a/packages/dockerfiles/Dockerfile.al2023 b/packages/dockerfiles/Dockerfile.al2023 index 15156c55d25..c0647a0bab5 100644 --- a/packages/dockerfiles/Dockerfile.al2023 +++ b/packages/dockerfiles/Dockerfile.al2023 @@ -9,16 +9,19 @@ RUN npm i RUN yum install -y \ mesa-libgbm \ libX11 \ - libXrandr\ + libXrandr \ libdrm \ libXdamage \ libXfixes \ - dbus -libs\ + dbus-libs \ libXcomposite \ - alsa -lib \ + alsa-lib \ nss \ dbus \ at-spi2-core \ atk \ at-spi2-atk +COPY ensure-browser.mjs . +COPY ensure.mjs . +RUN node ensure.mjs RUN npx remotion compositions diff --git a/packages/dockerfiles/ensure.mjs b/packages/dockerfiles/ensure.mjs new file mode 100644 index 00000000000..b5d510a516c --- /dev/null +++ b/packages/dockerfiles/ensure.mjs @@ -0,0 +1,3 @@ +import { ensureBrowser } from "./ensure-browser.mjs"; + +await ensureBrowser(); diff --git a/packages/dockerfiles/run.sh b/packages/dockerfiles/run.sh index 780e2dfc4e7..2011d8ad006 100644 --- a/packages/dockerfiles/run.sh +++ b/packages/dockerfiles/run.sh @@ -1,4 +1,8 @@ set -e +cd ../renderer +bun build-browser-downloader.ts +cp ensure-browser.mjs ../dockerfiles/ensure-browser.mjs +cd ../dockerfiles docker build --file Dockerfile.al2023 . --output type=tar,dest=/dev/null --progress=plain docker build --file Dockerfile.ubuntu . --output type=tar,dest=/dev/null --progress=plain docker build --file Dockerfile.debian . --output type=tar,dest=/dev/null --progress=plain diff --git a/packages/renderer/.gitignore b/packages/renderer/.gitignore index 0347abdc2a4..1d7f0a7033d 100644 --- a/packages/renderer/.gitignore +++ b/packages/renderer/.gitignore @@ -1,2 +1,3 @@ target toolchains +ensure-browser.mjs diff --git a/packages/renderer/build-browser-downloader.ts b/packages/renderer/build-browser-downloader.ts new file mode 100644 index 00000000000..a6ee634c1ad --- /dev/null +++ b/packages/renderer/build-browser-downloader.ts @@ -0,0 +1,8 @@ +const out = await Bun.build({ + entrypoints: ['src/ensure-browser.ts'], + target: 'node', +}); + +Bun.write('ensure-browser.mjs', await out.outputs[0].arrayBuffer()); + +export {}; diff --git a/packages/renderer/src/browser/BrowserFetcher.ts b/packages/renderer/src/browser/BrowserFetcher.ts index fe6459866e5..784aa87d9a0 100644 --- a/packages/renderer/src/browser/BrowserFetcher.ts +++ b/packages/renderer/src/browser/BrowserFetcher.ts @@ -123,7 +123,7 @@ export const downloadBrowser = async ({ if ( os.platform() !== 'darwin' && - os.platform() !== 'win32' && + os.platform() !== 'linux' && os.arch() === 'arm64' ) { throw new Error( From 573bb0ea95718917dd82bbe1f4e91b09ecd0a064 Mon Sep 17 00:00:00 2001 From: Jonny Burger Date: Mon, 17 Jun 2024 15:03:53 +0200 Subject: [PATCH 11/11] This should now support arm64 on Linux too --- .../renderer/src/browser/BrowserFetcher.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/renderer/src/browser/BrowserFetcher.ts b/packages/renderer/src/browser/BrowserFetcher.ts index 784aa87d9a0..a44459bd21d 100644 --- a/packages/renderer/src/browser/BrowserFetcher.ts +++ b/packages/renderer/src/browser/BrowserFetcher.ts @@ -43,7 +43,7 @@ function getChromeDownloadUrl({ version: string | null; }): string { if (platform === 'linux-arm64') { - return `https://playwright.azureedge.net/builds/chromium/${version ?? PLAYWRIGHT_VERSION}/chromium-linux.zip`; + return `https://playwright.azureedge.net/builds/chromium/${version ?? PLAYWRIGHT_VERSION}/chromium-linux-arm64.zip`; } return `https://storage.googleapis.com/chrome-for-testing-public/${ @@ -153,6 +153,23 @@ export const downloadBrowser = async ({ }); Log.info({indent, logLevel}); await extractZip(archivePath, {dir: outputPath}); + const chromePath = path.join(outputPath, 'chrome-linux', 'chrome'); + const chromeHeadlessShellPath = path.join( + outputPath, + 'chrome-linux', + 'chrome-headless-shell', + ); + if (fs.existsSync(chromePath)) { + fs.renameSync(chromePath, chromeHeadlessShellPath); + } + + const chromeLinuxFolder = path.join(outputPath, 'chrome-linux'); + if (fs.existsSync(chromeLinuxFolder)) { + fs.renameSync( + chromeLinuxFolder, + path.join(outputPath, 'chrome-headless-shell-linux-arm64'), + ); + } } finally { if (await existsAsync(archivePath)) { await unlinkAsync(archivePath);