aws / aws-codebuild-docker-images

Official AWS CodeBuild repository for managed Docker images http://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref.html
Other
1.11k stars 973 forks source link

Update nodejs version to 18.17.0 #673

Closed bilegjargal-jargalsaikhan closed 9 months ago

bilegjargal-jargalsaikhan commented 1 year ago

I have some node packages that don't support on the current version of the codebuild standard:7 image which has the node version 18.16.1 so I needed to update the node version to 18.17.0

Issue #668

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

matheuscanela commented 1 year ago

I use cdk to deploy, so I changed my script as per below and it is now running on 18.17.1

So I added 'n 18' & 'npm i npm@latest -g' to phases, initial, command, also I am using the latest image

  synth: new ShellStep('Synth', {
    input: CodePipelineSource.connection('myapp', 'master', { connectionArn: props.config.accounts.mgnt.gitConnection }),
    commands: [
      'npm ci',
      'npm run build',
      'npx cdk synth',
    ],
    installCommands: [
      'npm i -g npm && npm ci'
    ],
  }),
  synthCodeBuildDefaults: {
    partialBuildSpec : BuildSpec.fromObject({
      phases: {
        install: {
            commands: [
              'n 18',
              'npm i npm@latest -g',
            ]
        }
      }
    }),
    buildEnvironment: {
      privileged: true,
      //computeType: cdk.aws_codebuild.ComputeType.LARGE, 
      buildImage: LinuxBuildImage.fromCodeBuildImageId('aws/codebuild/amazonlinux2-x86_64-standard:5.0')
    },
  },
});
MrRatan commented 10 months ago

here is an alternate way, update your buildspec:

phases:
  install:
    runtime-versions:
      python: 3.x     #optional
    commands:
      - echo "Installing NVM and Node.js 18.17.0..."
      - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
      - . $HOME/.nvm/nvm.sh && nvm install 18.17.0
      - node -v
      - npm -v
      # ... other installation commands...
Dylan-AWS commented 9 months ago

CodeBuild released an update for node 18 in the AL:5.0 image and Ubuntu 7.0 (https://github.com/aws/aws-codebuild-docker-images/pull/689).