Skip to content
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

Upgrade to Node 14 #637

Merged
merged 12 commits into from
Jul 27, 2020
Merged

Upgrade to Node 14 #637

merged 12 commits into from
Jul 27, 2020

Conversation

LachlanStuart
Copy link
Contributor

@LachlanStuart LachlanStuart commented Jul 15, 2020

This change adds nvm for managing node versions, which would allow webapp/graphql to have their own independent versions if necessary. Unfortunately nvm did not integrate well with ansible / supervisor, so the commands to launch node/yarn are a bit hacky in places.

The main issue is that nvm isn't a script - it's a shell function that gets installed when you source the ~/.nvm/nvm.sh script, which usually is done automatically via .bashrc. To get past this, I had to ensure bash was running whenever nvm was needed, and had to prefix commands with . ~/.nvm/nvm.sh to install the shell function and nvm use to switch to the working directory's specified version of node. Neither Ansible nor Supervisord have any non-hacky ways to source .profile/.bashrc/etc. before running their commands.

Node 14 is not LTS yet - it's due to become LTS in 3 months. I like new shiny things though, and Node 14 has native ES Module support. I pinned it to 14.5.* because I've had dev environment issues in the past when my local copy of node has had a different minor version than my docker copy.

@richardgoater Please review the JS changes

@intsco Please review the ansible & docker changes

Related: #552

Code changes

  • Remove hacks needed for node 8 (asyncIterator polyfill, incorrect date format in ElapsedTime.spec.ts)
  • Updated FilterPanel snapshot. It seems the reason it was reordered was because Array.prototype.sort started using a stable sorting algorithm in Node 11, and sortFilterKeys in store/mutations.js sorts against the same value for most items.

Some dependencies needed to be updated for Node 14 support, or to prevent console warnings:

I also snuck in a couple unrelated changes:

Ansible changes

  • I found my previous changes that map python to python3 were overwritten when provisioning from scratch, so I had to make several fixes to prevent python2 from overwriting the symlink.
  • I fixed a warning about the use of jinja {{ var }} templates in the when clause in the ElasticSearch task
  • I re-enabled autorestart for the supervisor services.
  • I found an issue in sm-web - Mol DBs can't be installed before sm-graphql has created the database schema. Too hard to fix in this PR, so I left a TODO.

Docker changes

  • Switched to alpine images
  • Removed code for pre-caching yarn packages, as doesn't help for development mode

Testing

For ansible, I provisioned & deployed to a new dev server to test that the ansible changes all worked.

For webapp, I'd expect any issues would surface during build/test. There are no new errors/warnings as far as I can see.

For graphql:

  • I did the basic CRUD operations for datasets and projects to test that interop with Postgres, ElasticSearch, sm-api and the graphql image/storage server all still work.
  • I tested a dataset status update and a system maintenance message to check that RabbitMQ, and websocket subscriptions still work.

Deployment

I don't plan to merge this until after the current batch of changes to prod are deployed, as the pending deployment already has a lot of manual steps.

Before deployment the following should be run to install nvm:

ansible-playbook -i env/ENVIRONMENT provision/web.yml -t nodejs

Update webapp babel (via manual lockfile deletion & reinstall) due to babel/babel#11216
Update webapp node-sass for Node 14 support
Update webapp element-ui due to ElemeFE/element#19389
Update graphql bcrypt to hopefully fix rebuild-on-node-version-change behavior
Update graphql knex/pg to fix knex/knex#3836
Update graphql winston to fix winstonjs/winston#1797
Update graphql ts-node-dev to fix wclr/ts-node-dev#143
Pin version of graphql graphql-binding because I remember newer versions not being compatible

Remove hacks needed for node 8 (asyncIterator polyfill, incorrect date format in ElapsedTime.spec.ts)
Updated FilterPanel snapshot. It seems the reason it was reordered was because Array.prototype.sort started using a stable sorting algorithm in Node 11, and `sortFilterKeys` in store/mutations.js sorts against the same value for most items.
@@ -1,14 +1,15 @@
FROM node:8.16.2
FROM node:14.5.0-alpine3.12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for Alpine

Copy link
Member

@richardgoater richardgoater left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be great to modernise things a bit, thanks for picking up all those issues.

@LachlanStuart LachlanStuart merged commit 9f7d697 into master Jul 27, 2020
@LachlanStuart LachlanStuart deleted the feat/node-14 branch July 27, 2020 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants