🎥 Make videos programmatically with React
list sites, list services + docs
Matt McGillivrayac0f80bc5dfc
diff --git a/packages/cloudrun/gcpInstaller/gcpInstaller.tar b/packages/cloudrun/gcpInstaller/gcpInstaller.tarindex 18f04473e9..c48ed2d069 100644Binary files a/packages/cloudrun/gcpInstaller/gcpInstaller.tar and b/packages/cloudrun/gcpInstaller/gcpInstaller.tar differdiff --git a/packages/cloudrun/sa-permissions.json b/packages/cloudrun/sa-permissions.jsonindex a72c6db3a6..f84faacc32 100644--- a/packages/cloudrun/sa-permissions.json+++ b/packages/cloudrun/sa-permissions.json@@ -4,6 +4,7 @@"run.operations.get","run.routes.invoke","run.services.create",+ "run.services.get","run.services.list","run.services.update","storage.buckets.create",diff --git a/packages/cloudrun/src/api/deploy-service.ts b/packages/cloudrun/src/api/deploy-service.tsindex 9a48e84f15..9e1872aed0 100644--- a/packages/cloudrun/src/api/deploy-service.ts+++ b/packages/cloudrun/src/api/deploy-service.ts@@ -12,7 +12,6 @@ export type DeployServiceInput = {cpu?: string;projectID: string;region: string;- redeploy: boolean;};export type DeployServiceOutput = {diff --git a/packages/cloudrun/src/api/get-regions.ts b/packages/cloudrun/src/api/get-regions.tsnew file mode 100644index 0000000000..fe94f56720--- /dev/null+++ b/packages/cloudrun/src/api/get-regions.ts@@ -0,0 +1,11 @@+import type {GcpRegion} from '../pricing/gcp-regions';+import {GCP_REGIONS} from '../regions';++/**+ * @description Gets an array of all supported GCP regions of this release of Remotion Cloudrun.+ * @see [Documentation](https://remotion.dev/docs/cloudrun/getregions)+ * @returns {AwsRegion[]} A list of GCP regions.+ */+export const getRegions = (): readonly GcpRegion[] => {+ return GCP_REGIONS;+};diff --git a/packages/cloudrun/src/api/get-service-info.ts b/packages/cloudrun/src/api/get-service-info.tsnew file mode 100644index 0000000000..09f104b1d1--- /dev/null+++ b/packages/cloudrun/src/api/get-service-info.ts@@ -0,0 +1,53 @@+import type {GcpRegion} from '../client';+import {RENDER_SERVICE_PREFIX} from '../shared/constants';+import {getCloudRunClient} from './helpers/get-cloud-run-client';++export type ServiceInfo = {+ serviceName: string;+ timeoutInSeconds: number;+ memoryLimit: string;+ cpuLimit: string;+ remotionVersion: string | null;+};++export type GetServiceInfoInput = {+ region: GcpRegion;+ serviceName: string;+};+/**+ * @description Lists Remotion Cloud Run render services deployed to GCP Cloud Run.+ * @see [Documentation](https://remotion.dev/docs/cloudrun/getservices)+ * @param options.region The region of which the services should be listed.+ * @param options.compatibleOnly Whether only services compatible with the installed version of Remotion Cloud Run should be returned.+ * @returns {Promise<ServiceInfo[]>} An array with the objects containing information about the deployed services.+ */++export const getServiceInfo = async ({+ region,+ serviceName,+}: GetServiceInfoInput): Promise<ServiceInfo> => {+ const cloudRunClient = getCloudRunClient();++ const [service] = await cloudRunClient.getService({+ name: `projects/${process.env.REMOTION_GCP_PROJECT_ID}/locations/${region}/services/${serviceName}`,+ });++ if (!service) {+ throw new Error(`Service ${serviceName} not found`);+ }++ const parent = `projects/${process.env.REMOTION_GCP_PROJECT_ID}/locations/${region}`;++ return {+ serviceName: service.name?.replace(parent + '/services/', '') as string,+ timeoutInSeconds: service.template?.timeout?.seconds as number,+ memoryLimit: service.template?.containers?.[0].resources?.limits+ ?.memory as string,+ cpuLimit: service.template?.containers?.[0].resources?.limits+ ?.cpu as string,+ remotionVersion: service.name+ ?.replace(parent + '/services/' + RENDER_SERVICE_PREFIX + '--', '')+ .split('--')[0]+ .replace(/-/g, '.') as string,+ };+};diff --git a/packages/cloudrun/src/api/get-services.ts b/packages/cloudrun/src/api/get-services.tsindex 5435c6b60b..81081d55c9 100644--- a/packages/cloudrun/src/api/get-services.ts+++ b/packages/cloudrun/src/api/get-services.ts@@ -1,6 +1,7 @@import type {GcpRegion} from '../client';import {RENDER_SERVICE_PREFIX} from '../shared/constants';import {SERVICE_VERSION_STRING} from '../shared/service-version-string';+import type {ServiceInfo} from './get-service-info';import {getCloudRunClient} from './helpers/get-cloud-run-client';import type {IService} from './helpers/IService';@@ -9,14 +10,6 @@ export type GetServicesInput = {compatibleOnly: boolean;};-export type ServiceInfo = {- serviceName: string;- timeoutInSeconds: number;- memoryLimit: string;- cpuLimit: string;- remotionVersion: string | null;-};-/*** @description Lists Remotion Cloud Run render services deployed to GCP Cloud Run.* @see [Documentation](https://remotion.dev/docs/cloudrun/getservices)diff --git a/packages/cloudrun/src/api/get-sites.ts b/packages/cloudrun/src/api/get-sites.tsnew file mode 100644index 0000000000..1ffef644a3--- /dev/null+++ b/packages/cloudrun/src/api/get-sites.ts@@ -0,0 +1,68 @@+import type {GcpRegion} from '../client';+import {REMOTION_BUCKET_PREFIX} from '../shared/constants';+import {getCloudStorageClient} from './helpers/get-cloud-storage-client';++type Site = {+ lastModified: number | null;+ bucketName: string;+ id: string;+ serveUrl: string;+};++export type GetSitesInput = {+ bucketName?: string;+};++export type BucketWithLocation = {+ name: string;+ creationDate: number;+ region: GcpRegion;+};++export type GetSitesOutput = {+ sites: Site[];+ buckets: BucketWithLocation[];+};++/**+ * @description Gets all the deployed sites for a certain GCP project.+ * @see [Documentation](https://remotion.dev/docs/cloudrun/getsites)+ * @returns {Promise<GetSitesOutput>} A Promise containing an object with `sites` and `bucket` keys. Consult documentation for details.+ */+export const getSites = async (): Promise<GetSitesOutput> => {+ const cloudStorageClient = getCloudStorageClient();+ const buckets: BucketWithLocation[] = [];+ const sites: Site[] = [];++ const [fetchedBuckets] = await cloudStorageClient.getBuckets();++ for (const bucket of fetchedBuckets) {+ if (bucket.name?.startsWith(REMOTION_BUCKET_PREFIX)) {+ const bucketObject = {+ name: bucket.name,+ creationDate: new Date(bucket.metadata?.timeCreated).getTime(),+ region: bucket.metadata.location,+ };+ buckets.push(bucketObject);+ }+ }++ for (const bucket of buckets) {+ const [, , apiResponse] = await cloudStorageClient+ .bucket(bucket.name)+ .getFiles({autoPaginate: false, delimiter: '/', prefix: 'sites/'});++ for (const prefix of apiResponse.prefixes) {+ const sitePath = prefix.split('/');++ sites.push({+ bucketName: bucket.name,+ id: sitePath[1],+ serveUrl: `https://storage.googleapis.com/${bucket.name}/${prefix}index.html`,+ lastModified: null,+ });+ }+ }++ return {sites, buckets};+};diff --git a/packages/cloudrun/src/cli/commands/services/ls.ts b/packages/cloudrun/src/cli/commands/services/ls.tsindex a6ede35186..65c0df83c2 100644--- a/packages/cloudrun/src/cli/commands/services/ls.ts+++ b/packages/cloudrun/src/cli/commands/services/ls.ts@@ -1,4 +1,5 @@import {CliInternals} from '@remotion/cli';+import {getServiceInfo} from '../../../api/get-service-info';import {getServices} from '../../../api/get-services';import {getGcpRegion} from '../../get-gcp-region';@@ -18,6 +19,13 @@ export const servicesLsCommand = async () => {});fetchingOutput.update('Getting services...');+ const serviceTest = await getServiceInfo({+ region,+ serviceName: 'remotion--3-3-82--mem512mi--cpu2-0',+ });++ CliInternals.Log.info('serviceTest: ', serviceTest);+const services = await getServices({region,compatibleOnly: false,diff --git a/packages/cloudrun/src/cli/commands/sites/index.ts b/packages/cloudrun/src/cli/commands/sites/index.tsindex cfe806aff3..a7e38f5883 100644--- a/packages/cloudrun/src/cli/commands/sites/index.ts+++ b/packages/cloudrun/src/cli/commands/sites/index.ts@@ -3,6 +3,7 @@ import {BINARY_NAME} from '../../../shared/constants';import {quit} from '../../helpers/quit';import {Log} from '../../log';import {sitesCreateSubcommand, SITES_CREATE_SUBCOMMAND} from './create';+import {sitesLsSubcommand, SITES_LS_SUBCOMMAND} from './ls';export const SITES_COMMAND = 'sites';@@ -15,11 +16,22 @@ const printSitesHelp = () => {Log.info(CliInternals.chalk.gray('Creates a new site based on a Remotion project'));+ CliInternals.Log.info();+ CliInternals.Log.info(+ `${BINARY_NAME} ${SITES_COMMAND} ${SITES_LS_SUBCOMMAND}`+ );+ CliInternals.Log.info(+ CliInternals.chalk.gray('Lists the sites currently deployed')+ );};-// TODO: Add LS, RM, RMALL subcommands+// TODO: Add RM, RMALL subcommandsexport const sitesCommand = (args: string[], remotionRoot: string) => {+ if (args[0] === SITES_LS_SUBCOMMAND) {+ return sitesLsSubcommand();+ }+if (args[0] === SITES_CREATE_SUBCOMMAND) {return sitesCreateSubcommand(args.slice(1), remotionRoot);}diff --git a/packages/cloudrun/src/cli/commands/sites/ls.ts b/packages/cloudrun/src/cli/commands/sites/ls.tsnew file mode 100644index 0000000000..37c169f01c--- /dev/null+++ b/packages/cloudrun/src/cli/commands/sites/ls.ts@@ -0,0 +1,58 @@+import {CliInternals} from '@remotion/cli';+import {getSites} from '../../../api/get-sites';+import {dateString} from '../../helpers/date-string';++export const SITES_LS_SUBCOMMAND = 'ls';++const COLS: [number, number, number] = [20, 30, 15];++const logRow = (data: [string, string, string]) => {+ return [+ data[0].padEnd(COLS[0], ' '),+ data[1].padEnd(COLS[1], ' '),+ String(data[2]).padEnd(COLS[2], ' '),+ ].join('');+};++export const sitesLsSubcommand = async () => {+ const {sites, buckets} = await getSites();++ if (buckets.length > 1 && !CliInternals.quietFlagProvided()) {+ CliInternals.Log.warn(+ 'Warning: You have more than one Remotion Cloud Storage bucket, but only one is needed. This can lead to conflicts. Remove all but one of them.'+ );+ }++ const sitesPluralized = sites.length === 1 ? 'site' : 'sites';+ if (!CliInternals.quietFlagProvided()) {+ CliInternals.Log.info(+ `${sites.length} ${sitesPluralized} in the ${process.env.REMOTION_GCP_PROJECT_ID} project.`+ );+ }++ if (CliInternals.quietFlagProvided()) {+ if (sites.length === 0) {+ CliInternals.Log.info('()');+ return;+ }++ return CliInternals.Log.info(sites.map((s) => s.id).join(' '));+ }++ CliInternals.Log.info();+ CliInternals.Log.info(+ CliInternals.chalk.gray(logRow(['Site Name', 'Bucket', 'Last updated']))+ );++ for (const site of sites) {+ CliInternals.Log.info(+ logRow([+ site.id,+ site.bucketName,+ site.lastModified ? dateString(new Date(site.lastModified)) : 'n/a',+ ])+ );+ CliInternals.Log.info(site.serveUrl);+ CliInternals.Log.info();+ }+};diff --git a/packages/cloudrun/src/cli/helpers/date-string.ts b/packages/cloudrun/src/cli/helpers/date-string.tsnew file mode 100644index 0000000000..733cbc995b--- /dev/null+++ b/packages/cloudrun/src/cli/helpers/date-string.ts@@ -0,0 +1,6 @@+export const dateString = (date: Date) =>+ date.getFullYear() ++ '-' ++ String(date.getMonth() + 1).padStart(2, '0') ++ '-' ++ String(date.getDate()).padStart(2, '0');diff --git a/packages/cloudrun/src/index.ts b/packages/cloudrun/src/index.tsindex 4585ea1b25..64640f330d 100644--- a/packages/cloudrun/src/index.ts+++ b/packages/cloudrun/src/index.ts@@ -5,7 +5,10 @@ import type {import {deployService} from './api/deploy-service';import {deploySite} from './api/deploy-site';import {getOrCreateBucket} from './api/get-or-create-bucket';+import {getRegions} from './api/get-regions';+import {getServiceInfo} from './api/get-service-info';import {getServices} from './api/get-services';+import {getSites} from './api/get-sites';import {renderMediaOnCloudrun} from './api/render-media-on-cloudrun';import {renderStillOnCloudrun} from './api/render-still-on-cloudrun';import {CloudrunInternals} from './internals';@@ -18,5 +21,8 @@ export {getOrCreateBucket,renderMediaOnCloudrun,renderStillOnCloudrun,+ getServiceInfo,+ getRegions,+ getSites,};export type {DeployServiceInput, DeployServiceOutput};diff --git a/packages/docs/components/TableOfContents/cloudrun.tsx b/packages/docs/components/TableOfContents/cloudrun.tsxnew file mode 100644index 0000000000..21b026204b--- /dev/null+++ b/packages/docs/components/TableOfContents/cloudrun.tsx@@ -0,0 +1,100 @@+import React from "react";+import { Grid } from "./Grid";+import { TOCItem } from "./TOCItem";++export const TableOfContents: React.FC = () => {+ return (+ <div>+ <Grid>+ {/* <TOCItem link="/docs/cloudrun/estimateprice">+ <strong>estimatePrice()</strong>+ <div>Estimate the price of a render</div>+ </TOCItem> */}+ <TOCItem link="/docs/cloudrun/deployservice">+ <strong>deployService()</strong>+ <div>Create a new service in GCP Cloud Run</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/deleteservice">+ <strong>deleteService()</strong>+ <div>Delete a service in GCP Cloud Run</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/getserviceinfo">+ <strong>getServiceInfo()</strong>+ <div>Gets information about a service</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/getservices">+ <strong>getServices()</strong>+ <div>Lists available Remotion Cloud Run services</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/getcompositionsoncloudrun">+ <strong>getCompositionsOnCloudrun()</strong>+ <div>Gets list of compositions inside a Cloud Run service</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/deletesite">+ <strong>deleteSite()</strong>+ <div>Delete a bundle from S3</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/deploysite">+ <strong>deploySite()</strong>+ <div>Bundle and upload a site to S3</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/getawsclient">+ <strong>getAwsClient()</strong>+ <div>Access the AWS SDK directly</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/getregions">+ <strong>getRegions()</strong>+ <div>Get all available regions</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/getsites">+ <strong>getSites()</strong>+ <div>Get all available sites</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/downloadmedia">+ <strong>downloadMedia()</strong>+ <div>Download a render artifact from S3</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/getuserpolicy">+ <strong>getUserPolicy()</strong>+ <div>Get the policy JSON for your AWS user</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/getrolepolicy">+ <strong>getRolePolicy()</strong>+ <div>Get the policy JSON for your AWS role</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/getorcreatebucket">+ <strong>getOrCreateBucket()</strong>+ <div>Ensure a Remotion S3 bucket exists</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/getrenderprogress">+ <strong>getRenderProgress()</strong>+ <div>Query the progress of a render</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/presignurl">+ <strong>presignUrl()</strong>+ <div>Make a private file public to those with the link</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/rendermediaoncloudrun">+ <strong>renderMediaOnCloudrun()</strong>+ <div>Trigger a video or audio render</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/renderstilloncloudrun">+ <strong>renderStillOnCloudrun()</strong>+ <div>Trigger a still render</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/simulatepermissions">+ <strong>simulatePermissions()</strong>+ <div>Ensure permissions are correctly set up</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/speculateservicename">+ <strong>speculateServiceName()</strong>+ <div>Get the Cloud Run service name based on its configuration</div>+ </TOCItem>+ <TOCItem link="/docs/cloudrun/validatewebhooksignature">+ <strong>validateWebhookSignature()</strong>+ <div>Validate an incoming webhook request is authentic</div>+ </TOCItem>+ </Grid>+ </div>+ );+};diff --git a/packages/docs/docs/cloudrun/api.md b/packages/docs/docs/cloudrun/api.mdindex 32821ff1a1..6d43644cad 100644--- a/packages/docs/docs/cloudrun/api.md+++ b/packages/docs/docs/cloudrun/api.md@@ -1,12 +1,12 @@----image: /generated/articles-docs-lambda-api.png-title: "@remotion/lambda"-crumb: "Render videos without servers"+image: /generated/articles-docs-cloudrun-api.png+title: "@remotion/cloudrun"+crumb: "Render videos without servers on GCP"---import Tabs from '@theme/Tabs';import TabItem from '@theme/TabItem';-import {TableOfContents} from '../../components/TableOfContents/lambda';+import {TableOfContents} from '../../components/TableOfContents/cloudrun';<TabsdefaultValue="npm"@@ -19,7 +19,7 @@ values={[<TabItem value="npm">```bash-npm i @remotion/lambda+npm i @remotion/cloudrun```</TabItem>@@ -27,14 +27,14 @@ npm i @remotion/lambda<TabItem value="pnpm">```bash-pnpm i @remotion/lambda+pnpm i @remotion/cloudrun```</TabItem><TabItem value="yarn">```bash-yarn add @remotion/lambda+yarn add @remotion/cloudrun```</TabItem>@@ -47,7 +47,7 @@ Also update **all the other Remotion packages** to have the same version: `remotMake sure no package version number has a `^` character in front of it as it can lead to a version conflict.:::-**See the [setup guide](/docs/lambda/setup) for complete instructions on how to get started.**+**See the [setup guide](/docs/cloudrun/setup) for complete instructions on how to get started.**## APIs@@ -57,4 +57,4 @@ The following Node.JS are available:## CLI-See [here](/docs/lambda/cli) for a list of CLI commands.+See [here](/docs/cloudrun/cli) for a list of CLI commands.diff --git a/packages/docs/docs/cloudrun/cli.md b/packages/docs/docs/cloudrun/cli.mdindex 38403085ab..28c378caa1 100644--- a/packages/docs/docs/cloudrun/cli.md+++ b/packages/docs/docs/cloudrun/cli.md@@ -10,8 +10,10 @@ To use the Remotion Cloudrun CLI, you first need to [install it](/docs/cloudrun/## Commands-// TODO--## Global options--// TODO+- [sites](/docs/cloudrun/cli/sites)+- [functions](/docs/cloudrun/cli/functions)+- [render](/docs/cloudrun/cli/render)+- [still](/docs/cloudrun/cli/still)+- [compositions](/docs/cloudrun/cli/compositions)+- [policies](/docs/cloudrun/cli/policies)+- [quotas](/docs/cloudrun/cli/quotas)diff --git a/packages/docs/docs/cloudrun/cli/regions.md b/packages/docs/docs/cloudrun/cli/regions.mdnew file mode 100644index 0000000000..88c1f3f99e--- /dev/null+++ b/packages/docs/docs/cloudrun/cli/regions.md@@ -0,0 +1,24 @@+---+image: /generated/articles-docs-cloudrun-cli-regions.png+id: regions+sidebar_label: regions+title: "npx remotion cloudrun regions"+crumb: "Cloudrun CLI Reference"+---++Prints the GCP regions supported by the current version of Remotion Cloudrun. Useful for bash scripts.++```+npx remotion cloudrun regions+```++<details>+<summary>Show output+</summary>+<pre>+asia-east1 asia-east2 asia-northeast1 asia-northeast2 asia-northeast3 asia-south1 asia-south2 asia-southeast1 asia-southeast2 australia-southeast1 australia-southeast2 europe-central2 europe-north1 europe-southwest1 europe-west1 europe-west2 europe-west3 europe-west4 europe-west6 europe-west8 europe-west9 me-west1 northamerica-northeast1 northamerica-northeast2 southamerica-east1 southamerica-west1 us-central1 us-east1 us-east4 us-east5 us-south1 us-west1 us-west2 us-west3 us-west4</pre>+</details>++## See also++- [Region selection](/docs/cloudrun/region-selection)diff --git a/packages/docs/docs/cloudrun/cli/sites.md b/packages/docs/docs/cloudrun/cli/sites.mdnew file mode 100644index 0000000000..2feafed485--- /dev/null+++ b/packages/docs/docs/cloudrun/cli/sites.md@@ -0,0 +1,273 @@+---+image: /generated/articles-docs-cloudrun-cli-sites.png+id: sites+sidebar_label: sites+title: "npx remotion cloudrun sites"+slug: /cloudrun/cli/sites+crumb: "Cloud Run CLI Reference"+---++The `npx remotion cloudrun sites` command allows to create, view and delete Remotion projects in your Cloud Storage bucket.++- [`create`](#create)+- [`ls`](#ls)+- [`rm`](#rm)+- [`rmall`](#rmall)++## create++```+npx remotion cloudrun sites create src/index.ts+```++Bundle and upload a Remotion video to a Cloud Storage bucket.++The result will be a URL such as `https://storage.googleapis.com/remotioncloudrun-12345/sites/mySite123/index.html`.++:::note+If you make changes locally, you need to redeploy the site. Use [`--site-name`](#--site-name) to overwrite an existing site.+:::++You can use this "Serve URL" to render a video on Remotion Cloud Run using:++- The [`npx remotion cloudrun render media`](/docs/cloudrun/cli/render#media) and [`npx remotion cloudrun render still`](/docs/cloudrun/cli/render#still) commands+- Locally using the [`renderMedia()`](/docs/renderer/render-media) and [`renderStill()`](/docs/renderer/render-still) functions.+- Locally using the [`npx remotion render`](/docs/cli) and [`npx remotion still`](/docs/cli) commands++If you are rendering on Cloud Run, you can also pass the site Name (in this case `mySite123`) as an abbreviation.++<details>+<summary>+Example output+</summary>+<pre>+(1/3) [====================] Bundled video 3975ms<br/>+(2/3) [====================] Created bucket 457ms<br/>+(3/3) [====================] Uploaded to S3 25118ms<br/>+<br/>+Deployed to GCP Cloud Storage!<br/>+Serve URL: https://storage.googleapis.com/remotioncloudrun-12345/sites/mySite123/index.html<br/>+Site Name: mySite123<br/>+</pre>+</details>++### `--region`++The [GCP region](/docs/cloudrun/region-selection) to select. Both project and function should be in this region.++### `--site-name`++Uploads the project to a specific directory and returns a deterministic URL. If a site already existed under this name, it will be overwritten. Can only contain the following characters: `0-9`, `a-z`, `A-Z`, `-`, `!`, `_`, `.`, `*`, `'`, `(`, `)`++```+npx remotion cloudrun sites create src/index.ts --site-name=my-project+```++<details>+<summary>+Example output+</summary>+<pre>+(1/3) [====================] Bundled video 3975ms<br/>+(2/3) [====================] Created bucket 457ms<br/>+(3/3) [====================] Uploaded to S3 25118ms<br/>+<br/>+Deployed to GCP Cloud Storage!<br/>+Serve URL: https://storage.googleapis.com/remotioncloudrun-12345/sites/my-project/index.html<br/>+Site Name: my-project<br/>++</pre>+</details>++## ls++```+npx remotion cloudrun sites ls+```++Get a list of sites. The URL that is printed can be passed to the `render` command to render a video.++<details>+<summary>+Example output+</summary>+<pre>+Site Name Bucket Last updated<br/>+pr6fwglz05 remotioncloudrun-abcdefg 2021-12-02<br/>+https://storage.googleapis.com/remotioncloudrun-abcdefg/sites/pr6fwglz05/index.html<br/><br/>+testbed remotioncloudrun-abcdefg 2021-12-02 <br/>+https://storage.googleapis.com/remotioncloudrun-abcdefg/sites/testbed/index.html<br/>+</pre>+</details>++### `--quiet`, `-q`++Returns only a list of space-separated sites.++```+npx remotion cloudrun sites ls -q+```++<details>+<summary>+Example output+</summary>+<pre>+pr6fwglz05 testbed<br/>+</pre>+</details>++## rm++Removes a site (or multiple) from S3 by it's ID.++```bash+npx remotion cloudrun sites rm abcdef+npx remotion cloudrun sites rm abcdef my-project # multiple at once+```++<details>+<summary>+Example output+</summary>+<pre>Site abcdef in bucket remotionlambda-gc1w0xbfzl (14.7 MB): Delete? (Y/n): Y+<br/>Deleted sites/abcdef/052787b08233d85edebfc4ce4610944e.mp4+<br/>Deleted sites/abcdef/258.bundle.js+<br/>Deleted sites/abcdef/15.bundle.js+<br/>Deleted sites/abcdef/249.bundle.js.map+<br/>Deleted sites/abcdef/263.bundle.js+<br/>Deleted sites/abcdef/143.bundle.js+<br/>Deleted sites/abcdef/258.bundle.js.map+<br/>Deleted sites/abcdef/15.bundle.js.map+<br/>Deleted sites/abcdef/185.bundle.js.map+<br/>Deleted sites/abcdef/249.bundle.js+<br/>Deleted sites/abcdef/143.bundle.js.map+<br/>Deleted sites/abcdef/185.bundle.js+<br/>Deleted sites/abcdef/1f2d09019ff34eed846a5151b8561d5b.mp4+<br/>Deleted sites/abcdef/263.bundle.js.map+<br/>Deleted sites/abcdef/268.bundle.js+<br/>Deleted sites/abcdef/378.bundle.js.map+<br/>Deleted sites/abcdef/268.bundle.js.map+<br/>Deleted sites/abcdef/378.bundle.js+<br/>Deleted sites/abcdef/2b91c5234e41d3c36d4bf6df37876958.webm+<br/>Deleted sites/abcdef/450.bundle.js+<br/>Deleted sites/abcdef/46.bundle.js.map+<br/>Deleted sites/abcdef/46.bundle.js+<br/>Deleted sites/abcdef/450.bundle.js.map+<br/>Deleted sites/abcdef/534.bundle.js.map+<br/>Deleted sites/abcdef/569.bundle.js+<br/>Deleted sites/abcdef/3577958454aa99ad707b596f65151746.webm+<br/>Deleted sites/abcdef/534.bundle.js+<br/>Deleted sites/abcdef/575.bundle.js.map+<br/>Deleted sites/abcdef/575.bundle.js+<br/>Deleted sites/abcdef/569.bundle.js.map+<br/>Deleted sites/abcdef/801.bundle.js+<br/>Deleted sites/abcdef/7badbf53d3130d91b90c46181a2ecdc4.webm+<br/>Deleted sites/abcdef/801.bundle.js.map+<br/>Deleted sites/abcdef/873.bundle.js+<br/>Deleted sites/abcdef/98.bundle.js.map+<br/>Deleted sites/abcdef/bff822b868a2b87b31877f3606c9cc13.mp3+<br/>Deleted sites/abcdef/873.bundle.js.map+<br/>Deleted sites/abcdef/98.bundle.js+<br/>Deleted sites/abcdef/a2f36e3a48b4989e0da1fea9959fb35f.mp3+<br/>Deleted sites/abcdef/bundle.js+<br/>Deleted sites/abcdef/bundle.js.map+<br/>Deleted sites/abcdef/a7d87d9934059032eebb9c1536378a2a.webm+<br/>Deleted sites/abcdef/index.html+<br/>Deleted site abcdef and freed up 14.7 MB.+<br/>+</pre>+</details>++### `--region`++The [AWS region](/docs/cloudrun/region-selection) to select. Both project and function should be in this region.++### `--yes`, `-y`++Removes a site without asking for confirmation.++```+npx remotion cloudrun sites rm abcdef -y+```++### `--force-bucket-name` <AvailableFrom v="3.3.42" />++Specify a specific bucket name to be used. [This is not recommended](/docs/cloudrun/multiple-buckets), instead let Remotion discover the right bucket automatically.++## rmall++Remove all sites in the selected AWS region.++```bash+npx remotion cloudrun sites rmall+```++<details>+<summary>+Example output+</summary>+<pre>Site abcdef in bucket remotionlambda-gc1w0xbfzl (14.7 MB): Delete? (Y/n): Y+<br/>Deleted sites/abcdef/052787b08233d85edebfc4ce4610944e.mp4+<br/>Deleted sites/abcdef/258.bundle.js+<br/>Deleted sites/abcdef/15.bundle.js+<br/>Deleted sites/abcdef/249.bundle.js.map+<br/>Deleted sites/abcdef/263.bundle.js+<br/>Deleted sites/abcdef/143.bundle.js+<br/>Deleted sites/abcdef/258.bundle.js.map+<br/>Deleted sites/abcdef/15.bundle.js.map+<br/>Deleted sites/abcdef/185.bundle.js.map+<br/>Deleted sites/abcdef/249.bundle.js+<br/>Deleted sites/abcdef/143.bundle.js.map+<br/>Deleted sites/abcdef/185.bundle.js+<br/>Deleted sites/abcdef/1f2d09019ff34eed846a5151b8561d5b.mp4+<br/>Deleted sites/abcdef/263.bundle.js.map+<br/>Deleted sites/abcdef/268.bundle.js+<br/>Deleted sites/abcdef/378.bundle.js.map+<br/>Deleted sites/abcdef/268.bundle.js.map+<br/>Deleted sites/abcdef/378.bundle.js+<br/>Deleted sites/abcdef/2b91c5234e41d3c36d4bf6df37876958.webm+<br/>Deleted sites/abcdef/450.bundle.js+<br/>Deleted sites/abcdef/46.bundle.js.map+<br/>Deleted sites/abcdef/46.bundle.js+<br/>Deleted sites/abcdef/450.bundle.js.map+<br/>Deleted sites/abcdef/534.bundle.js.map+<br/>Deleted sites/abcdef/569.bundle.js+<br/>Deleted sites/abcdef/3577958454aa99ad707b596f65151746.webm+<br/>Deleted sites/abcdef/534.bundle.js+<br/>Deleted sites/abcdef/575.bundle.js.map+<br/>Deleted sites/abcdef/575.bundle.js+<br/>Deleted sites/abcdef/569.bundle.js.map+<br/>Deleted sites/abcdef/801.bundle.js+<br/>Deleted sites/abcdef/7badbf53d3130d91b90c46181a2ecdc4.webm+<br/>Deleted sites/abcdef/801.bundle.js.map+<br/>Deleted sites/abcdef/873.bundle.js+<br/>Deleted sites/abcdef/98.bundle.js.map+<br/>Deleted sites/abcdef/bff822b868a2b87b31877f3606c9cc13.mp3+<br/>Deleted sites/abcdef/873.bundle.js.map+<br/>Deleted sites/abcdef/98.bundle.js+<br/>Deleted sites/abcdef/a2f36e3a48b4989e0da1fea9959fb35f.mp3+<br/>Deleted sites/abcdef/bundle.js+<br/>Deleted sites/abcdef/bundle.js.map+<br/>Deleted sites/abcdef/a7d87d9934059032eebb9c1536378a2a.webm+<br/>Deleted sites/abcdef/index.html+<br/>Deleted site abcdef and freed up 14.7 MB.+<br/>+</pre>+</details>++### `--region`++The [AWS region](/docs/cloudrun/region-selection) to select. Both project and function should be in this region.++### `--yes`, `-y`++Removes all sites without asking for confirmation.++```+npx remotion cloudrun sites rmall -y+```++### `--force-bucket-name` <AvailableFrom v="3.3.42" />++Specify a specific bucket name to be used. [This is not recommended](/docs/cloudrun/multiple-buckets), instead let Remotion discover the right bucket automatically.diff --git a/packages/docs/docs/cloudrun/deployservice.md b/packages/docs/docs/cloudrun/deployservice.mdindex 048cdc1fc3..5b14982ec9 100644--- a/packages/docs/docs/cloudrun/deployservice.md+++ b/packages/docs/docs/cloudrun/deployservice.md@@ -1,14 +1,14 @@---image: /generated/articles-docs-cloudrun-deployservice.pngid: deployservice-title: deployservice()+title: deployService()slug: /cloudrun/deployservicecrumb: "Cloudrun API"----Creates an [AWS Lambda](https://aws.amazon.com/lambda/) function in your AWS account that will be able to render a video in the cloud.+Creates a [GCP Cloud Run](https://cloud.google.com/run) service in your GCP project that will be able to render a video in the cloud.-If a function with the same version, memory size and timeout already existed, it will be returned instead without a new one being created. This means this function can be treated as idempotent.+If a service with the same version, memory limit and cpu limit already existed, it will be returned instead without a new one being created. This means this service can be treated as idempotent.## Example@@ -16,69 +16,59 @@ If a function with the same version, memory size and timeout already existed, it// @module: esnext// @target: es2017-import { deployFunction } from "@remotion/lambda";+import { deployService } from "@remotion/cloudrun";-const { functionName } = await deployFunction({- region: "us-east-1",- timeoutInSeconds: 120,- memorySizeInMb: 2048,- createCloudWatchLogGroup: true,- diskSizeInMb: 2048,+const { shortName } = await deployService({+ remotionVersion: "3.3.82",+ memory: "2GiB",+ cpu: "2.0",+ projectID: "my-remotion-project",+ region: "us-east1",});-console.log(functionName);+console.log(shortName);```## ArgumentsAn object with the following properties:-### `region`--The [AWS region](/docs/lambda/region-selection) which you want to deploy the Lambda function too. It must be the same region that your Lambda Layer resides in.--### `timeoutInSeconds`--How long the Lambda function may run before it gets killed. Must be below 900 seconds.-We recommend a timeout of 120 seconds or lower - remember, Remotion Lambda is the fastest if you render with a high concurrency. If your video takes longer to render, the concurrency should be increased rather than the timeout.+### `remotionVersion`-### `memorySizeInMb`+The Remotion version of the service. Remotion is versioning the Cloud Run service and a render can only be triggered from a version of `@remotion/cloudrun` that is matching the one of the service.-How many megabytes of RAM the Lambda function should have. By default we recommend a value of 2048MB. You may increase or decrease it depending on how memory-consuming your video is. The minimum allowed number is `512`, the maximum allowed number is `10240`. Since the costs of Remotion Lambda is directly proportional to the amount of RAM, we recommend to keep this amount as low as possible.+### `memory`-### `createCloudWatchLogGroup`+The upper bound on the amount of RAM that the Cloud Run service can consume. By default we recommend a value of 2GiB. You may increase or decrease it depending on how memory-consuming your video is. The minimum allowed number is `512MiB`, the maximum allowed number is `32GiB`. Since the costs of Remotion Cloud Run is directly proportional to the amount of RAM, we recommend to keep this amount as low as possible.-_boolean_+### `cpu`-Whether logs should be saved into CloudWatch. We recommend enabling this option.+The maximum number of CPU cores that the Cloud Run service can use to process requests.-### `cloudWatchLogRetentionPeriodInDays`+### `projectID`-_optional_+The [project ID](https://cloud.google.com/resource-manager/docs/creating-managing-projects#:~:text=to%20be%20unique.-,Project%20ID,-%3A%20A%20globally%20unique) of the GCP Project that has been configured for Remotion Cloud Run.-Retention period for the CloudWatch Logs. Default: 14 days.--### `diskSizeInMb`--_optional_--Sets the amount of disk storage that is available in the Lambda function. Must be between 512MB and 10240MB (10GB). Default: 2048MB. Set this higher if you want to render longer videos. See also: [Disk size](/docs/lambda/disk-size)+### `region`-### `customRoleArn`+The [GCP region](/docs/cloudrun/region-selection) which you want to deploy the Cloud Run Service too.-_optional_+### `timeoutInSeconds`-Use a custom role for the function instead of the default (`arn:aws:iam::[aws-account-id]:role/remotion-lambda-role`)+How long the Cloud Run Service may run before it gets killed. Must be below 900 seconds.+We recommend a timeout of 120 seconds or lower - remember, Remotion Lambda is the fastest if you render with a high concurrency. If your video takes longer to render, the concurrency should be increased rather than the timeout.## Return valueAn object with the following values:-- `functionName` (_string_): The name of the function just created.-- `alreadyExisted`: (_boolean_): Whether the creation was skipped because the function already existed.+- `fullName` (_string_): The full name of the service just created, in the form `projects/remotion-6/locations/{region}/services/{serviceName}`.+- `shortName` (_string_): The name of the service just created, as it appears in the console.+- `uri` (_string_): The endpoint of the service just created.+- `alreadyExists`: (_boolean_): Whether the creation was skipped because the service already existed.## See also-- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/lambda/src/api/deploy-function.ts)-- [CLI equivalent: npx remotion lambda functions deploy](/docs/lambda/cli/functions#deploy)-- [deleteFunction()](/docs/lambda/deletefunction)-- [getFunctions()](/docs/lambda/getfunctions)+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/cloudrun/src/api/deploy-service.ts)+- [CLI equivalent: npx remotion cloudrun services deploy](/docs/cloudrun/cli/services#deploy)+- [deleteService()](/docs/cloudrun/deleteservice)+- [getServices()](/docs/cloudrun/getservices)diff --git a/packages/docs/docs/cloudrun/getServiceinfo.md b/packages/docs/docs/cloudrun/getServiceinfo.mdnew file mode 100644index 0000000000..505c465a5e--- /dev/null+++ b/packages/docs/docs/cloudrun/getServiceinfo.md@@ -0,0 +1,72 @@+---+image: /generated/articles-docs-cloudrun-getserviceinfo.png+id: getserviceinfo+title: getServiceInfo()+slug: /cloudrun/getserviceinfo+crumb: "Cloudrun API"+---++Gets information about a service given it's name and region.++To get a list of deployed services, use [`getServices()`](/docs/cloudrun/getservices).++To deploy a service, use [`deployService()`](/docs/lambda/deployservice).++## Example++```ts twoslash+// @module: esnext+// @target: es2017++import { getServiceInfo } from "@remotion/cloudrun";++const info = await getServiceInfo({+ region: "us-east1",+ serviceName: "remotion--3-3-82--mem512mi--cpu1-0",+});+console.log(info.serviceName); // remotion--3-3-82--mem512mi--cpu1-0+console.log(info.timeoutInSeconds); // 120+console.log(info.memoryLImit); // 1500+console.log(info.cpuLimit); // 2048+console.log(info.remotionVersion); // '2021-07-14'+```++## Arguments++An object containing the following properties:++### `region`++The [GCP region](/docs/cloudrun/region-selection) the service resides in.++### `serviceName`++The name of the service.++## Return value++If the service does not exist, an error is thrown by the GCP SDK.+If the service exists, promise resolving to an object with the following properties is returned:++### `memoryLImit`++The upper bound on the amount of RAM that the Cloud Run service can consume.++### `cpuLimit`++The maximum number of CPU cores that the Cloud Run service can use to process requests.++### `remotionVersion`++The Remotion version of the service. Remotion is versioning the Cloud Run service and a render can only be triggered from a version of `@remotion/cloudrun` that is matching the one of the service.++### `timeoutInSeconds`++The timeout that has been assigned to the Cloud Run service.++## See also++- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/cloudrun/src/api/get-service-info.ts)+- [`getServices()`](/docs/cloudrun/getservices)+- [`deployService()`](/docs/cloudrun/deployservice)+- [`deleteService()`](/docs/cloudrun/deleteservice)diff --git a/packages/docs/docs/cloudrun/getregions.md b/packages/docs/docs/cloudrun/getregions.mdnew file mode 100644index 0000000000..5d711749c2--- /dev/null+++ b/packages/docs/docs/cloudrun/getregions.md@@ -0,0 +1,30 @@+---+image: /generated/articles-docs-cloudrun-getregions.png+id: getregions+title: getRegions()+crumb: "Cloudrun API"+---++Gets an array of all supported GCP regions of this release of Cloudrun Lambda.++## Example++```tsx twoslash+// @module: esnext+// @target: es2017+import { getRegions } from "@remotion/cloudrun";++// ---cut---++const regions = getRegions();+// ["asia-east1", "us-east1"]+```++## Return value++An array of supported regions by this release of Remotion Lambda.++## See also++- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/cloudrun/src/api/get-regions.ts)+- [Region selection](/docs/cloudrun/region-selection)diff --git a/packages/docs/docs/cloudrun/region-selection.md b/packages/docs/docs/cloudrun/region-selection.mdindex df9b341cc7..84bf1472df 100644--- a/packages/docs/docs/cloudrun/region-selection.md+++ b/packages/docs/docs/cloudrun/region-selection.md@@ -18,8 +18,7 @@ The following GCP regions are available:<GcpRegionList />-// TODO: Link-You can call `getRegions()` or type `npx remotion cloudrun regions` to get this list programmatically.+You can call [`getRegions()`](/docs/cloudrun/getregions) or type [`npx remotion cloudrun regions`](/docs/cloudrun/cli/regions) to get this list programmatically.## Default region@@ -31,13 +30,7 @@ There are 3 ways of selection a region:- When using the Node.JS APIs, you have to pass the region explicitly to each function. Make sure your projects satisfy the Typescript types or follow the documentation.-- When using the CLI, you can set the region using the `REMOTION_GCP_REGION` environment variable. It's best to put it in a `.env` file so you don't forget it sometimes.--- You can also pass the `--region` flag to all CLI commands to override the region. The flag takes precedence over the environment variable.--:::info-The REMOTION_GCP_REGION environment variable and `--region` flag do not have an effect when using the Node.JS APIs. You need to pass a region explicitly.-:::+- You can pass the `--region` flag to all CLI commands to set the region.If you don't set a region, Remotion will use the default region.diff --git a/packages/docs/docs/lambda/api.md b/packages/docs/docs/lambda/api.mdindex 32821ff1a1..73560b14ad 100644--- a/packages/docs/docs/lambda/api.md+++ b/packages/docs/docs/lambda/api.md@@ -1,7 +1,7 @@---image: /generated/articles-docs-lambda-api.pngtitle: "@remotion/lambda"-crumb: "Render videos without servers"+crumb: "Render videos without servers on AWS"---import Tabs from '@theme/Tabs';diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex 139f306055..d6f200ff89 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -40,13 +40,13 @@ module.exports = {id: "cloudrun/cli",},items: [- "lambda/cli/sites",+ "cloudrun/cli/sites","lambda/cli/functions","lambda/cli/render","lambda/cli/still","lambda/cli/policies","lambda/cli/compositions",- "lambda/cli/regions",+ "cloudrun/cli/regions","lambda/cli/quotas",],},@@ -231,7 +231,10 @@ module.exports = {href: "/docs/cloudrun/cli",label: "CLI Reference",},+ "cloudrun/getserviceinfo","cloudrun/getservices",+ "cloudrun/getregions",+ "cloudrun/deployservice",],},{