Created
July 5, 2020 11:32
-
-
Save dewey/071731f7e4fe65dc15bdba296ee8730d to your computer and use it in GitHub Desktop.
This file contains hidden or 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.7-alpine AS build-env | |
ARG RAILS_ROOT=/app | |
ARG BUILD_PACKAGES="build-base curl-dev git" | |
ARG DEV_PACKAGES="postgresql-dev yaml-dev zlib-dev nodejs yarn" | |
ARG RUBY_PACKAGES="tzdata" | |
ENV RAILS_ENV=production | |
ENV NODE_ENV=production | |
ENV BUNDLE_APP_CONFIG="$RAILS_ROOT/.bundle" | |
WORKDIR $RAILS_ROOT | |
RUN apk update \ | |
&& apk upgrade \ | |
&& apk add --update --no-cache $BUILD_PACKAGES $DEV_PACKAGES $RUBY_PACKAGES | |
COPY Gemfile* package.json yarn.lock ./ | |
COPY Gemfile Gemfile.lock $RAILS_ROOT/ | |
RUN bundle config --global frozen 1 \ | |
&& bundle install --without development:test:assets -j4 --retry 3 --path=vendor/bundle \ | |
&& rm -rf vendor/bundle/ruby/2.7.0/cache/*.gem \ | |
&& find vendor/bundle/ruby/2.7.0/gems/ -name "*.c" -delete \ | |
&& find vendor/bundle/ruby/2.7.0/gems/ -name "*.o" -delete | |
RUN yarn install --production | |
COPY . . | |
RUN bin/rails webpacker:compile | |
RUN bin/rails assets:precompile | |
RUN rm -rf node_modules tmp/cache vendor/assets spec | |
FROM ruby:2.7-alpine | |
ARG RAILS_ROOT=/app | |
ARG PACKAGES="tzdata postgresql-client nodejs bash vips-dev vips" | |
ENV RAILS_ENV=production | |
ENV BUNDLE_APP_CONFIG="$RAILS_ROOT/.bundle" | |
WORKDIR $RAILS_ROOT | |
# install packages | |
RUN apk update \ | |
&& apk upgrade \ | |
&& apk add --update --no-cache $PACKAGES | |
COPY --from=build-env $RAILS_ROOT $RAILS_ROOT | |
EXPOSE 3000 | |
ENV PATH="/app/bin:${PATH}" | |
CMD ["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