Skip to content

Commit

Permalink
bump runtime to node 16 LTS (#2324)
Browse files Browse the repository at this point in the history
* bump runtime to node 16 LTS

* update circle CI base image

* update node runtime and required engine

* update spa node image

* update docs

* update docs for release pipeline vars

* update documentation for running test suite

* Upgrade functions to v4 in host.json

* Revert "Upgrade functions to v4 in host.json"

This reverts commit b60ac4d.

* Update assets version

* Downgrade functions to v14

* Update circleci dockerfile with additional v14 node version
minor bump to v14.21.1

* move functions to node 16 with the v2 bindings extension preserved for table storage compatability.  add a util to sync or create the local.settings.json file

Co-authored-by: Jon Shipley <[email protected]>
Co-authored-by: Jon Shipley <[email protected]>
  • Loading branch information
3 people authored Dec 5, 2022
1 parent 3b2c288 commit 3d48960
Show file tree
Hide file tree
Showing 45 changed files with 169 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .disabled.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ language: node_js
services:
- docker
node_js:
- 14.18.1
- 16.17.1
env:
jobs:
- IMAGE=admin
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.18.1
v16.17.1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
## Project tooling requirements

- Docker (current LTS)
- Node JS (best installed via nvm)
- Node JS (best installed via [nvm](https://github.com/nvm-sh/nvm))
- Text Editor
- bash
- Azure storage explorer
Expand Down
2 changes: 1 addition & 1 deletion admin/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.18.1
v16.17.1
2 changes: 1 addition & 1 deletion admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14.18.1
FROM node:16.17.1

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
Expand Down
2 changes: 1 addition & 1 deletion admin/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14.18.1
FROM node:16.17.1
EXPOSE 3001 2222
RUN mkdir -p /mtc/admin
WORKDIR /mtc/admin
Expand Down
2 changes: 1 addition & 1 deletion admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"assets-version": "e3cf7309a51a6a6af117a4d5f04dedec"
},
"engines": {
"node": ">= 14"
"node": ">= 16"
},
"resolutions": {
"**/**/lodash": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion db/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.18.1
v16.17.1
2 changes: 1 addition & 1 deletion db/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14.18.1
FROM node:16.17.1

RUN mkdir -p /usr/src/app
WORKDIR /user/src/app
Expand Down
2 changes: 1 addition & 1 deletion db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"license": "GPL-3.0",
"private": false,
"engines": {
"node": ">= 14"
"node": ">= 16"
},
"scripts": {
"new": "node ./engine/create-migration.js",
Expand Down
4 changes: 2 additions & 2 deletions deploy/build-agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ RUN echo "export GEM_PATH=$GEM_HOME:/usr/local/lib/ruby/gems/2.6.0" >> ~/.profil

# install nvm and current node runtimes
ENV NVM_DIR=/home/$BUILD_USER/.nvm
ENV CURRENT_NODE_VERSION=14.18.1
ENV PREVIOUS_NODE_VERSION=12.18.2
ENV CURRENT_NODE_VERSION=16.17.1
ENV PREVIOUS_NODE_VERSION=14.18.1

RUN curl -sL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
Expand Down
2 changes: 1 addition & 1 deletion deploy/build-agent/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
4. delete existing build server container instances in azure
5. run `./create-instance.sh` to create new build servers
6. once new agents are up and running, assign a 'user defined capability' to each one via the build agent management screen in VSO.
7. Add name as mtc-instance and number them consecutively, starting at 1. This allows us to source and whitelist the IP address of each.
7. Add name as `mtc-instance` and number them consecutively, starting at 1. This allows us to source and whitelist the IP address of each.

example execution of `create-instance.sh`...

Expand Down
9 changes: 4 additions & 5 deletions deploy/docker/circleci-node-multi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# This is a custom dockerfile to allow us to run multiple versions of node
# +nvm
FROM circleci/node:10-browsers
RUN curl -s -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
RUN /bin/bash -c "export NVM_DIR=\${HOME}/.nvm && source \${NVM_DIR}/nvm.sh && nvm install v10.14.1"
RUN /bin/bash -c "export NVM_DIR=\${HOME}/.nvm && source \${NVM_DIR}/nvm.sh && nvm install v10.17.0"
RUN /bin/bash -c "export NVM_DIR=\${HOME}/.nvm && source \${NVM_DIR}/nvm.sh && nvm install v12.18.2"
FROM circleci/node:14-browsers
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
RUN /bin/bash -c "export NVM_DIR=\${HOME}/.nvm && source \${NVM_DIR}/nvm.sh && nvm install v14.18.1"
RUN /bin/bash -c "export NVM_DIR=\${HOME}/.nvm && source \${NVM_DIR}/nvm.sh && nvm install v14.21.1"
RUN /bin/bash -c "export NVM_DIR=\${HOME}/.nvm && source \${NVM_DIR}/nvm.sh && nvm install v16.17.1"
3 changes: 3 additions & 0 deletions deploy/docker/circleci-node-multi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ for multiple node versions.

This docker image needs to be made publicly available so we can pull it in when launching our circleci jobs.Availability

## Modifying
Change the base image reference to the lowest version of node the solution needs to support. Change the nvm install list to cover all versions of node in use.

### Publishing

1. Build it
Expand Down
2 changes: 1 addition & 1 deletion deploy/docker/functions-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14.18.1
FROM node:16.17.1

# SHELL ["/bin/bash", "-c"]

Expand Down
2 changes: 1 addition & 1 deletion deploy/service-bus/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.18.1
v16.17.1
2 changes: 1 addition & 1 deletion deploy/service-bus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"deleteqs": "node ./delete.js"
},
"engines": {
"node": ">= 14"
"node": ">= 16"
},
"repository": "[email protected]:DFEAGILEDEVOPS/MTC.git",
"author": "Guy Harwood",
Expand Down
2 changes: 1 addition & 1 deletion deploy/sql/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.18.1
v16.17.1
2 changes: 1 addition & 1 deletion deploy/sql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dummy:all": "node ./dummy-data/all.js"
},
"engines": {
"node": ">= 14"
"node": ">= 16"
},
"dependencies": {
"axios": "^0.21.2",
Expand Down
1 change: 0 additions & 1 deletion design/spikes-poc/spike-durable-functions/.nvmrc

This file was deleted.

32 changes: 32 additions & 0 deletions docs/node-runtime-upgrade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Upgrading the Node Runtime

This solution is heavily dependent on the Node JS runtime.
We typically upgrade to the most sensible LTS once or twice a year to stay aligned with security patching and general maintenance.

## Files to update

In order to upgrade the node runtime across the solution, you must update multiple files.
The easiest way to do this is use your editor to search for the current version string across all files in the solution.

## Update the build-agent Dockerfile

We install the current and last node versions on the build agent to ensure it can handle transitions to new versions across builds without interruption. There are 2 variables to update in this file...
- `PREVIOUS_NODE_VERSION`
- `CURRENT_NODE_VERSION`

## Update the circle-CI Dockerfile

The Circle CI base image for pull request testing must be updated to include the least supported version of node, plus current. Details and instructions [here](!./../../deploy/docker/circleci-node-multi/README.md)

## Upgrade the Azure functions

### Ensure function apps runtime is compatible with Node JS runtime

https://learn.microsoft.com/en-us/azure/azure-functions/functions-versions?tabs=azure-cli%2Cwindows%2Cin-process%2Cv4&pivots=programming-language-javascript#changing-version-of-apps-in-azure

### Update the release pipeline variables to the new Node JS version and function runtime

within the VSO release library for each environment there are variables that cover the function runtime and node version respectively...

`Functions.Runtime.Version`
`Functions.Node.Version`
2 changes: 1 addition & 1 deletion func-consumption/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.18.1
v16.17.1
9 changes: 8 additions & 1 deletion func-consumption/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"prod:clean": "rm -rf ./node_modules && yarn install --frozen-lockfile --production",
"rebuild": "yarn clean && yarn build",
"sync": "node ./sync-tslib-deps.js && yarn install",
"sync:settings": "node ./sync-local-settings.js",
"delete-specs": "find . -name \"*.spec.js\" -type f -delete",
"clean": "rm -rf ./dist",
"start:host": "func start",
Expand Down Expand Up @@ -64,5 +65,11 @@
"random-number-csprng": "^1.0.2",
"ua-parser-js": "^0.8.1",
"uuid": "^8.3.1"
},
"function-settings": {
"FUNCTIONS_WORKER_RUNTIME": "node",
"FUNCTIONS_EXTENSION_VERSION": "~4",
"WEBSITE_NODE_DEFAULT_VERSION": "~16",
"AzureWebJobs.check-notifier.Disabled": "true"
}
}
}
2 changes: 2 additions & 0 deletions func-consumption/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ a local.settings.json file is required in the root of the project, with a minimu
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "node",
"FUNCTIONS_EXTENSION_VERSION": "~4",
"WEBSITE_NODE_DEFAULT_VERSION": "~16",
"AzureWebJobsStorage": "{AzureWebJobsStorage}",
"AZURE_STORAGE_CONNECTION_STRING": "#your storage account connection#",
"AZURE_SERVICE_BUS_CONNECTION_STRING": "#your service bus connection#",
Expand Down
12 changes: 12 additions & 0 deletions func-consumption/sync-local-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict'

