From d03da33ac336ee32831c84d6788a6bf27b6ad03a Mon Sep 17 00:00:00 2001 From: Daniel Uber Date: Mon, 3 Jan 2022 10:23:07 -0600 Subject: [PATCH] Update to node version 16 (#15522) * update to node version 16 * Remove canvas compiled node objects * use f35 testing image as builder/base * Update production builder base image to use Fedora 35 I missed this (it's not immediately obvious that there are 2 base images declared in this file, one called builder, one called production, this seems like it could be refactored to lift that out (give it a name, a cmd, and do nothing else) `as base` perhaps, while keeping separate install processes for testing- and pr-/production images. * Add libpq dependency in production We need this (if not the -devel header file, at least the library) to start pg_ext.so I think this might have been working because of the --cache-from options when building in the build container script? * Update .gitpod.dockerfile * Add temporary cleanup for upgrade to bin/setup This has the undesirable effect of requiring a yarn reinstall. It would be better if there were a smart check to confirm the version of the canvas.node file matched the node version or did not (so we only do this as needed, rather than on every setup invocation until this is removed from the code). * Use check-files rather than force when rebuilding canvas Optimal situation would be a `rebuild` command in yarn (I believe npm has this option) to recompile canvas (all that's needed) rather than fetch, install, and build. Co-authored-by: Michael Kohl --- .gitpod.dockerfile | 2 +- .nvmrc | 2 +- .travis.yml | 2 ++ Containerfile | 5 ++--- bin/setup | 9 +++++++++ package.json | 2 +- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.gitpod.dockerfile b/.gitpod.dockerfile index 684bb871c..12595d9bd 100644 --- a/.gitpod.dockerfile +++ b/.gitpod.dockerfile @@ -12,7 +12,7 @@ RUN bash -lc "rvm install ruby-$RUBY_VERSION && rvm use ruby-$RUBY_VERSION --def RUN echo "rvm_gems_path=/workspace/.rvm" > ~/.rvmrc # Install Node and Yarn -ENV NODE_VERSION=14.17.6 +ENV NODE_VERSION=16.13.1 RUN bash -c ". .nvm/nvm.sh && \ nvm install ${NODE_VERSION} && \ nvm alias default ${NODE_VERSION} && \ diff --git a/.nvmrc b/.nvmrc index 8351c1939..b6a7d89c6 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -14 +16 diff --git a/.travis.yml b/.travis.yml index ef80efb34..dc7c836c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,8 @@ cache: bundler: true directories: - node_modules +before_cache: + - find node_modules -type f -name "*.node" -delete rvm: - 3.0.2 addons: diff --git a/Containerfile b/Containerfile index 4dbc7199d..cdf3c2683 100644 --- a/Containerfile +++ b/Containerfile @@ -1,5 +1,4 @@ -FROM quay.io/forem/ruby:3.0.2 as base - +FROM quay.io/forem/ruby:3.0.2-testing as base FROM base as builder @@ -58,7 +57,7 @@ USER root RUN dnf install --setopt install_weak_deps=false -y bash curl ImageMagick \ iproute jemalloc less libcurl \ - postgresql tzdata nodejs \ + postgresql tzdata nodejs libpq \ && dnf -y clean all \ && rm -rf /var/cache/yum diff --git a/bin/setup b/bin/setup index 2c1679c5d..7e1fc4aa4 100755 --- a/bin/setup +++ b/bin/setup @@ -22,6 +22,15 @@ FileUtils.chdir APP_ROOT do system! "gem list \"^foreman$\" -i --silent || gem install foreman" + # TODO: temporary fix for node 16 upgrade, remove after release as this triggers reinstallation + # of the canvas library (with its extension compiled against the versioned node symbol) + if File.exist?("node_modules/canvas/") + FileUtils.rm_rf("node_modules/canvas/") + # having removed the module ourselves, + # we need to coerce yarn, or remove the .yarn-integrity file + system("yarn install --check-files") + end + # Install JavaScript dependencies if using Yarn system("bin/yarn") diff --git a/package.json b/package.json index a73c3e92a..a1d71abe5 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Where programmers share ideas and help each other grow", "engines": { "yarn": ">=1.21.x", - "node": "14.x" + "node": "16.x" }, "main": "index.js", "directories": {