Skip to content

Commit

Permalink
chore: Upgrade Node.js to v20 (chatwoot#7759)
Browse files Browse the repository at this point in the history
Co-authored-by: Vishnu Narayanan <[email protected]>
Co-authored-by: Pranav Raj S <[email protected]>
  • Loading branch information
3 people authored Aug 28, 2023
1 parent 57feedb commit e2a6dc3
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 36 deletions.
15 changes: 7 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ defaults: &defaults
- image: cimg/postgres:15.3
- image: cimg/redis:6.2.6
environment:
- RAILS_LOG_TO_STDOUT: false
- COVERAGE: true
- LOG_LEVEL: warn
- RAILS_LOG_TO_STDOUT: false
- COVERAGE: true
- LOG_LEVEL: warn
parallelism: 4
resource_class: large

Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
nvm install v16
nvm install v20
echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
Expand All @@ -64,7 +64,6 @@ jobs:
- ~/.bundle
key: chatwoot-bundle-{{ .Environment.CACHE_VERSION }}-v20220524-{{ checksum "Gemfile.lock" }}


# Only necessary if app uses webpacker or yarn in some other way
- restore_cache:
keys:
Expand All @@ -82,7 +81,7 @@ jobs:
- ~/.cache/yarn

- run:
name: Download cc-test-reporter
name: Download cc-test-reporter
command: |
mkdir -p ~/tmp
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ~/tmp/cc-test-reporter
Expand Down Expand Up @@ -182,7 +181,7 @@ jobs:
- attach_workspace:
at: ~/build
- run:
name: Download cc-test-reporter
name: Download cc-test-reporter
command: |
mkdir -p ~/tmp
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ~/tmp/cc-test-reporter
Expand All @@ -204,4 +203,4 @@ workflows:
- build
- upload-coverage:
requires:
- build
- build
5 changes: 4 additions & 1 deletion .github/workflows/run_foss_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: yarn

- name: yarn
run: yarn install
Expand All @@ -75,6 +76,8 @@ jobs:
- name: Run backend tests
run: |
bundle exec rspec --profile=10 --format documentation
env:
NODE_OPTIONS: --openssl-legacy-provider

- name: Upload rails log folder
uses: actions/upload-artifact@v3
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/run_response_bot_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: yarn

- name: yarn
run: yarn install
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/size-limit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: 'yarn'

- name: yarn
run: yarn install
Expand All @@ -30,9 +31,11 @@ jobs:
run: |
rm -rf enterprise
rm -rf spec/enterprise
- name: Run asset compile
run: bundle exec rake assets:precompile
env:
NODE_OPTIONS: --openssl-legacy-provider

- name: Size Check
run: yarn run size
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.20.1
20.5.1
2 changes: 1 addition & 1 deletion Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
backend: bin/rails s -p 3000
frontend: bin/webpack-dev-server
frontend: export NODE_OPTIONS=--openssl-legacy-provider && bin/webpack-dev-server
# https://github.com/mperham/sidekiq/issues/3090#issuecomment-389748695
worker: dotenv bundle exec sidekiq -C config/sidekiq.yml
3 changes: 3 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
],
"stack": "heroku-20",
"buildpacks": [
{
"url": "heroku/nodejs"
},
{
"url": "heroku/ruby"
}
Expand Down
4 changes: 2 additions & 2 deletions deployment/setup_20.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ EOF
function install_dependencies() {
apt update && apt upgrade -y
apt install -y curl
curl -sL https://deb.nodesource.com/setup_16.x | bash -
curl -sL https://deb.nodesource.com/setup_20.x | bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
Expand Down Expand Up @@ -349,7 +349,7 @@ function setup_chatwoot() {
sed -i -e '/RAILS_ENV/ s/=.*/=$RAILS_ENV/' .env
echo -en "\nINSTALLATION_ENV=linux_script" >> ".env"
rake assets:precompile RAILS_ENV=production
rake assets:precompile RAILS_ENV=production NODE_OPTIONS=--openssl-legacy-provider
EOF
}

Expand Down
37 changes: 20 additions & 17 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pre-build stage
FROM ruby:3.2.2-alpine3.16 AS pre-builder
FROM ruby:3.2.2-alpine3.18 AS pre-builder

# ARG default to production settings
# For development docker-compose file overrides ARGS
Expand All @@ -13,18 +13,21 @@ ENV RAILS_SERVE_STATIC_FILES ${RAILS_SERVE_STATIC_FILES}
ARG RAILS_ENV=production
ENV RAILS_ENV ${RAILS_ENV}

ARG NODE_OPTIONS="--openssl-legacy-provider"
ENV NODE_OPTIONS ${NODE_OPTIONS}

ENV BUNDLE_PATH="/gems"

RUN apk update && apk add --no-cache \
openssl \
tar \
build-base \
tzdata \
postgresql-dev \
postgresql-client \
nodejs \
yarn \
git \
openssl \
tar \
build-base \
tzdata \
postgresql-dev \
postgresql-client \
nodejs-current \
yarn \
git \
&& mkdir -p /var/app \
&& gem install bundler

Expand Down Expand Up @@ -70,7 +73,7 @@ RUN rm -rf /gems/ruby/3.2.0/cache/*.gem \
&& rm .gitignore

# final build stage
FROM ruby:3.2.2-alpine3.16
FROM ruby:3.2.2-alpine3.18


ARG BUNDLE_WITHOUT="development:test"
Expand All @@ -92,12 +95,12 @@ ENV BUNDLE_PATH="/gems"

RUN apk update && apk add --no-cache \
build-base \
openssl \
tzdata \
postgresql-client \
imagemagick \
git \
vips \
openssl \
tzdata \
postgresql-client \
imagemagick \
git \
vips \
&& gem install bundler

RUN if [ "$RAILS_ENV" != "production" ]; then \
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/yarn.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# https://github.com/rails/rails/issues/43906#issuecomment-1099992310
task before_assets_precompile: :environment do
# run a command which starts your packaging
ENV['NODE_OPTIONS'] = '--openssl-legacy-provider'
system('yarn')
end

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"prepare": "husky install",
"size": "size-limit"
},
"size-limit": [{
"size-limit": [
{
"path": "public/packs/js/widget-*.js",
"limit": "270 KB"
},
Expand Down Expand Up @@ -146,9 +147,9 @@
"webpack-dev-server": "^3"
},
"engines": {
"node": ">=10.x",
"node": "20.x",
"npm": ">=6.x",
"yarn": ">=1.x"
"yarn": "1.22.x"
},
"husky": {
"hooks": {
Expand Down

0 comments on commit e2a6dc3

Please sign in to comment.