Skip to content

Instantly share code, notes, and snippets.

@ardeearam
Last active April 12, 2019 03:23
Show Gist options
  • Save ardeearam/d50d2293b7c2b3e8a3eec46f680dc60f to your computer and use it in GitHub Desktop.
Save ardeearam/d50d2293b7c2b3e8a3eec46f680dc60f to your computer and use it in GitHub Desktop.
Ready to use Rails 5.2 + Ruby 2.6
# Usage: `docker build --build-arg RAILS_MASTER_KEY=$RAILS_MASTER_KEY -t myapp .
FROM ruby:2.6.2-slim
ARG RAILS_MASTER_KEY
# Install NodeJS
RUN apt-get update \
&& apt-get install -y apt-transport-https curl gnupg2 \
&& curl --silent --show-error --location https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
&& echo "deb https://deb.nodesource.com/node_6.x/ stretch main" > /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install -y nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install Yarn
RUN curl --silent --show-error --location https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get install -y yarn \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install essentials for Bundle Install
RUN apt-get update \
&& apt-get install -y libxslt-dev libxml2-dev zlib1g-dev build-essential
# Install PostgreSQL support
RUN apt-get update \
&& apt-get install -y libpq-dev
WORKDIR /app
ENV RAILS_ENV=production
ENV NODE_ENV=production
COPY Gemfile Gemfile.lock /app/
RUN gem install bundler && bundle install --jobs 4 --without development:test --deployment
COPY . /app/
RUN RAILS_MASTER_KEY=$RAILS_MASTER_KEY bin/rails assets:precompile
CMD ["/app/bin/rails", "server", "-b", "0.0.0.0", "--port", "3000"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment