π₯ Make videos programmatically with React
cpu limits added to deploy command
Matt McGillivray9282bc07c9c5
diff --git a/packages/gcp/readme.md b/packages/gcp/readme.mdindex a1da3457a1..82e6c8a35d 100644--- a/packages/gcp/readme.md+++ b/packages/gcp/readme.md@@ -148,12 +148,6 @@ To render media, send a POST request to the URL with the following body:## Using the CLI command, WIP-`pnpm exec remotion gcp render https://storage.googleapis.com/remotioncloudrun-n8x4pc7dz3/sites/axp52acnh2/index.html expert`--- π© Error when rendering color-interpolation composition, checking cloud run logs, it has run out of memory- - β Surface the cloud run logs back to CLI- - π© Update Cloud Run Deploy command to accept memory + CPU parameters- - π© Deploy new Cloud Run Service with larger limit, test it works- π© Work out progress bar for CLI<br><br><br><br>diff --git a/packages/gcp/src/api/deploy-cloud-run-revision.ts b/packages/gcp/src/api/deploy-cloud-run-revision.tsindex b57f6bc6bc..51468d9ad0 100644--- a/packages/gcp/src/api/deploy-cloud-run-revision.ts+++ b/packages/gcp/src/api/deploy-cloud-run-revision.ts@@ -1,12 +1,15 @@import {validateGcpRegion} from '../shared/validate-gcp-region';import {validateProjectID} from '../shared/validate-project-id';import {validateRemotionVersion} from '../shared/validate-remotion-version';+import {constructServiceTemplate} from './helpers/construct-service-deploy-request';import {getCloudRunClient} from './helpers/get-cloud-run-client';import type {IService} from './helpers/IService';export type DeployCloudRunRevisionInput = {remotionVersion: string;existingService: IService;+ memory: string;+ cpu: string;projectID: string;region: string;};@@ -27,27 +30,17 @@ export const deployCloudRunRevision = async (validateProjectID(options.projectID);validateRemotionVersion(options.remotionVersion);- // TODO: Add option for CPU and memory limits, and validate-const cloudRunClient = getCloudRunClient();// Construct requestconst request = {service: {name: options.existingService.name,- template: {- containers: [- {- image: `us-docker.pkg.dev/remotion-dev/cloud-run/render:${options.remotionVersion}`,- resources: {- limits: {- cpu: '1',- memory: '4Gi',- },- },- },- ],- },+ template: constructServiceTemplate({+ remotionVersion: options.remotionVersion,+ memory: options.memory,+ cpu: options.cpu,+ }),},};// Run requestdiff --git a/packages/gcp/src/api/deploy-new-cloud-run.ts b/packages/gcp/src/api/deploy-new-cloud-run.tsindex a8305521a8..2b572e2671 100644--- a/packages/gcp/src/api/deploy-new-cloud-run.ts+++ b/packages/gcp/src/api/deploy-new-cloud-run.ts@@ -1,8 +1,8 @@import {validateGcpRegion} from '../shared/validate-gcp-region';import {validateProjectID} from '../shared/validate-project-id';import {validateRemotionVersion} from '../shared/validate-remotion-version';-import {validateServiceMemory} from '../shared/validate-service-memory';import {validateServiceName} from '../shared/validate-service-name';+import {constructServiceTemplate} from './helpers/construct-service-deploy-request';import {getCloudRunClient} from './helpers/get-cloud-run-client';import type {IService} from './helpers/IService';@@ -10,6 +10,7 @@ export type DeployCloudRunInput = {remotionVersion: string;serviceName: string;memory: string;+ cpu: string;projectID: string;region: string;overwriteService: boolean;@@ -27,9 +28,9 @@ export type DeployCloudRunInput = {export const deployNewCloudRun = async (options: DeployCloudRunInput): Promise<IService> => {+ // ToDo: This needs to allow for defaults for use of the node API without CLIvalidateGcpRegion(options.region);validateServiceName(options.serviceName);- validateServiceMemory(options.memory);validateProjectID(options.projectID);validateRemotionVersion(options.remotionVersion);@@ -37,23 +38,15 @@ export const deployNewCloudRun = async (const cloudRunClient = getCloudRunClient();- // Construct requestconst request = {parent,service: {// service structure: https://googleapis.dev/nodejs/run/latest/google.cloud.run.v2.IService.html- template: {- containers: [- {- image: `us-docker.pkg.dev/remotion-dev/cloud-run/render:${options.remotionVersion}`,- resources: {- limits: {- memory: options.memory,- },- },- },- ],- },+ template: constructServiceTemplate({+ remotionVersion: options.remotionVersion,+ memory: options.memory,+ cpu: options.cpu,+ }),},serviceId: options.serviceName,};diff --git a/packages/gcp/src/api/helpers/construct-service-deploy-request.ts b/packages/gcp/src/api/helpers/construct-service-deploy-request.tsnew file mode 100644index 0000000000..16f5992c31--- /dev/null+++ b/packages/gcp/src/api/helpers/construct-service-deploy-request.ts@@ -0,0 +1,23 @@+export const constructServiceTemplate = ({+ remotionVersion,+ memory,+ cpu,+}: {+ remotionVersion: string;+ memory: string;+ cpu: string;+}) => {+ return {+ containers: [+ {+ image: `us-docker.pkg.dev/remotion-dev/cloud-run/render:${remotionVersion}`,+ resources: {+ limits: {+ memory,+ cpu,+ },+ },+ },+ ],+ };+};diff --git a/packages/gcp/src/cli/commands/cloud-run/deploy.ts b/packages/gcp/src/cli/commands/cloud-run/deploy.tsindex 96d52e5032..9b9d2efa10 100644--- a/packages/gcp/src/cli/commands/cloud-run/deploy.ts+++ b/packages/gcp/src/cli/commands/cloud-run/deploy.ts@@ -9,7 +9,6 @@ import {validateGcpRegion} from '../../../shared/validate-gcp-region';import {validateOverwrite} from '../../../shared/validate-overwrite';import {validateProjectID} from '../../../shared/validate-project-id';import {validateRemotionVersion} from '../../../shared/validate-remotion-version';-import {validateServiceMemory} from '../../../shared/validate-service-memory';import {validateServiceName} from '../../../shared/validate-service-name';import {parsedGcpCli} from '../../args';import {getGcpRegion} from '../../get-gcp-region';@@ -26,10 +25,10 @@ export const cloudRunDeploySubcommand = async () => {const allowUnauthenticated = parsedGcpCli['allow-unauthenticated'] ?? false;const overwriteService = parsedGcpCli['overwrite-service'] ?? false;const memory = parsedGcpCli.memory ?? '512Mi';+ const cpu = parsedGcpCli.cpu ?? '1.0';validateGcpRegion(region);validateServiceName(serviceName);- validateServiceMemory(memory);validateProjectID(projectID);validateRemotionVersion(remotionVersion);validateOverwrite(overwriteService);@@ -39,6 +38,8 @@ export const cloudRunDeploySubcommand = async () => {`Remotion Version = ${remotionVersion}Service Name = ${serviceName}+Service Memory Limit = ${memory}+Service CPU Limit = ${cpu}Project Name = ${projectID}Region = ${region}Allow Unauthenticated Access = ${allowUnauthenticated}@@ -67,6 +68,8 @@ Overwrite existing service = ${overwriteService}const deployRevisionResult = await deployCloudRunRevision({remotionVersion,existingService,+ memory,+ cpu,projectID,region,});@@ -105,6 +108,7 @@ GCP Console URL = https://console.cloud.google.com/run/detail/${region}/${servicremotionVersion,serviceName,memory,+ cpu,projectID,region,overwriteService,diff --git a/packages/gcp/src/shared/validate-service-memory.ts b/packages/gcp/src/shared/validate-service-memory.tsdeleted file mode 100644index c3ce6bcb67..0000000000--- a/packages/gcp/src/shared/validate-service-memory.ts+++ /dev/null@@ -1,18 +0,0 @@-export const validateServiceMemory = (serviceMemory: unknown) => {- if (typeof serviceMemory !== 'string') {- throw new TypeError(- `The 'memory' argument must be a string, but is ${JSON.stringify(- serviceMemory- )}`- );- }-- // Check if the service memory is a valid value for a GCP CLoud Run service- if (!serviceMemory.match(/^(128Mi|256Mi|512Mi|1Gi|2Gi|4Gi|8Gi|16Gi|32Gi)$/)) {- throw new Error(- 'The `serviceMemory` must match the RegExp `/^(128Mi|256Mi|512Mi|1Gi|2Gi|4Gi|8Gi|16Gi|32Gi)$/`. This means it may only be a valid GCP Cloud Run memory value. You passed: ' +- serviceMemory +- '. Check for invalid characters.'- );- }-};