Skip to content

Instantly share code, notes, and snippets.

@niteshpurohit
Created December 4, 2019 16:17
Show Gist options
  • Save niteshpurohit/b88f177253740615a4213e97e81ef67c to your computer and use it in GitHub Desktop.
Save niteshpurohit/b88f177253740615a4213e97e81ef67c to your computer and use it in GitHub Desktop.
Docker
FROM ruby:2.6.3-alpine3.9
RUN apk update && apk add libpq nodejs
ENV RAILS_ROOT /app
RUN mkdir -p $RAILS_ROOT
ENV BUNDLER_VERSION 2.0.2
WORKDIR $RAILS_ROOT
RUN echo 'gem: --no-ri --no-rdoc' > ~/.gemrc
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN apk add --virtual build-dependencies build-base gcc wget git postgresql-dev \
&& gem install bundler -v 2.0.2 \
&& bundle install --jobs 20 --retry 5 \
&& apk del build-dependencies \
&& rm -rf /var/cache/apk/*
RUN gem install foreman
COPY . /app
#set ENV
ARG RAILS_MASTER_KEY
ARG RAILS_ENV
ARG RACK_ENV
ENV RAILS_LOG_TO_STDOUT=true
ENV RAILS_MASTER_KEY=$RAILS_MASTER_KEY
ENV RAILS_ENV=$RAILS_ENV
ENV RACK_ENV=$RACK_ENV
RUN apk add --virtual build-dependencies nodejs \
&& RAILS_ENV=${RAILS_ENV} bundle exec rails assets:clobber \
&& RAILS_ENV=${RAILS_ENV} bundle exec rails assets:precompile \
&& apk del build-dependencies \
&& rm -rf /var/cache/apk/*
EXPOSE 5000
CMD ["foreman", "start", "web=1,worker=1"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment