Skip to content

Commit 03e0bd5

Browse files
authored
Merge pull request rails#47461 from Shopify/docker-node-latest-lts
Use an actual version in .node-version
2 parents 7048f30 + e8638c9 commit 03e0bd5

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

railties/lib/rails/generators/app_base.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class AppBase < Base # :nodoc:
1515
include Database
1616
include AppName
1717

18+
NODE_TLS_VERSION = "18.15.0"
19+
1820
attr_accessor :rails_template
1921
add_shebang_option!
2022

@@ -458,10 +460,14 @@ def using_node?
458460
options[:javascript] && options[:javascript] != "importmap"
459461
end
460462

461-
def dockerfile_node_version
462-
using_node? and `node --version`[/\d+\.\d+\.\d+/]
463-
rescue
464-
"lts"
463+
def node_version
464+
if using_node?
465+
ENV.fetch("NODE_VERSION") do
466+
`node --version`[/\d+\.\d+\.\d+/]
467+
rescue
468+
NODE_TLS_VERSION
469+
end
470+
end
465471
end
466472

467473
def dockerfile_yarn_version

railties/lib/rails/generators/rails/app/templates/Dockerfile.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN apt-get update -qq && \
2323

2424
<% if using_node? -%>
2525
# Install JavaScript dependencies
26-
ARG NODE_VERSION=<%= dockerfile_node_version %>
26+
ARG NODE_VERSION=<%= node_version %>
2727
ARG YARN_VERSION=<%= dockerfile_yarn_version %>
2828
ENV PATH=/usr/local/node/bin:$PATH
2929
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<%= ENV["NODE_VERSION"] || dockerfile_node_version %>
1+
<%= node_version %>

0 commit comments

Comments
 (0)