Skip to content

🎥 Make videos programmatically with React

add internalDeployService for cloudrun

Matt McGillivray632fb3f50645
diff --git a/packages/cloudrun/src/api/deploy-service.ts b/packages/cloudrun/src/api/deploy-service.ts
index 1c7a63c4bd..e98b3cda9f 100644
--- a/packages/cloudrun/src/api/deploy-service.ts
+++ b/packages/cloudrun/src/api/deploy-service.ts
@@ -12,6 +12,16 @@ import {checkIfServiceExists} from './check-if-service-exists';
import {constructServiceTemplate} from './helpers/construct-service-deploy-request';
import {getCloudRunClient} from './helpers/get-cloud-run-client';
+type InternalDeployServiceInput = {
+ performImageVersionValidation: boolean;
+ memoryLimit: string;
+ cpuLimit: string;
+ timeoutSeconds: number;
+ minInstances: number;
+ maxInstances: number;
+ projectID: string;
+ region: string;
+};
export type DeployServiceInput = {
performImageVersionValidation?: boolean;
memoryLimit?: string;
@@ -39,33 +49,13 @@ const deployServiceRaw = async ({
maxInstances,
projectID,
region,
-}: DeployServiceInput): Promise<DeployServiceOutput> => {
+}: InternalDeployServiceInput): Promise<DeployServiceOutput> => {
validateGcpRegion(region);
validateProjectID(projectID);
if (performImageVersionValidation) {
validateImageRemotionVersion();
}
- if (!memoryLimit) {
- memoryLimit = '2Gi';
- }
-
- if (!cpuLimit) {
- cpuLimit = '1.0';
- }
-
- if (!timeoutSeconds) {
- timeoutSeconds = DEFAULT_TIMEOUT;
- }
-
- if (!minInstances) {
- minInstances = DEFAULT_MIN_INSTANCES;
- }
-
- if (!maxInstances) {
- maxInstances = DEFAULT_MAX_INSTANCES;
- }
-
const parent = `projects/${projectID}/locations/${region}`;
const cloudRunClient = getCloudRunClient();
@@ -120,6 +110,9 @@ const deployServiceRaw = async ({
};
};
+export const internalDeployService =
+ PureJSAPIs.wrapWithErrorHandling(deployServiceRaw);
+
/**
* @description Creates a Cloud Run service in your project that will be able to render a video in GCP.
* @link https://remotion.dev/docs/cloudrun/deployservice
@@ -131,4 +124,25 @@ const deployServiceRaw = async ({
* @param params.region GCP region to deploy the Cloud Run service to.
* @returns {Promise<DeployServiceOutput>} See documentation for detailed structure
*/
-export const deployService = PureJSAPIs.wrapWithErrorHandling(deployServiceRaw);
+
+export const deployService = ({
+ performImageVersionValidation = true,
+ memoryLimit,
+ cpuLimit,
+ timeoutSeconds,
+ minInstances,
+ maxInstances,
+ projectID,
+ region,
+}: DeployServiceInput): Promise<DeployServiceOutput> => {
+ return internalDeployService({
+ performImageVersionValidation,
+ memoryLimit: memoryLimit ?? '2Gi',
+ cpuLimit: cpuLimit ?? '1.0',
+ timeoutSeconds: timeoutSeconds ?? DEFAULT_TIMEOUT,
+ minInstances: minInstances ?? DEFAULT_MIN_INSTANCES,
+ maxInstances: maxInstances ?? DEFAULT_MAX_INSTANCES,
+ projectID,
+ region,
+ });
+};
diff --git a/packages/cloudrun/src/cli/commands/services/deploy.ts b/packages/cloudrun/src/cli/commands/services/deploy.ts
index 6bc89fbd56..41abbf2fe5 100644
--- a/packages/cloudrun/src/cli/commands/services/deploy.ts
+++ b/packages/cloudrun/src/cli/commands/services/deploy.ts
@@ -1,7 +1,7 @@
import {CliInternals} from '@remotion/cli';
import {VERSION} from 'remotion/version';
import {displayServiceInfo, LEFT_COL} from '.';
-import {deployService} from '../../../api/deploy-service';
+import {internalDeployService} from '../../../api/deploy-service';
import {
DEFAULT_MAX_INSTANCES,
DEFAULT_MIN_INSTANCES,
@@ -68,11 +68,13 @@ ${[
}
try {
- const deployResult = await deployService({
+ const deployResult = await internalDeployService({
performImageVersionValidation: false, // this is already performed above
- memoryLimit,
- cpuLimit,
- timeoutSeconds,
+ memoryLimit: memoryLimit ?? '2Gi',
+ cpuLimit: cpuLimit ?? '1.0',
+ timeoutSeconds: timeoutSeconds ?? DEFAULT_TIMEOUT,
+ minInstances: Number(minInstances) ?? DEFAULT_MIN_INSTANCES,
+ maxInstances: Number(maxInstances) ?? DEFAULT_MAX_INSTANCES,
projectID,
region,
});