Skip to content

fix: #111 Prevent initializing Docker in CDK #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions src/frameworks/cdkFramework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,14 @@ export class CdkFramework implements IFramework {
// });
global.lambdas.push(lambdaInfo);` + codeToFind,
);
}

if (
} else if (
args.path.includes(
'aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.',
path.join(
'aws-cdk-lib',
'aws-s3-deployment',
'lib',
'bucket-deployment.',
),
)
) {
const codeToFind = 'super(scope,id),this.requestDestinationArn=!1;';
Expand All @@ -341,6 +344,24 @@ export class CdkFramework implements IFramework {

// Inject code to prevent deploying the assets
contents = contents.replace(codeToFind, codeToFind + `return;`);
} else if (
args.path.includes(
path.join('aws-cdk-lib', 'aws-lambda-nodejs', 'lib', 'bundling.'),
)
) {
// prevent initializing Docker if esbuild is no installed
// Docker is used for bundling if esbuild is not installed, but it is not needed at this point
const origCode =
'const shouldBuildImage=props.forceDockerBundling||!Bundling.esbuildInstallation;';
const replaceCode = 'const shouldBuildImage=false;';

if (contents.includes(origCode)) {
contents = contents.replace(origCode, replaceCode);
} else {
throw new Error(
`Can not find code to inject in ${args.path} to prevent initializing Docker`,
);
}
}

return {
Expand Down
Loading