const jedit = require('edit-json-file')

// if the destination file does not exist it will be created
const dest = jedit('./local.settings.json')
const src = jedit('./package.json')
const defaultValues = src.get('function-settings')
dest.set('Values', defaultValues, {
merge: true
})
dest.save()
2 changes: 1 addition & 1 deletion func-ps-report/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.18.1
v16.17.1
8 changes: 7 additions & 1 deletion func-ps-report/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"prod:clean": "rm -rf ./node_modules && yarn install --frozen-lockfile --production",
"rebuild": "yarn clean && yarn build",
"sync": "node ./sync-tslib-deps.js && yarn install",
"sync:settings": "node ./sync-local-settings.js",
"delete-specs": "find . -name \"*.spec.js\" -type f -delete",
"clean": "rm -rf ./dist",
"start:host": "func host start --port 7074",
Expand Down Expand Up @@ -54,5 +55,10 @@
"random-number-csprng": "^1.0.2",
"ua-parser-js": "^0.8.1",
"uuid": "^8.3.1"
},
"function-settings": {
"FUNCTIONS_WORKER_RUNTIME": "node",
"FUNCTIONS_EXTENSION_VERSION": "~4",
"WEBSITE_NODE_DEFAULT_VERSION": "~16"
}
}
}
2 changes: 2 additions & 0 deletions func-ps-report/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ a local.settings.json file is required in the root of the project, with a minimu
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "node",
"FUNCTIONS_EXTENSION_VERSION": "~4",
"WEBSITE_NODE_DEFAULT_VERSION": "~16",
"AzureWebJobsStorage": "{AzureWebJobsStorage}",
"AZURE_STORAGE_CONNECTION_STRING": "#your storage account connection#",
"AZURE_SERVICE_BUS_CONNECTION_STRING": "#your service bus connection#"
Expand Down
12 changes: 12 additions & 0 deletions func-ps-report/sync-local-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict'

