<!-- TITLE: Ruby And Nodejs In One Image -->
<!-- SUBTITLE: This Dockerfiles allows to create ruby image with nodejs support -->
# Ruby And Nodejs In One
This Dockerfile allows to create ruby image with nodejs support if frontend is maintaned by rails as well. Old fasion approach.
```Dockerfile
FROM ruby:2.4.3-slim-stretch
RUN apt-get update -qq && apt-get install --no-install-recommends -y \
build-essential \
patch \
ruby-dev \
zlib1g-dev \
liblzma-dev \
libxml2 \
libxml2-dev \
libpq-dev \
default-libmysqlclient-dev \
imagemagick \
git \
wget \
gnupg2 \
curl \
nodejs-dev \
node-gyp \
libssl1.0-dev \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch"-pgdg main | tee /etc/apt/sources.list.d/pgdg.list \
&& apt-get update -qq && apt-get install --no-install-recommends --no-upgrade -y \
postgresql-client-11 \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSLO --compressed "https://nodejs.org/dist/v8.17.0/node-v8.17.0-linux-x64.tar.xz" \
&& tar -xJf "node-v8.17.0-linux-x64.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& rm "node-v8.17.0-linux-x64.tar.xz" \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs \
&& npm install -g yarn
WORKDIR /opt/app
COPY ./config/entrypoint.sh /usr/bin/entrypoint.sh
RUN gem install bundler -v 2.0.1
ADD Gemfile* /opt/app/
RUN bundle install
ARG RAILS_ENV
ARG ACTION_CABLE_URL
COPY . /opt/app
RUN yarn install --check-files
RUN RAILS_ENV=$RAILS_ENV bundle exec rake assets:precompile
EXPOSE 9292
```