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

Install specific nodejs version #223

Merged
merged 5 commits into from
Nov 23, 2023

Conversation

Senen
Copy link
Member

@Senen Senen commented Sep 21, 2023

References

Do not merge until the Consul Democracy 2.1.0 release.

Objective

Consul Democracy has added a .node-version file in version 2.1.0, and now it installs the version defined there when deploying with Capistrano and installs NPM packages for that version.

So we're doing the same when running the installer.

  1. Install FNM for the deploy user
  2. Install the nodejs version defined in consuldemocracy/consuldemocracy using FNM.
  3. Install the nodejs application dependencies defined in consuldemocracy application package.json using NPM.
  4. Update rails commands so the application finds the proper nodejs binaries

The FNM installer adds the following entry to the deploy_user .bashrc file:

# fnm
export PATH="/home/deploy/.fnm:$PATH"
eval "`fnm env

This code loads the NodeJS version defined in the .node-version during interactive shells in the same fashion we do with RVM (by loading the ruby version defined in the .ruby-version file).

Notes

Any consuldemocracy/consuldemocracy command that loads the application (rake, rails, delayed_job puma, among others) must have NodeJS binaries available. Otherwise, it crashes even for commands where JS is not required, like rake secret.

@javierm javierm added this to Doing in Consul Democracy Sep 21, 2023
@Senen Senen force-pushed the install_specific_nodejs_version branch from 2f3d28b to a4ef031 Compare October 6, 2023 11:40
@Senen Senen force-pushed the install_specific_nodejs_version branch 10 times, most recently from da86fdc to 5b1d9bd Compare October 9, 2023 13:21
@javierm javierm force-pushed the install_specific_nodejs_version branch from 5b1d9bd to 3708188 Compare October 9, 2023 20:55
@Senen Senen force-pushed the install_specific_nodejs_version branch 2 times, most recently from 06bd6bd to 5bfddc9 Compare October 13, 2023 07:01
@Senen Senen marked this pull request as ready for review October 16, 2023 14:21
@Senen Senen force-pushed the install_specific_nodejs_version branch from 83fd201 to 150522c Compare October 16, 2023 14:30
@javierm javierm moved this from Doing to Reviewing in Consul Democracy Oct 16, 2023
@javierm javierm marked this pull request as draft October 16, 2023 14:30
Consul Democracy automation moved this from Reviewing to Testing Oct 16, 2023
roles/rails/tasks/main.yml Outdated Show resolved Hide resolved
@Senen Senen force-pushed the install_specific_nodejs_version branch from 150522c to dc6cc35 Compare October 18, 2023 15:59
@Senen Senen marked this pull request as ready for review October 18, 2023 16:01
@javierm javierm marked this pull request as draft October 18, 2023 16:07
@Senen Senen force-pushed the install_specific_nodejs_version branch from dc6cc35 to 9d48239 Compare October 18, 2023 16:08
@Senen Senen force-pushed the install_specific_nodejs_version branch from 9d48239 to 283c2c4 Compare October 24, 2023 13:46
@Senen Senen force-pushed the install_specific_nodejs_version branch 2 times, most recently from bb0c82d to 05f8278 Compare November 16, 2023 16:44
…f nodejs

Note we aren't installing the `master` branch (for now) because that
branch requires configuring Puma with systemd. Instead, we're using the
last commit which still uses Puma as a daemon.
@javierm javierm force-pushed the install_specific_nodejs_version branch from 05f8278 to 75f6f9e Compare November 21, 2023 19:56
@javierm javierm changed the base branch from master to release_2.1.0 November 21, 2023 19:56
@javierm javierm marked this pull request as ready for review November 21, 2023 19:56
@javierm javierm self-assigned this Nov 22, 2023
@Senen Senen force-pushed the install_specific_nodejs_version branch 3 times, most recently from fa60e64 to 387de80 Compare November 23, 2023 15:34
Consul Democracy has added a `.node-version` file in version 2.1.0, and
now it installs the version defined there when deploying with Capistrano
and installs NPM packages for that version.

So we're doing the same when running the installer.
```
[DEPRECATION WARNING]: "include" is deprecated, use include_tasks/import_tasks instead. See https://docs.ansible.com/ansible-core/2.15/user_guide/playbooks_reuse_includes.html for
details. This feature will be removed in version 2.16. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
```
We found nodejs binaries from `nodejs.org/dist` sometimes are not
available or takes to long to download them making the installer
crash.

With this change we hope to significally reduce the chance to have a
failure when running the installer.
@Senen Senen force-pushed the install_specific_nodejs_version branch from 387de80 to 59b8bbb Compare November 23, 2023 16:04
@javierm javierm merged commit ad38999 into release_2.1.0 Nov 23, 2023
4 checks passed
Consul Democracy automation moved this from Testing to Release 2.1.0 Nov 23, 2023
@javierm javierm deleted the install_specific_nodejs_version branch November 23, 2023 18:15
@javierm javierm removed the 2.1 label Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants