Dockerfile 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. # Copy the docker configurations over
  20. COPY config/database.yml.docker config/database.yml
  21. # And compile our assets
  22. RUN rails assets:precompile
  23. FROM ruby:2.6.3-alpine
  24. RUN apk add --update postgresql-dev tzdata && \
  25. cp /usr/share/zoneinfo/UTC /etc/localtime && \
  26. echo "UTC" > /etc/timezone
  27. # Make an app directory, just like Heroku.
  28. RUN mkdir /app
  29. WORKDIR /app
  30. # Grab everything from the builder
  31. COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
  32. COPY --from=builder /app/ /app/
  33. # Run the server
  34. EXPOSE 3000
  35. CMD rails server -p 3000