Depend on a specific version of Node.js
We're choosing version 18 because if offers support for SSL 3, just like Ruby 3.1 does. Note we're symlinking a .nvmrc file as well, in order to make it compatible with NVM. While the .nvmrc and .node-version files use different formats, they both support the syntax we're using to define the version. The code to install Node.js in the Dockerfile is a simplification of the code in the Rails Dockerfile template [1]. [1] https://github.com/rails/rails/blob/04c97aec8a/railties/lib/rails/generators/rails/app/templates/Dockerfile.tt#L25
This commit is contained in:
10
Dockerfile
10
Dockerfile
@@ -13,7 +13,6 @@ RUN apt-get update -qq \
|
||||
libpq-dev \
|
||||
libxss1 \
|
||||
memcached \
|
||||
nodejs \
|
||||
pkg-config \
|
||||
postgresql-client \
|
||||
shared-mime-info \
|
||||
@@ -28,7 +27,7 @@ RUN adduser --shell /bin/bash --disabled-password --gecos "" consul \
|
||||
&& adduser consul sudo \
|
||||
&& 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
|
||||
|
||||
# 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
|
||||
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.
|
||||
# (the src likely changed and we don't want to invalidate Docker's cache too early)
|
||||
COPY Gemfile* ./
|
||||
|
||||
Reference in New Issue
Block a user