Skip to content

Commit

Permalink
use supported version of pnpm in docker build container based on node…
Browse files Browse the repository at this point in the history
… runtime

fixes aws#25710
  • Loading branch information
0xdevalias committed Jun 7, 2023
1 parent 830e6d3 commit 6a98b35
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/aws-cdk-lib/aws-lambda-nodejs/lib/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ FROM $IMAGE
RUN npm install --global [email protected]

# Install pnpm
RUN npm install --global [email protected]
ARG PNPM_VERSION=0
RUN npm install --global pnpm@$PNPM_VERSION

# Install typescript
RUN npm install --global typescript
Expand Down
25 changes: 23 additions & 2 deletions packages/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,34 @@ export class Bundling implements cdk.BundlingOptions {

// Docker bundling
const shouldBuildImage = props.forceDockerBundling || !Bundling.esbuildInstallation;
// If runtime isn't passed use regional default, lowest common denominator is node14
const imageRuntime = props.runtime ?? Runtime.NODEJS_14_X
// Use supported version of pnpm based on the chosen runtime
const imagePnpmVersion = ((runtime) => {
switch (runtime) {
case Runtime.NODEJS_4_3:
return '^1.27.0-1'
case Runtime.NODEJS_6_10:
return '^2.24.0-0'
case Runtime.NODEJS_8_10:
return '^3.8.1'
case Runtime.NODEJS_10_X:
return '^5.18.10'
case Runtime.NODEJS_12_X:
return '^6.35.1'
case Runtime.NODEJS_14_X:
return '^7.32.5'
default:
return '^8.5.1'
}
})(imageRuntime)
this.image = shouldBuildImage ? props.dockerImage ?? cdk.DockerImage.fromBuild(path.join(__dirname, '../lib'),
{
buildArgs: {
...props.buildArgs ?? {},
// If runtime isn't passed use regional default, lowest common denominator is node14
IMAGE: (props.runtime ?? Runtime.NODEJS_14_X).bundlingImage.image,
IMAGE: imageRuntime.bundlingImage.image,
ESBUILD_VERSION: props.esbuildVersion ?? ESBUILD_MAJOR_VERSION,
PNPM_VERSION: imagePnpmVersion,
},
platform: props.architecture.dockerPlatform,
})
Expand Down

0 comments on commit 6a98b35

Please sign in to comment.