Created
November 6, 2024 19:06
-
-
Save sephraim/06220cb4327b6be6874af54b3f1a49e1 to your computer and use it in GitHub Desktop.
[Installing node / npm in a Ruby Docker image]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# STAGE 1: Initial setup | |
FROM ruby:2.6.10 as base | |
WORKDIR /app | |
# Use a bundler version that works for both this version of Ruby and (if applicable) the version of Rails being used | |
# NOTE: The RubyGems version that comes with Ruby 2.6 contains a bug and must be updated to v3.2.3. | |
# Use a bundler version that works for both this version of Ruby and (if applicable) the version of Rails being used | |
# NOTE: Bundler v2.4.22 is the last version that works with Ruby 2.6. | |
# RubyGems v3.4.22 is the last version that works with Ruby 2.6. | |
# When Ruby gets upgraded, the version flags can be updated below. | |
ENV BUNDLER_VERSION=2.4.22 | |
ARG RUBYGEMS_VERSION=3.2.3 | |
# NOTE: Pinning solargraph version for now because there is a bug with 0.50.0 | |
ARG SOLARGRAPH_VERSION=0.49.0 | |
# Latest gem versions available for Ruby 2.6 as of 2024-09-30 | |
ARG DEBUG_VERSION=1.8.0 | |
ARG PYGMENTS_VERSION=3.0.0 | |
ARG RUBOCOP_VERSION=1.50.2 | |
ARG SOLARGRAPH_RAILS_VERSION=1.1.0 | |
# Get NodeJS | |
COPY --from=node:20-slim /usr/local/bin /usr/local/bin | |
# Get npm | |
COPY --from=node:20-slim /usr/local/lib/node_modules /usr/local/lib/node_modules | |
# Install missing package(s) | |
RUN apt-get update -qq && apt-get install -yq --no-install-recommends \ | |
wait-for-it=0.0~git20180723-1 \ | |
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
# Prep for gem installation & install gems used for IntelliSense and debugging | |
RUN gem update --system ${RUBYGEMS_VERSION} \ | |
&& gem install bundler:${BUNDLER_VERSION} \ | |
&& gem install pygments.rb:${PYGMENTS_VERSION} \ | |
debug:${DEBUG_VERSION} \ | |
rubocop:${RUBOCOP_VERSION} \ | |
solargraph:${SOLARGRAPH_VERSION} \ | |
solargraph-rails:${SOLARGRAPH_RAILS_VERSION} | |
# Keep container running | |
CMD ["tail", "-f", "/dev/null"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment