11# syntax = docker/dockerfile:1
22
3- # Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
43ARG RUBY_VERSION=3.3.1
5- FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
4+ FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim AS base
65
7- # Rails app lives here
86WORKDIR /rails
97
10- # Set production environment
118ENV RAILS_ENV="development" \
129 BUNDLE_DEPLOYMENT="1" \
13- BUNDLE_PATH="/usr/local/bundle" \
14- BUNDLE_WITHOUT="development"
10+ BUNDLE_PATH="/usr/local/bundle"
1511
12+ FROM base AS build
1613
17- # Throw-away build stage to reduce size of final image
18- FROM base as build
19-
20- # Install packages needed to build gems
2114RUN apt-get update -qq && \
2215 apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config
2316
24- # Install application gems
2517COPY Gemfile Gemfile.lock ./
2618RUN bundle install && \
2719 rm -rf ~/.bundle/ "${BUNDLE_PATH}" /ruby/*/cache "${BUNDLE_PATH}" /ruby/*/bundler/gems/*/.git && \
2820 bundle exec bootsnap precompile --gemfile
2921
30- # Copy application code
3122COPY . .
3223
33- # Precompile bootsnap code for faster boot times
3424RUN bundle exec bootsnap precompile app/ lib/
3525
3626
37- # Final stage for app image
3827FROM base
3928
40- # Install packages needed for deployment
4129RUN apt-get update -qq && \
4230 apt-get install --no-install-recommends -y curl libvips postgresql-client redis-tools && \
4331 rm -rf /var/lib/apt/lists /var/cache/apt/archives
@@ -51,9 +39,8 @@ RUN useradd rails --create-home --shell /bin/bash && \
5139 chown -R rails:rails db log storage tmp
5240USER rails:rails
5341
54- # Entrypoint prepares the database.
5542ENTRYPOINT ["/rails/bin/docker-entrypoint" ]
5643
5744# Start the server by default, this can be overwritten at runtime
5845EXPOSE 3009
59- CMD ["./bin/rails" , "server" ]
46+ CMD ["./bin/rails" , "server" ]
0 commit comments