const jedit = require('edit-json-file')

// if the destination file does not exist it will be created
const dest = jedit('./local.settings.json')
const src = jedit('./package.json')
const defaultValues = src.get('function-settings')
dest.set('Values', defaultValues, {
merge: true
})
dest.save()
2 changes: 1 addition & 1 deletion func-throttled/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.18.1
v16.17.1
8 changes: 7 additions & 1 deletion func-throttled/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"prod:clean": "rm -rf ./node_modules && yarn install --frozen-lockfile --production",
"rebuild": "yarn clean && yarn build",
"sync": "node ./sync-tslib-deps.js && yarn install",
"sync:settings": "node ./sync-local-settings.js",
"delete-specs": "find . -name \"*.spec.js\" -type f -delete",
"clean": "rm -rf ./dist",
"start:host": "func host start --port 7073",
Expand Down Expand Up @@ -54,5 +55,10 @@
"random-number-csprng": "^1.0.2",
"ua-parser-js": "^0.8.1",
"uuid": "^8.3.1"
},
"function-settings": {
"FUNCTIONS_WORKER_RUNTIME": "node",
"FUNCTIONS_EXTENSION_VERSION": "~4",
"WEBSITE_NODE_DEFAULT_VERSION": "~16"
}
}
}
2 changes: 2 additions & 0 deletions func-throttled/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ a local.settings.json file is required in the root of the project, with a minimu
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "node",
"FUNCTIONS_EXTENSION_VERSION": "~4",
"WEBSITE_NODE_DEFAULT_VERSION": "~16",
"AzureWebJobsStorage": "{AzureWebJobsStorage}",
"AZURE_STORAGE_CONNECTION_STRING": "#your storage account connection#",
"AZURE_SERVICE_BUS_CONNECTION_STRING": "#your service bus connection#"
Expand Down
12 changes: 12 additions & 0 deletions func-throttled/sync-local-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict'

