Skip to content

Commit c630ccf

Browse files
authored
Pipeline: Upgrade to Node.js 20 (#144)
* Fix NodeJS and Build Images * Fix install * X86 needed for Docker
1 parent bf7e60a commit c630ccf

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

lib/cdk-pipeline-stack.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,29 @@ export class CdkPipelineStack extends cdk.Stack {
8989
const pipeline = new pipelines.CodePipeline(this, 'Pipeline', {
9090
dockerEnabledForSynth: true,
9191
publishAssetsInParallel: false,
92+
// Add this to fix asset publishing steps
93+
assetPublishingCodeBuildDefaults: {
94+
buildEnvironment: {
95+
buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2023_5,
96+
computeType: codebuild.ComputeType.LARGE,
97+
},
98+
partialBuildSpec: codebuild.BuildSpec.fromObject({
99+
phases: {
100+
install: {
101+
commands: [
102+
// Update Node.js first
103+
`n ${NODE_VERSION}`,
104+
'node --version',
105+
// Install CDK with compatible cdk-assets
106+
`npm install -g aws-cdk@${CDK_VERSION}`,
107+
],
108+
},
109+
},
110+
}),
111+
},
92112
synth: new pipelines.CodeBuildStep('SynthAndDeployBackend', {
93113
buildEnvironment: {
94-
buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0,
114+
buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2023_STANDARD_3_0,
95115
computeType: codebuild.ComputeType.LARGE,
96116
},
97117
input: pipelines.CodePipelineSource.gitHub(props.sourceRepo, props.sourceBranchName, {
@@ -189,7 +209,7 @@ export class CdkPipelineStack extends cdk.Stack {
189209
'amplify codegen', // I'm not repeating myself ;)
190210
'cd ../..',
191211
'docker run --rm -v $(pwd):/foo -w /foo' +
192-
" public.ecr.aws/sam/build-nodejs18.x:latest bash -c 'npm install" +
212+
" public.ecr.aws/sam/build-nodejs20.x:latest bash -c 'npm install" +
193213
" --cache /tmp/empty-cache && npm run build'",
194214
'aws s3 sync ./build/ s3://$sourceBucketName/ --delete',
195215
'echo distributionId=$distributionId',
@@ -228,7 +248,7 @@ export class CdkPipelineStack extends cdk.Stack {
228248
'amplify codegen', // I'm not repeating myself ;)
229249
'cd ../..',
230250
'docker run --rm -v $(pwd):/foo -w /foo' +
231-
" public.ecr.aws/sam/build-nodejs18.x:latest bash -c 'npm install" +
251+
" public.ecr.aws/sam/build-nodejs20.x:latest bash -c 'npm install" +
232252
" --cache /tmp/empty-cache && npm run build'",
233253
'aws s3 sync ./build/ s3://$leaderboardSourceBucketName/ --delete',
234254
"aws cloudfront create-invalidation --distribution-id $leaderboardDistributionId --paths '/*'",
@@ -266,7 +286,7 @@ export class CdkPipelineStack extends cdk.Stack {
266286
'amplify codegen', // I'm not repeating myself ;)
267287
'cd ../..',
268288
'docker run --rm -v $(pwd):/foo -w /foo' +
269-
" public.ecr.aws/sam/build-nodejs18.x:latest bash -c 'npm install" +
289+
" public.ecr.aws/sam/build-nodejs20.x:latest bash -c 'npm install" +
270290
" --cache /tmp/empty-cache && npm run build'",
271291
'aws s3 sync ./build/ s3://$streamingOverlaySourceBucketName/ --delete',
272292
"aws cloudfront create-invalidation --distribution-id $streamingOverlayDistributionId --paths '/*'",

0 commit comments

Comments
 (0)