diff --git a/.npmrc b/.npmrc index 9483f4e6f49..02d75a7e198 100644 --- a/.npmrc +++ b/.npmrc @@ -1,5 +1,8 @@ +# Install peers for convenience auto-install-peers=true +# Particularly since we're installing them automatically, we want to know about +# any conflicts strict-peer-dependencies=true -# TODO: consider reworking the scripts to avoid usage of pre/post scripts +# A lot of our scripts rely on pre and post scripts, so this is necessary for +# now enable-pre-post-scripts=true -use-node-version=18.14.2 diff --git a/docs/devops.md b/docs/devops.md index 069f3353dd6..775c2476afe 100644 --- a/docs/devops.md +++ b/docs/devops.md @@ -450,48 +450,48 @@ sudo apt install build-essential Provisioning VMs with the Code -1. Install `pnpm` globally. +1. Install Node LTS. - ```console - curl -fsSL https://get.pnpm.io/install.sh | sh - - ``` +2. Install pnpm globally. -2. Clone freeCodeCamp, setup env and keys. +```console +npm install -g pnpm +``` - ```console - git clone https://github.com/freeCodeCamp/freeCodeCamp.git - cd freeCodeCamp - git checkout prod-current # or any other branch to be deployed - ``` +3. Clone freeCodeCamp, setup env and keys. -3. Create the `.env` from the secure credentials storage. +```console +git clone https://github.com/freeCodeCamp/freeCodeCamp.git +cd freeCodeCamp +git checkout prod-current # or any other branch to be deployed +``` -4. Create the `google-credentials.json` from the secure credentials storage. +4. Create the `.env` from the secure credentials storage. 5. Install dependencies - ```console - pnpm install - ``` +```console +pnpm install +``` 6. Setup pm2 `logrotate` and startup on boot - ```console - pnpm pm2 install pm2-logrotate - pnpm pm2 startup - ``` +```console +pnpm pm2 install pm2-logrotate +pnpm pm2 startup +``` 7. Build the server - ```console - pnpm prebuild && pnpm build:curriculum && pnpm build:server - ``` +```console +pnpm prebuild && pnpm build:curriculum && pnpm build:server +``` 8. Start Instances - ```console - pnpm start:server - ``` +```console +pnpm start:server +``` ### Logging and Monitoring @@ -529,7 +529,7 @@ pnpm install 3. Build the server ```console -pnpm run create:config && pnpm run build:curriculum && pnpm run build:server +pnpm create:config && pnpm build:curriculum && pnpm build:server ``` 4. Start Instances @@ -541,12 +541,22 @@ pnpm start:server && pnpm pm2 logs #### 2. Rolling updates - Used for logical changes to code. ```console -pnpm pm2 reload api-server/ecosystem.config.js && pnpm pm2 logs +pnpm reload:server && pnpm pm2 logs ``` > [!NOTE] We are handling rolling updates to code, logic, via pipelines. You > should not need to run these commands. These are here for documentation. +#### 3. Updating Node + +1. Install new Node version + +2. Update pm2 to use the new version + +```console +pnpm pm2 update +``` + ## Work on Client Instances 1. Install build tools for node binaries (`node-gyp`) etc. diff --git a/package.json b/package.json index 82fdd6b0023..0ba2a193d1c 100644 --- a/package.json +++ b/package.json @@ -74,13 +74,14 @@ "lint:js": "eslint --max-warnings 0 .", "lint:ts": "tsc && tsc -p config && tsc -p tools/ui-components && tsc -p utils", "lint:prettier": "prettier --list-different .", + "reload:server": "pm2 reload api-server/ecosystem.config.js", "seed": "cross-env DEBUG=fcc:* node ./tools/scripts/seed/seed-demo-user", "seed:certified-user": "cross-env DEBUG=fcc:* node ./tools/scripts/seed/seed-demo-user certified-user", "serve:client": "cd ./client && pnpm run serve", "serve:client-ci": "cd ./client && pnpm run serve-ci", "start": "npm-run-all create:* -p develop:server serve:client", "start-ci": "npm-run-all create:* -p start:server serve:client-ci", - "start:server": "pnpm pm2 start api-server/ecosystem.config.js", + "start:server": "pm2 start api-server/ecosystem.config.js", "storybook": "cd ./tools/ui-components && pnpm run storybook", "test": "run-s create:* build:curriculum build-workers test:*", "test:source": "jest",