Created
December 25, 2021 15:42
-
-
Save RaMin0/d7f1a1e0868f4859044f17c58bfa94a3 to your computer and use it in GitHub Desktop.
A Dockerfile for Ruby on Rails
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
FROM ruby:2.6.3-alpine AS builder | |
ARG RAILS_MASTER_KEY | |
ENV BUNDLE_APP_CONFIG=.bundle \ | |
BUNDLE_PATH=vendor/bundle \ | |
RAILS_ENV=production | |
RUN apk add -U --no-cache build-base \ | |
libxml2-dev \ | |
libxslt-dev \ | |
postgresql-dev \ | |
nodejs \ | |
shared-mime-info \ | |
tzdata && \ | |
gem install rubygems-update \ | |
bundler | |
WORKDIR /usr/src/app | |
RUN bundle config clean true && \ | |
bundle config deployment true && \ | |
bundle config ignore_messages true && \ | |
bundle config jobs 8 && \ | |
bundle config without development:test | |
COPY Gemfile Gemfile.lock ./ | |
RUN bundle config build.sassc --disable-march-tune-native && \ | |
bundle install && \ | |
rm -rf vendor/bundle/ruby/${RUBY_MAJOR}.0/cache/*.gem && \ | |
find vendor/bundle/ruby/${RUBY_MAJOR}.0/gems/ -name *.c -delete && \ | |
find vendor/bundle/ruby/${RUBY_MAJOR}.0/gems/ -name *.o -delete | |
COPY . . | |
RUN bin/rails assets:precompile && \ | |
rm -rf tmp/cache \ | |
vendor/assets && \ | |
ls app/assets | grep -v fonts | xargs -I {} rm -rf app/assets/{} | |
FROM ruby:2.6.3-alpine | |
ENV BUNDLE_APP_CONFIG=.bundle \ | |
BUNDLE_PATH=vendor/bundle \ | |
RAILS_ENV=production \ | |
RAILS_SERVE_STATIC_FILES=true \ | |
RAILS_LOG_TO_STDOUT=true | |
RUN apk add -U --no-cache postgresql-client \ | |
nodejs \ | |
tzdata \ | |
imagemagick && \ | |
gem install rubygems-update \ | |
bundler | |
WORKDIR /usr/src/app | |
COPY --from=builder /usr/src/app . | |
EXPOSE 3000 | |
CMD ["bin/rails", "server", "-b", "0.0.0.0"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment