From 9f08902a2d0b1ac32b83c4371d2f5b2dc79d0c90 Mon Sep 17 00:00:00 2001 From: branberry Date: Thu, 29 Feb 2024 09:44:46 -0600 Subject: [PATCH] [DOP-4334]: Add new build commands --- .../lib/constructs/api/webhook-api-construct.ts | 12 ++++++++++++ cdk-infra/lib/constructs/worker/worker-construct.ts | 3 ++- package.json | 4 +++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cdk-infra/lib/constructs/api/webhook-api-construct.ts b/cdk-infra/lib/constructs/api/webhook-api-construct.ts index ed8dbab16..c27ef7305 100644 --- a/cdk-infra/lib/constructs/api/webhook-api-construct.ts +++ b/cdk-infra/lib/constructs/api/webhook-api-construct.ts @@ -10,6 +10,8 @@ import { getFeatureName } from '../../../utils/env'; const HANDLERS_PATH = path.join(__dirname, '/../../../../api/controllers/v2'); +const memorySize = 1024; + const bundling: BundlingOptions = { sourceMap: true, minify: true, @@ -46,6 +48,7 @@ export class WebhookApiConstruct extends Construct { environment, bundling, timeout, + memorySize, }); const slackDisplayRepoLambda = new NodejsFunction(this, 'slackDisplayRepoLambda', { @@ -55,6 +58,7 @@ export class WebhookApiConstruct extends Construct { environment, bundling, timeout, + memorySize, }); const dochubTriggerUpsertLambda = new NodejsFunction(this, 'dochubTriggerUpsertLambda', { @@ -63,6 +67,7 @@ export class WebhookApiConstruct extends Construct { handler: 'UpsertEdgeDictionaryItem', environment, timeout, + memorySize, }); const githubTriggerLambda = new NodejsFunction(this, 'githubTriggerLambda', { @@ -72,6 +77,7 @@ export class WebhookApiConstruct extends Construct { bundling, environment, timeout, + memorySize, }); const githubDeleteArtifactsLambda = new NodejsFunction(this, 'githubDeleteArtifactsLambda', { @@ -81,6 +87,7 @@ export class WebhookApiConstruct extends Construct { bundling, environment, timeout, + memorySize, }); const triggerLocalBuildLambda = new NodejsFunction(this, 'triggerLocalBuildLambda', { @@ -90,6 +97,7 @@ export class WebhookApiConstruct extends Construct { environment, bundling, timeout, + memorySize, }); const handleJobsLambda = new NodejsFunction(this, 'handleJobsLambda', { @@ -99,6 +107,7 @@ export class WebhookApiConstruct extends Construct { environment, bundling, timeout, + memorySize, }); const snootyBuildCompleteLambda = new NodejsFunction(this, 'snootyBuildCompleteLambda', { @@ -108,6 +117,7 @@ export class WebhookApiConstruct extends Construct { environment, bundling, timeout, + memorySize, }); const testDeployLambda = new NodejsFunction(this, 'testDeployLambda', { entry: `${HANDLERS_PATH}/test-deploy.ts`, @@ -116,6 +126,7 @@ export class WebhookApiConstruct extends Construct { environment, bundling, timeout, + memorySize, }); // generic handler for the root endpoint @@ -124,6 +135,7 @@ export class WebhookApiConstruct extends Construct { runtime, handler: 'RootEndpointLambda', timeout, + memorySize, }); const apiName = `webhookHandlers-${getFeatureName()}`; diff --git a/cdk-infra/lib/constructs/worker/worker-construct.ts b/cdk-infra/lib/constructs/worker/worker-construct.ts index 236bd55b6..956cb2adc 100644 --- a/cdk-infra/lib/constructs/worker/worker-construct.ts +++ b/cdk-infra/lib/constructs/worker/worker-construct.ts @@ -13,6 +13,7 @@ import { IQueue } from 'aws-cdk-lib/aws-sqs'; import { Construct } from 'constructs'; import path from 'path'; import { getEnv } from '../../../utils/env'; +import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; interface WorkerConstructProps { dockerEnvironment: Record; @@ -69,9 +70,9 @@ export class WorkerConstruct extends Construct { NPM_BASE_64_AUTH: dockerEnvironment.NPM_BASE_64_AUTH, NPM_EMAIL: dockerEnvironment.NPM_EMAIL, }, - cacheFrom: [{ type: 'gha' }], cacheTo: { type: 'gha', params: { mode: 'max' } }, + platform: Platform.LINUX_AMD64, }; const taskDefLogGroup = new LogGroup(this, 'workerLogGroup'); diff --git a/package.json b/package.json index 9043be8ef..663754b7c 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,9 @@ "clean": "node maintain.js", "build": "tsc", "build:esbuild:cacheUpdater": "esbuild src/cache-updater/index.ts --bundle --platform=node --outdir=./dist/ --allow-overwrite --sourcemap", - "build:esbuild": "esbuild src/onDemandApp.ts --bundle --platform=node --outdir=./ --allow-overwrite --sourcemap", + "build:esbuild": "npm run build:esbuild:enhanced && npm run build:esbuild:onDemand", + "build:esbuild:onDemand": "esbuild src/onDemandApp.ts --bundle --platform=node --outdir=./ --allow-overwrite --sourcemap", + "build:esbuild:enhanced": "esbuild src/enhanced/enhancedApp.ts --bundle --platform=node --outdir=./enhanced --allow-overwrite --sourcemap", "format": "npm run prettier -- --check", "format:fix": "npm run prettier -- --write", "lint": "eslint --ext .ts .",