Merge pull request #5158 from consuldemocracy/node_version
Depend on a specific version of Node.js
This commit is contained in:
4
.github/workflows/tests.yml
vendored
4
.github/workflows/tests.yml
vendored
@@ -40,7 +40,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
bundler-cache: true
|
bundler-cache: true
|
||||||
- name: Setup NPM
|
- name: Setup NPM
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version-file: ".node-version"
|
||||||
- name: Copy secrets and database files
|
- name: Copy secrets and database files
|
||||||
run: for i in config/*.example; do cp "$i" "${i/.example}"; done
|
run: for i in config/*.example; do cp "$i" "${i/.example}"; done
|
||||||
- name: Setup database
|
- name: Setup database
|
||||||
|
|||||||
1
.node-version
Normal file
1
.node-version
Normal file
@@ -0,0 +1 @@
|
|||||||
|
18.18.0
|
||||||
10
Dockerfile
10
Dockerfile
@@ -13,7 +13,6 @@ RUN apt-get update -qq \
|
|||||||
libpq-dev \
|
libpq-dev \
|
||||||
libxss1 \
|
libxss1 \
|
||||||
memcached \
|
memcached \
|
||||||
nodejs \
|
|
||||||
pkg-config \
|
pkg-config \
|
||||||
postgresql-client \
|
postgresql-client \
|
||||||
shared-mime-info \
|
shared-mime-info \
|
||||||
@@ -28,7 +27,7 @@ RUN adduser --shell /bin/bash --disabled-password --gecos "" consul \
|
|||||||
&& adduser consul sudo \
|
&& adduser consul sudo \
|
||||||
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
||||||
|
|
||||||
RUN echo 'Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bundle/bin"' > /etc/sudoers.d/secure_path
|
RUN echo 'Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bundle/bin:/usr/local/node/bin"' > /etc/sudoers.d/secure_path
|
||||||
RUN chmod 0440 /etc/sudoers.d/secure_path
|
RUN chmod 0440 /etc/sudoers.d/secure_path
|
||||||
|
|
||||||
# Define where our application will live inside the image
|
# Define where our application will live inside the image
|
||||||
@@ -40,6 +39,13 @@ RUN mkdir -p $RAILS_ROOT/tmp/pids
|
|||||||
# Set our working directory inside the image
|
# Set our working directory inside the image
|
||||||
WORKDIR $RAILS_ROOT
|
WORKDIR $RAILS_ROOT
|
||||||
|
|
||||||
|
# Install Node
|
||||||
|
COPY .node-version ./
|
||||||
|
ENV PATH=/usr/local/node/bin:$PATH
|
||||||
|
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
|
||||||
|
/tmp/node-build-master/bin/node-build `cat .node-version` /usr/local/node && \
|
||||||
|
rm -rf /tmp/node-build-master
|
||||||
|
|
||||||
# Use the Gemfiles as Docker cache markers. Always bundle before copying app src.
|
# Use the Gemfiles as Docker cache markers. Always bundle before copying app src.
|
||||||
# (the src likely changed and we don't want to invalidate Docker's cache too early)
|
# (the src likely changed and we don't want to invalidate Docker's cache too early)
|
||||||
COPY Gemfile* ./
|
COPY Gemfile* ./
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ You can access the main website of the project at [http://consuldemocracy.org](h
|
|||||||
|
|
||||||
**NOTE**: For more detailed instructions check the [docs](https://docs.consuldemocracy.org)
|
**NOTE**: For more detailed instructions check the [docs](https://docs.consuldemocracy.org)
|
||||||
|
|
||||||
Prerequisites: install git, Ruby 3.1.4, CMake, pkg-config, shared-mime-info, Node.js and PostgreSQL (>=9.5).
|
Prerequisites: install git, Ruby 3.1.4, CMake, pkg-config, shared-mime-info, Node.js 18.18.0 and PostgreSQL (>=9.5).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/consuldemocracy/consuldemocracy.git
|
git clone https://github.com/consuldemocracy/consuldemocracy.git
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ Puedes acceder a la página principal del proyecto en [http://consuldemocracy.or
|
|||||||
|
|
||||||
**NOTA**: para unas instrucciones más detalladas consulta la [documentación](https://docs.consuldemocracy.org)
|
**NOTA**: para unas instrucciones más detalladas consulta la [documentación](https://docs.consuldemocracy.org)
|
||||||
|
|
||||||
Prerequisitos: tener instalado git, Ruby 3.1.4, CMake, pkg-config, shared-mime-info, Node.js y PostgreSQL (9.5 o superior).
|
Prerequisitos: tener instalado git, Ruby 3.1.4, CMake, pkg-config, shared-mime-info, Node.js 18.18.0 y PostgreSQL (9.5 o superior).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/consuldemocracy/consuldemocracy.git
|
git clone https://github.com/consuldemocracy/consuldemocracy.git
|
||||||
|
|||||||
@@ -37,6 +37,17 @@ set :keep_releases, 5
|
|||||||
|
|
||||||
set :local_user, ENV["USER"]
|
set :local_user, ENV["USER"]
|
||||||
|
|
||||||
|
set :fnm_path, "$HOME/.fnm"
|
||||||
|
set :fnm_install_command, "curl -fsSL https://fnm.vercel.app/install | " \
|
||||||
|
"bash -s -- --install-dir \"#{fetch(:fnm_path)}\""
|
||||||
|
set :fnm_update_command, "#{fetch(:fnm_install_command)} --skip-shell"
|
||||||
|
set :fnm_setup_command, -> do
|
||||||
|
"export PATH=\"#{fetch(:fnm_path)}:$PATH\" && " \
|
||||||
|
"cd #{release_path} && fnm env > /dev/null && eval \"$(fnm env)\""
|
||||||
|
end
|
||||||
|
set :fnm_install_node_command, -> { "#{fetch(:fnm_setup_command)} && fnm use --install-if-missing" }
|
||||||
|
set :fnm_map_bins, %w[bundle node npm puma pumactl rake yarn]
|
||||||
|
|
||||||
set :puma_conf, "#{release_path}/config/puma/#{fetch(:rails_env)}.rb"
|
set :puma_conf, "#{release_path}/config/puma/#{fetch(:rails_env)}.rb"
|
||||||
|
|
||||||
set :delayed_job_workers, 2
|
set :delayed_job_workers, 2
|
||||||
@@ -49,6 +60,9 @@ namespace :deploy do
|
|||||||
Rake::Task["delayed_job:default"].clear_actions
|
Rake::Task["delayed_job:default"].clear_actions
|
||||||
Rake::Task["puma:smart_restart"].clear_actions
|
Rake::Task["puma:smart_restart"].clear_actions
|
||||||
|
|
||||||
|
after "git:create_release", "map_node_bins"
|
||||||
|
|
||||||
|
after :updating, "install_node"
|
||||||
after :updating, "install_ruby"
|
after :updating, "install_ruby"
|
||||||
|
|
||||||
after "deploy:migrate", "add_new_settings"
|
after "deploy:migrate", "add_new_settings"
|
||||||
@@ -89,6 +103,40 @@ task :install_ruby do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
task :install_node do
|
||||||
|
on roles(:app) do
|
||||||
|
with rails_env: fetch(:rails_env) do
|
||||||
|
begin
|
||||||
|
execute fetch(:fnm_install_node_command)
|
||||||
|
rescue SSHKit::Command::Failed
|
||||||
|
begin
|
||||||
|
execute fetch(:fnm_setup_command)
|
||||||
|
rescue SSHKit::Command::Failed
|
||||||
|
execute fetch(:fnm_install_command)
|
||||||
|
else
|
||||||
|
execute fetch(:fnm_update_command)
|
||||||
|
end
|
||||||
|
|
||||||
|
execute fetch(:fnm_install_node_command)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
task :map_node_bins do
|
||||||
|
on roles(:app) do
|
||||||
|
within release_path do
|
||||||
|
with rails_env: fetch(:rails_env) do
|
||||||
|
prefix = "#{fetch(:fnm_setup_command)} && fnm exec"
|
||||||
|
|
||||||
|
fetch(:fnm_map_bins).each do |command|
|
||||||
|
SSHKit.config.command_map.prefix[command.to_sym].unshift(prefix)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
task :refresh_sitemap do
|
task :refresh_sitemap do
|
||||||
on roles(:app) do
|
on roles(:app) do
|
||||||
within release_path do
|
within release_path do
|
||||||
|
|||||||
Reference in New Issue
Block a user