package.json has no build step.
Fortunately, there are alternatives.
Nodesource
We can start with the Node.js recommendation.build-essentials
later results in failures.
merging images
Another approach is merge files from the official node and ruby images.volta
A third approach is to use a version manager. Much like how Ruby has rvm, rbenv, chruby and others, Node has several. Volta is one written in Rust that works well for this task. A minimal Dockerfile making use of Volta would look like the following:Node as the base
A fourth option is to flip the script: start with node as the base and add ruby. Debian bullseye includes Ruby 2.7 which ended support on March 31, 2023.COPY --from=gems line as the location of the
gem directory has changed.
This results in the smallest image yet, at 424 MB. The downside is that you
get a dated Ruby.
Variations are possible, including copying Ruby from the base docker image
or using a Ruby version manager such as
rvm,
rbenv, or
chruby.
Example application
Below is an example application that demonstrates React.js working with esbuild. Start by adding the following lines immediately before theFROM base line:
COPY <<-"EOF" config/routes.rb with the following:
- A counter component which extracts attributes from the root element and displays a counter which increments every second.
- A time controller and view which includes an SVG image and sets HTML attributes containing the Ruby, Rails, and Node versions.