Skip to content

πŸŽ₯ Make videos programmatically with React

CLI docs complete 🀞

Matt McGillivray10e05c43bdf3
diff --git a/packages/cloudrun/gcpInstaller/gcpInstaller.tar b/packages/cloudrun/gcpInstaller/gcpInstaller.tar
index 3a3b29c984..b53669090c 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 c266a5f2e2..d5c0e38cdc 100644
--- a/packages/cloudrun/package.json
+++ b/packages/cloudrun/package.json
@@ -1,6 +1,6 @@
{
"name": "@remotion/cloudrun",
- "version": "3.3.88",
+ "version": "3.3.92",
"description": "GCP Cloud Run alternative to lambda rendering",
"main": "dist/index.js",
"scripts": {
diff --git a/packages/cloudrun/src/admin/bundle-renderLogic.ts b/packages/cloudrun/src/admin/bundle-renderLogic.ts
index 64b82ad9c1..525ca480af 100644
--- a/packages/cloudrun/src/admin/bundle-renderLogic.ts
+++ b/packages/cloudrun/src/admin/bundle-renderLogic.ts
@@ -16,7 +16,7 @@ const bundleRenderLogic = async () => {
await BundlerInternals.esbuild.build({
platform: 'node',
- target: 'node14',
+ target: 'node16',
bundle: true,
outfile,
entryPoints: [template],
diff --git a/packages/cloudrun/src/api/cloud-run-allow-unauthenticated-access.ts b/packages/cloudrun/src/api/cloud-run-allow-unauthenticated-access.ts
index ea8fcdc3e6..08f666711d 100644
--- a/packages/cloudrun/src/api/cloud-run-allow-unauthenticated-access.ts
+++ b/packages/cloudrun/src/api/cloud-run-allow-unauthenticated-access.ts
@@ -12,8 +12,6 @@ export const allowUnauthenticatedAccess = async (
): Promise<Boolean> => {
const cloudRunClient = getCloudRunClient();
- // ToDo: once this is finalised, need to test out the testCall code - is it able to invoke the Cloud Run service using the stored json credentials, where as the got() call should fail.
-
const existingPolicy = await cloudRunClient.getIamPolicy({
resource: serviceName,
});
diff --git a/packages/cloudrun/src/api/get-service-info.ts b/packages/cloudrun/src/api/get-service-info.ts
index 85184578e5..35df75ae9a 100644
--- a/packages/cloudrun/src/api/get-service-info.ts
+++ b/packages/cloudrun/src/api/get-service-info.ts
@@ -9,6 +9,7 @@ export type ServiceInfo = {
cpuLimit: string;
remotionVersion: string | null;
uri: string;
+ region: string;
};
export type GetServiceInfoInput = {
@@ -51,5 +52,6 @@ export const getServiceInfo = async ({
.split('--')[0]
.replace(/-/g, '.') as string,
uri: service.uri as string,
+ region: service.name?.split('/')[3] as string,
};
};
diff --git a/packages/cloudrun/src/api/get-services.ts b/packages/cloudrun/src/api/get-services.ts
index a84f1b4781..4ff09e7b3e 100644
--- a/packages/cloudrun/src/api/get-services.ts
+++ b/packages/cloudrun/src/api/get-services.ts
@@ -1,3 +1,4 @@
+import {JWT} from 'google-auth-library';
import type {GcpRegion} from '../pricing/gcp-regions';
import {RENDER_SERVICE_PREFIX} from '../shared/constants';
import {SERVICE_VERSION_STRING} from '../shared/service-version-string';
@@ -6,10 +7,38 @@ import {getCloudRunClient} from './helpers/get-cloud-run-client';
import type {IService} from './helpers/IService';
export type GetServicesInput = {
- region: GcpRegion;
+ region: GcpRegion | 'all regions';
compatibleOnly: boolean;
};
+type v1Data = {
+ items: {
+ metadata: {
+ name: string;
+ uid: string;
+ labels: {
+ 'cloud.googleapis.com/location': string;
+ };
+ creationTimestamp: string;
+ };
+ status: {
+ url: string;
+ };
+ spec: {
+ template: {
+ spec: {
+ timeoutSeconds: number;
+ containers: {
+ resources: {
+ limits: {cpu: string; memory: string};
+ };
+ }[];
+ };
+ };
+ };
+ }[];
+};
+
/**
* @description Lists Remotion Cloud Run render services deployed to GCP Cloud Run.
* @see [Documentation](https://remotion.dev/docs/cloudrun/getservices)
@@ -21,6 +50,38 @@ export type GetServicesInput = {
export const getServices = async (
options: GetServicesInput
): Promise<ServiceInfo[]> => {
+ if (options.region === 'all regions') {
+ const cloudRunEndpoint = `https://run.googleapis.com/apis/serving.knative.dev/v1/namespaces/${process.env.REMOTION_GCP_PROJECT_ID}/services`;
+
+ const client = new JWT({
+ email: process.env.REMOTION_GCP_CLIENT_EMAIL,
+ key: process.env.REMOTION_GCP_PRIVATE_KEY,
+ scopes: ['https://www.googleapis.com/auth/cloud-platform'],
+ });
+
+ const res = await client.request({url: cloudRunEndpoint});
+
+ const data = res.data as v1Data;
+
+ return data.items.map((service): ServiceInfo => {
+ return {
+ serviceName: service.metadata.name as string,
+ timeoutInSeconds: service.spec.template.spec.timeoutSeconds as number,
+ memoryLimit: service.spec.template.spec.containers?.[0].resources
+ ?.limits?.memory as string,
+ cpuLimit: service.spec.template.spec.containers?.[0].resources?.limits
+ ?.cpu as string,
+ remotionVersion: service.metadata.name
+ .split('--')[1]
+ .replace(/-/g, '.') as string,
+ uri: service.status.url as string,
+ region: service.metadata.labels[
+ 'cloud.googleapis.com/location'
+ ] as string,
+ };
+ });
+ }
+
const cloudRunClient = getCloudRunClient();
const parent = `projects/${process.env.REMOTION_GCP_PROJECT_ID}/locations/${options.region}`;
@@ -58,6 +119,7 @@ export const getServices = async (
.split('--')[0]
.replace(/-/g, '.') as string,
uri: service.uri as string,
+ region: service.name?.split('/')[3] as string,
};
});
};
diff --git a/packages/cloudrun/src/cli/commands/services/index.ts b/packages/cloudrun/src/cli/commands/services/index.ts
index 6c4e3dd44d..954891131c 100644
--- a/packages/cloudrun/src/cli/commands/services/index.ts
+++ b/packages/cloudrun/src/cli/commands/services/index.ts
@@ -10,7 +10,7 @@ import {servicesRmallCommand, SERVICES_RMALL_SUBCOMMAND} from './rmall';
export const SERVICES_COMMAND = 'services';
-export const displaySiteInfo = (service: ServiceInfo) => {
+export const displayServiceInfo = (service: ServiceInfo) => {
const LEFT_COL = 16;
return [
'Service name: '.padEnd(LEFT_COL, ' ') + ' ' + service.serviceName,
@@ -18,6 +18,7 @@ export const displaySiteInfo = (service: ServiceInfo) => {
'CPU Limit: '.padEnd(LEFT_COL, ' ') + ' ' + service.cpuLimit,
'Memory Limit: '.padEnd(LEFT_COL, ' ') + ' ' + service.memoryLimit,
'Timeout: '.padEnd(LEFT_COL, ' ') + ' ' + service.timeoutInSeconds + 'sec',
+ 'Region: '.padEnd(LEFT_COL, ' ') + ' ' + service.region,
].join('\n');
};
diff --git a/packages/cloudrun/src/cli/commands/services/ls.ts b/packages/cloudrun/src/cli/commands/services/ls.ts
index a6ede35186..d11cc6afee 100644
--- a/packages/cloudrun/src/cli/commands/services/ls.ts
+++ b/packages/cloudrun/src/cli/commands/services/ls.ts
@@ -1,22 +1,21 @@
import {CliInternals} from '@remotion/cli';
+import {displayServiceInfo} from '.';
import {getServices} from '../../../api/get-services';
+import {parsedCloudrunCli} from '../../args';
import {getGcpRegion} from '../../get-gcp-region';
-
-const NAME_COLS = 70;
-const RESOURCE_LIMIT_COLS = 15;
-const DISK_COLS = 15;
-const TIMEOUT_COLS = 15;
-const VERSION_COLS = 15;
+import {Log} from '../../log';
export const SERVICES_LS_SUBCOMMAND = 'ls';
export const servicesLsCommand = async () => {
- const region = getGcpRegion();
+ const allRegions = parsedCloudrunCli['all-regions'];
+
+ const region = allRegions ? 'all regions' : getGcpRegion();
const fetchingOutput = CliInternals.createOverwriteableCliOutput({
quiet: CliInternals.quietFlagProvided(),
cancelSignal: null,
});
- fetchingOutput.update('Getting services...');
+ fetchingOutput.update(`Getting services in ${region}...`);
const services = await getServices({
region,
@@ -25,44 +24,22 @@ export const servicesLsCommand = async () => {
if (CliInternals.quietFlagProvided()) {
if (services.length === 0) {
- CliInternals.Log.info('()');
+ Log.info('()');
return;
}
- CliInternals.Log.info(services.map((f) => f.serviceName).join(' '));
+ Log.info(services.map((f) => f.serviceName).join(' '));
return;
}
fetchingOutput.update('Getting service info...');
const pluralized = services.length === 1 ? 'service' : 'services';
- fetchingOutput.update(
- `${services.length} ${pluralized} in the ${region} region`
- );
- CliInternals.Log.info();
- CliInternals.Log.info(
- CliInternals.chalk.gray(
- [
- 'Name'.padEnd(NAME_COLS, ' '),
- 'Version'.padEnd(VERSION_COLS, ' '),
- 'CPU Limit'.padEnd(RESOURCE_LIMIT_COLS, ' '),
- 'Memory Limit'.padEnd(RESOURCE_LIMIT_COLS, ' '),
- 'Timeout (sec)'.padEnd(TIMEOUT_COLS, ' '),
- ].join('')
- )
- );
+ fetchingOutput.update(`${services.length} ${pluralized} in ${region}`);
+ Log.info();
- for (const datapoint of services) {
- CliInternals.Log.info(
- [
- datapoint.serviceName.padEnd(NAME_COLS, ' '),
- datapoint.remotionVersion
- ? datapoint.remotionVersion.padEnd(VERSION_COLS, ' ')
- : 'Error'.padEnd(VERSION_COLS, ' '),
- String(datapoint.cpuLimit).padEnd(DISK_COLS, ' '),
- String(datapoint.memoryLimit).padEnd(RESOURCE_LIMIT_COLS, ' '),
- String(datapoint.timeoutInSeconds).padEnd(TIMEOUT_COLS, ' '),
- ].join('')
- );
+ for (const service of services) {
+ Log.info();
+ Log.info(displayServiceInfo(service));
}
};
diff --git a/packages/cloudrun/src/cli/commands/services/rm.ts b/packages/cloudrun/src/cli/commands/services/rm.ts
index 3c29dfe048..b1224adc32 100644
--- a/packages/cloudrun/src/cli/commands/services/rm.ts
+++ b/packages/cloudrun/src/cli/commands/services/rm.ts
@@ -6,7 +6,7 @@ import {getGcpRegion} from '../../get-gcp-region';
import {confirmCli} from '../../helpers/confirm';
import {quit} from '../../helpers/quit';
import {Log} from '../../log';
-import {displaySiteInfo, SERVICES_COMMAND} from './index';
+import {displayServiceInfo, SERVICES_COMMAND} from './index';
import {SERVICES_LS_SUBCOMMAND} from './ls';
export const SERVICES_RM_SUBCOMMAND = 'rm';
@@ -41,7 +41,7 @@ export const servicesRmCommand = async (args: string[]) => {
serviceName,
});
- infoOutput.update(displaySiteInfo(info));
+ infoOutput.update(displayServiceInfo(info));
Log.info();
const confirmDelete = await confirmCli({
diff --git a/packages/cloudrun/src/cli/commands/services/rmall.ts b/packages/cloudrun/src/cli/commands/services/rmall.ts
index b3a7aeec5a..8578f05d0a 100644
--- a/packages/cloudrun/src/cli/commands/services/rmall.ts
+++ b/packages/cloudrun/src/cli/commands/services/rmall.ts
@@ -1,34 +1,37 @@
import {CliInternals} from '@remotion/cli';
-import {displaySiteInfo} from '.';
import {deleteService} from '../../../api/delete-service';
-import {getServiceInfo} from '../../../api/get-service-info';
import {getServices} from '../../../api/get-services';
+import {parsedCloudrunCli} from '../../args';
import {getGcpRegion} from '../../get-gcp-region';
import {confirmCli} from '../../helpers/confirm';
import {Log} from '../../log';
+import {displayServiceInfo} from './index';
export const SERVICES_RMALL_SUBCOMMAND = 'rmall';
export const servicesRmallCommand = async () => {
- const region = getGcpRegion();
+ const allRegions = parsedCloudrunCli['all-regions'];
+
+ const region = allRegions ? 'all regions' : getGcpRegion();
+
+ const fetchingOutput = CliInternals.createOverwriteableCliOutput({
+ quiet: CliInternals.quietFlagProvided(),
+ cancelSignal: null,
+ });
+ fetchingOutput.update(`Getting services in ${region}...`);
+
const services = await getServices({
region,
compatibleOnly: false,
});
- for (const serv of services) {
- const infoOutput = CliInternals.createOverwriteableCliOutput({
- quiet: CliInternals.quietFlagProvided(),
- cancelSignal: null,
- });
- infoOutput.update('Getting service info...');
- const info = await getServiceInfo({
- region,
- serviceName: serv.serviceName,
- });
-
- infoOutput.update(displaySiteInfo(info));
+ const pluralized = services.length === 1 ? 'service' : 'services';
+ fetchingOutput.update(`${services.length} ${pluralized} in ${region}`);
+ Log.info();
+ Log.info();
+ for (const serv of services) {
+ Log.info(displayServiceInfo(serv));
Log.info();
const confirmDelete = await confirmCli({
@@ -37,7 +40,8 @@ export const servicesRmallCommand = async () => {
});
if (!confirmDelete) {
- Log.info(`Skipping service - ${info.serviceName}.`);
+ Log.info(`Skipping service - ${serv.serviceName}.`);
+ Log.info();
continue;
}
diff --git a/packages/docs/docs/cloudrun/cli/render.md b/packages/docs/docs/cloudrun/cli/render.md
index 7a017e1716..cd079ee67a 100644
--- a/packages/docs/docs/cloudrun/cli/render.md
+++ b/packages/docs/docs/cloudrun/cli/render.md
@@ -62,6 +62,10 @@ One of:
- `"public"` (_default_): The rendered media is publicly accessible under the Cloud Storage URL.
- `"private"`: The rendered media is not publicly available, but is available within the GCP project to those with the correct permissions.
+### `output-bucket`
+
+The bucket to place the rendered media/still in. The resulting Google Cloud Storage URL will be in the format `gs://{bucket-name}/renders/{render-id}/{file-name}`
+
### `--jpeg-quality`
[Value between 0 and 100 for JPEG rendering quality](/docs/config#setjpegquality). Doesn't work when PNG frames are rendered.
@@ -82,9 +86,17 @@ Specify a location for a dotenv file. Default `.env`. This is not for invoking t
The file name of the media output as stored in the Cloud Storage bucket. By default, it is `out` plus the appropriate file extension, for example: `out.mp4`. Must match `/([0-9a-zA-Z-!_.*'()/]+)/g`.
+### `--cloud-run-url`
+
+Specify the url of the service which should be used to perform the render. You must set either `cloud-run-url` _or_ `service-name`, but not both
+
### `--service-name`
-Specify the name of the service which should be used to perform the render.
+Specify the name of the service which should be used to perform the render. This is used in conjunction with the region to determine the service endpoint, as the same service name can exist across multiple regions. You must set either `cloud-run-url` _or_ `service-name`, but not both
+
+### `--unauthenticated-request`
+
+When this flag is set, the endpoint will be called without making use of credentials in the .env file. This requires the service to allow unauthenticated invocations. This can be set with the [--allow-unauthenticated](/docs/cloudrun/cli/services#--allow-unauthenticated) flag through the CLI, or through the [allowUnauthenticatedAccess](/docs/cloudrun/allowunauthenticatedaccess) method in the Node API.
## Media Rendering Specific Flags
diff --git a/packages/docs/docs/cloudrun/cli/services.md b/packages/docs/docs/cloudrun/cli/services.md
index 5b8ab1910b..c97c7a59c6 100644
--- a/packages/docs/docs/cloudrun/cli/services.md
+++ b/packages/docs/docs/cloudrun/cli/services.md
@@ -54,6 +54,10 @@ Deploying Cloud Run Service...
</pre>
</details>
+### `--region`
+
+The [GCP region](/docs/cloudrun/region-selection) to select. The site that the service will be accessing should also be in this same region to minimise latency.
+
### `--memoryLimit`
The upper bound on the amount of RAM that the Cloud Run service can consume. Default: 512 MB.
@@ -91,13 +95,58 @@ Lists the services that you have deployed to GCP in the [selected region](/docs/
Example output
</summary>
<pre>
-3 services in the us-east1 region<br/>
-Name Version CPU Limit Memory Limit Timeout (sec) <br/>
-remotion--3-3-82--mem512mi--cpu1-0--t-800 3.3.82 1.0 512Mi 800 <br/>
-remotion--3-3-82--mem512mi--cpu1-0--t-500 3.3.82 1.0 512Mi 500 <br/>
-remotion--3-3-82--mem1gi--cpu1-0--t-300 3.3.82 1.0 1Gi 300 <br/>
-<br/>
+2 services in us-east1<br/><br/>
+Service name: remotion--3-3-92--mem512mi--cpu2--t-1200<br/>
+Version: 3.3.92<br/>
+CPU Limit: 2<br/>
+Memory Limit: 512Mi<br/>
+Timeout: 1200sec<br/>
+Region: us-east1<br/><br/>
+Service name: remotion--3-3-82--mem512mi--cpu1-0--t-800<br/>
+Version: 3.3.82<br/>
+CPU Limit: 1.0<br/>
+Memory Limit: 512Mi<br/>
+Timeout: 800sec<br/>
+Region: us-east1<br/>
+</pre>
+</details>
+
+### `--region`
+
+The [GCP region](/docs/cloudrun/region-selection) to list services from.
+
+### `--all-regions`,
+
+Ignores region, returning services across all regions for the project.
+
+```
+npx remotion cloudrun services ls --all-regions
+```
+<details>
+<summary>
+Example output
+</summary>
+<pre>
+3 services in all regions<br/><br/>
+Service name: remotion--3-3-82--mem512mi--cpu1-0--t-800<br/>
+Version: 3.3.82<br/>
+CPU Limit: 1.0<br/>
+Memory Limit: 512Mi<br/>
+Timeout: 800sec<br/>
+Region: us-central1<br/><br/>
+Service name: remotion--3-3-92--mem512mi--cpu2--t-1200<br/>
+Version: 3.3.92<br/>
+CPU Limit: 2<br/>
+Memory Limit: 512Mi<br/>
+Timeout: 1200sec<br/>
+Region: us-east1<br/><br/>
+Service name: remotion--3-3-82--mem512mi--cpu1-0--t-800<br/>
+Version: 3.3.82<br/>
+CPU Limit: 1.0<br/>
+Memory Limit: 512Mi<br/>
+Timeout: 800sec<br/>
+Region: us-east1<br/>
</pre>
</details>
@@ -124,6 +173,7 @@ Version: 3.3.82<br/>
CPU Limit: 1.0<br/>
Memory Limit: 2Gi<br/>
Timeout: 300sec<br/>
+Region: us-east1<br/>
Delete? (Y/n): Y<br/>
Deleted!
<br/>
@@ -135,6 +185,10 @@ Deleted!
The [GCP region](/docs/cloudrun/region-selection) to select.
+:::note
+The `rm` command does not support the --all-regions flag, as it is possible to have the same service name in multiple regions. This makes it difficult to remove multiple service names from multiple regions.
+:::
+
### `--yes`, `-y`
Skips confirmation.
@@ -145,37 +199,77 @@ Skips confirmation.
npx remotion cloudrun services rmall
```
-Removes all services in a region from your GCP project.
+Removes all services from your GCP project for a certain region (or all regions if the --all-regions flag is passed).
<details>
<summary>
Example output
</summary>
<pre>
-<br/>
-Service name: remotion--3-3-82--mem2gi--cpu1-0--t-800<br/>
-Version: 3.3.82<br/>
-CPU Limit: 1.0<br/>
-Memory Limit: 2Gi<br/>
-Timeout: 300sec<br/>
-Delete? (Y/n): Y<br/>
-Deleted!
-<br/>
-Service name: remotion--3-3-82--mem4gi--cpu2-0--t-1200<br/>
+2 services in us-east1<br/><br/>
+Service name: remotion--3-3-92--mem512mi--cpu2--t-1200<br/>
+Version: 3.3.92<br/>
+CPU Limit: 2<br/>
+Memory Limit: 512Mi<br/>
+Timeout: 1200sec<br/>
+Region: us-east1<br/><br/>
+Delete? (Y/n) n<br/>
+Skipping service - remotion--3-3-92--mem512mi--cpu2--t-1200.<br/><br/>
+Service name: remotion--3-3-82--mem512mi--cpu1-0--t-800<br/>
Version: 3.3.82<br/>
CPU Limit: 1.0<br/>
-Memory Limit: 2Gi<br/>
-Timeout: 300sec<br/>
-Delete? (Y/n): Y<br/>
-Deleted!
-<br/>
-
+Memory Limit: 512Mi<br/>
+Timeout: 800sec<br/>
+Region: us-east1<br/><br/>
+Delete? (Y/n) n<br/>
+Skipping service - remotion--3-3-82--mem512mi--cpu1-0--t-800.<br/>
</pre>
</details>
### `--region`
-The [GCP region](/docs/cloudrun/region-selection) to select.
+The [GCP region](/docs/cloudrun/region-selection) to remove services from.
+
+### `--all-regions`,
+
+Ignores region, removing services across all regions for the project.
+
+```
+npx remotion cloudrun services rmall --all-regions
+```
+
+<details>
+<summary>
+Example output
+</summary>
+<pre>
+3 services in all regions<br/><br/>
+Service name: remotion--3-3-82--mem512mi--cpu1-0--t-800<br/>
+Version: 3.3.82<br/>
+CPU Limit: 1.0<br/>
+Memory Limit: 512Mi<br/>
+Timeout: 800sec<br/>
+Region: us-central1<br/><br/>
+Delete? (Y/n) n<br/>
+Skipping service - remotion--3-3-82--mem512mi--cpu1-0--t-800.<br/><br/>
+Service name: remotion--3-3-92--mem512mi--cpu2--t-1200<br/>
+Version: 3.3.92<br/>
+CPU Limit: 2<br/>
+Memory Limit: 512Mi<br/>
+Timeout: 1200sec<br/>
+Region: us-east1<br/><br/>
+Delete? (Y/n) n<br/>
+Skipping service - remotion--3-3-92--mem512mi--cpu2--t-1200.<br/><br/>
+Service name: remotion--3-3-82--mem512mi--cpu1-0--t-800<br/>
+Version: 3.3.82<br/>
+CPU Limit: 1.0<br/>
+Memory Limit: 512Mi<br/>
+Timeout: 800sec<br/>
+Region: us-east1<br/><br/>
+Delete? (Y/n) n<br/>
+Skipping service - remotion--3-3-82--mem512mi--cpu1-0--t-800.<br/>
+</pre>
+</details>
### `--yes`, `-y`