🎥 Make videos programmatically with React
bundle working and running in docker
Matt Mcgillivrayb3db1ee8f200
diff --git a/packages/gcp/Dockerfile b/packages/gcp/Dockerfiledeleted file mode 100644index 092973efe0..0000000000--- a/packages/gcp/Dockerfile+++ /dev/null@@ -1,22 +0,0 @@-FROM node:alpine--ADD ./packages/gcp/chromium-x64 /opt/bin/chromium--ARG PNPM_VERSION=7.7.1-RUN npm --no-update-notifier --no-fund --global install pnpm@${PNPM_VERSION}--ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \- PUPPETEER_EXECUTABLE_PATH=/opt/bin/chromium--WORKDIR /root/monorepo-COPY . .--RUN pnpm install --filter "@remotion/gcp..."-# RUN pnpm build --filter "@remotion/gcp..."--WORKDIR /root/monorepo/packages/gcp--EXPOSE 8080--CMD ["pnpm", "run", "start"]-# CMD ["npm", "run", "start"]\ No newline at end of filediff --git a/packages/gcp/container/Dockerfile b/packages/gcp/container/Dockerfilenew file mode 100644index 0000000000..552ef61647--- /dev/null+++ b/packages/gcp/container/Dockerfile@@ -0,0 +1,28 @@+FROM node:alpine++RUN apk add --no-cache \+ chromium \+ nss \+ freetype \+ freetype-dev \+ harfbuzz \+ ca-certificates \+ ttf-freefont \+ ffmpeg \+ font-noto-emoji++ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \+ PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser++WORKDIR /usr/app+++COPY package*.json ./+COPY dist ./dist++RUN npm i++EXPOSE 8080++# CMD ["npm", "run", "list"]+CMD ["npm", "run", "start"]\ No newline at end of filediff --git a/packages/gcp/container/package.json b/packages/gcp/container/package.jsonnew file mode 100644index 0000000000..89253dd563--- /dev/null+++ b/packages/gcp/container/package.json@@ -0,0 +1,12 @@+{+ "name": "gcp-container",+ "version": "0.0.1",+ "description": "GCP alternative to lambda rendering",+ "main": "dist/index.js",+ "scripts": {+ "start": "functions-framework --target=functionStart"+ },+ "dependencies": {+ "@google-cloud/functions-framework": "^3.1.3"+ }+}diff --git a/packages/gcp/src/bundle-lambda.ts b/packages/gcp/src/bundle-lambda.tsindex 60830b753e..3b1d903b46 100644--- a/packages/gcp/src/bundle-lambda.ts+++ b/packages/gcp/src/bundle-lambda.ts@@ -5,7 +5,7 @@ import path from 'path';import zl = require('zip-lib');const bundleLambda = async () => {- const outdir = path.join(__dirname, '..', `dist`);+ const outdir = path.join(__dirname, '..', 'container', '/', 'dist');fs.mkdirSync(outdir, {recursive: true,});diff --git a/packages/gcp/src/helpers/get-chromium-executable-path.ts b/packages/gcp/src/helpers/get-chromium-executable-path.tsindex de089cdf29..a95a055492 100644--- a/packages/gcp/src/helpers/get-chromium-executable-path.ts+++ b/packages/gcp/src/helpers/get-chromium-executable-path.ts@@ -12,5 +12,5 @@ if (}export const executablePath = async (): Promise<string | undefined> => {- return '/opt/bin/chromium';+ return '/usr/bin/chromium-browser';};diff --git a/packages/gcp/src/index.ts b/packages/gcp/src/index.tsindex 5e624ae13d..96e05d08e4 100644--- a/packages/gcp/src/index.ts+++ b/packages/gcp/src/index.ts@@ -1,10 +1,9 @@import * as ff from '@google-cloud/functions-framework';// import {getCompositions} from '@remotion/renderer';import {getBrowserInstance} from './helpers/get-browser-instance';-import { existsSync, readdirSync } from 'node:fs';+import { existsSync } from 'node:fs';--ff.http('TypescriptFunction', async (req: ff.Request, res: ff.Response) => {+export const functionStart = async (req: ff.Request, res: ff.Response) => {const AWSUrl ='https://remotionlambda-11kow3vq6f.s3.us-east-1.amazonaws.com/sites/xmycbufjs3/index.html';const GCPUrl =@@ -15,20 +14,14 @@ ff.http('TypescriptFunction', async (req: ff.Request, res: ff.Response) => {// const comps = await getCompositions(AWSUrl);// console.log('comps', comps);- // const browserInstance = await getBrowserInstance(true, {});- // console.log('browserInstance', browserInstance);-- console.log('inside index.ts');-+ const browserInstance = await getBrowserInstance(true, {});+ console.log('browserInstance', browserInstance);- if (existsSync('/opt/bin/chromium')) {+ if (existsSync('/usr/bin/chromium-browser')) {console.log('The path exists.');- readdirSync('/opt/bin/chromium/bin').forEach(file => {- console.log(file);- });} else {console.log('The path does not exist.');}res.send('OK');-});+};