Dockerfile 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. FROM ruby:2.6.3-alpine as builder
  2. # Add git to clone Rspec repositories and build-base to compile nokogiri gem
  3. # Additionally, we need to set timezone information
  4. RUN apk add --update git build-base postgresql-dev yarn tzdata && \
  5. cp /usr/share/zoneinfo/UTC /etc/localtime && \
  6. echo "UTC" > /etc/timezone
  7. # Make an app directory, just like Heroku.
  8. RUN mkdir /app
  9. WORKDIR /app
  10. # Copying the Gemfile separately allows the image to be cached.
  11. # These steps are not rerun unless the Gemfile or Gemfile.lock is changed.
  12. COPY Gemfile Gemfile.lock /app/
  13. RUN bundle install --jobs 4 --retry 5 --without development test
  14. # Again, copy seperately so we can cache this step.
  15. COPY package.json yarn.lock /app/
  16. RUN yarn install
  17. # Copy our app over now
  18. COPY . /app
  19. # And compile our assets
  20. RUN rails assets:precompile && \
  21. rm -rf node_modules tmp log
  22. FROM ruby:2.6.3-alpine
  23. RUN apk add --update postgresql-dev tzdata && \
  24. cp /usr/share/zoneinfo/UTC /etc/localtime && \
  25. echo "UTC" > /etc/timezone
  26. # Make an app directory, just like Heroku.
  27. RUN mkdir /app
  28. WORKDIR /app
  29. # Grab everything from the builder
  30. COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
  31. COPY --from=builder /app/ /app/
  32. # Copy the docker configurations over
  33. COPY config/database.yml.docker config/database.yml
  34. # Run the server
  35. EXPOSE 3000
  36. CMD rails server -p 3000