Dockerfile 974 B

123456789101112131415161718192021222324252627282930313233343536
  1. FROM ruby:2.7.1-alpine as Builder
  2. RUN apk add --update --no-cache build-base nodejs yarn mariadb-dev tzdata imagemagick nano
  3. WORKDIR /home/rails/app
  4. COPY Gemfile* ./
  5. RUN bundle config --global frozen 1 \
  6. && bundle install --without development test \
  7. && rm -rf /usr/local/bundle/cache/*.gem \
  8. && find /usr/local/bundle/gems/ -name "*.c" -delete \
  9. && find /usr/local/bundle/gems/ -name "*.o" -delete
  10. COPY package.json yarn.lock ./
  11. RUN yarn install
  12. COPY . .
  13. RUN RAILS_ENV=production bundle exec rails assets:precompile
  14. RUN rm -rf node_modules tmp/cache
  15. FROM ruby:2.6.6-alpine
  16. # Add Alpine packages
  17. RUN apk add --update --no-cache mariadb-dev imagemagick tzdata
  18. RUN adduser rails --gecos "" --disabled-password
  19. USER rails
  20. COPY --from=Builder /usr/local/bundle/ /usr/local/bundle/
  21. COPY --from=Builder --chown=1000:1000 /home/rails/app /home/rails/app
  22. WORKDIR /home/rails/app
  23. ENV RAILS_ENV=production
  24. COPY entrypoint.sh /entrypoint.sh
  25. ENTRYPOINT ["/entrypoint.sh"]