const jedit = require('edit-json-file')

// if the destination file does not exist it will be created
const dest = jedit('./local.settings.json')
const src = jedit('./package.json')
const defaultValues = src.get('function-settings')
dest.set('Values', defaultValues, {
merge: true
})
dest.save()
2 changes: 1 addition & 1 deletion load-test/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.18.1
v16.17.1
2 changes: 1 addition & 1 deletion load-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"purgestorage": "bin/init-dev-storage.js"
},
"engines": {
"node": ">= 14"
"node": ">= 16"
},
"resolutions": {
"**/**/lodash": "^4.17.21"
Expand Down
2 changes: 1 addition & 1 deletion pupil-api/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.18.1
v16.17.1
2 changes: 1 addition & 1 deletion pupil-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14.18.1
FROM node:16.17.1

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
Expand Down
2 changes: 1 addition & 1 deletion pupil-api/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14.18.1
FROM node:16.17.1
RUN mkdir -p /mtc/pupil-api
WORKDIR /mtc/pupil-api
EXPOSE 3003
2 changes: 1 addition & 1 deletion pupil-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"clean": "rm -rf ./dist"
},
"engines": {
"node": ">= 14"
"node": ">= 16"
},
"resolutions": {
"**/**/lodash": "^4.17.21"
Expand Down
2 changes: 1 addition & 1 deletion pupil-spa/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.18.1
v16.17.1
2 changes: 1 addition & 1 deletion pupil-spa/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### STAGE 1: Build ###

# We label our stage as 'builder'
FROM node:14-alpine as builder
FROM node:16-alpine as builder

# `yarn install` needs to be able to find `git` for lz-string which uses a github.com URL for the version.
RUN apk update && \
Expand Down
2 changes: 1 addition & 1 deletion pupil-spa/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14.18.1
FROM node:16.17.1

RUN mkdir -p /mtc/pupil-spa
WORKDIR /mtc/pupil-spa
Expand Down
2 changes: 1 addition & 1 deletion pupil-spa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"runUnsupportedBrowserTests": "./unsupported-browser-tests/run-unsupported-browser-tests.sh"
},
"engines": {
"node": ">= 14"
"node": ">= 16"
},
"resolutions": {
"**/**/lodash": ">=4.17.21",
Expand Down
Loading

0 comments on commit 3d48960

Please sign in to comment.