Skip to content

Commit 4b9f9f4

Browse files
authored
Merge pull request #130 from JudahSan/FT/rails8
Upgrade to Rails 8 from the previous version
2 parents 1c779c8 + c894a02 commit 4b9f9f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1076
-630
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
2-
ARG RUBY_VERSION=3.4.1
2+
ARG RUBY_VERSION=3.4.4
33
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION

Dockerfile

Lines changed: 80 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,88 @@
1-
FROM ruby:3.4.1-alpine
1+
# syntax=docker/dockerfile:1
2+
# Multi-stage Dockerfile for Rails 8 app with Ruby 3.4.4
23

3-
ENV APP_PATH /var/app
4-
ENV BUNDLE_VERSION 2.3.1
5-
ENV BUNDLE_PATH /usr/local/bundle/gems
6-
ENV TMP_PATH /tmp/
7-
ENV RAILS_LOG_TO_STDOUT true
8-
ENV RAILS_PORT 3000
4+
ARG RUBY_VERSION=3.4.4
95

10-
# Install system dependencies
11-
RUN apt-get update && apt-get install -y \
12-
build-essential \
13-
git \
14-
postgresql-client \
15-
libxml2-dev \
16-
libxslt-dev \
17-
nodejs \
18-
npm \
6+
# Base image with Ruby and system libs
7+
FROM ruby:${RUBY_VERSION}-slim AS base
8+
ENV APP_PATH=/rails \
9+
RAILS_LOG_TO_STDOUT=true \
10+
RAILS_SERVE_STATIC_FILES=true
11+
WORKDIR ${APP_PATH}
12+
13+
# Install runtime deps
14+
RUN apt-get update -qq && \
15+
apt-get install --no-install-recommends -y \
16+
curl \
17+
ca-certificates \
18+
libpq5 \
1919
imagemagick \
20+
libvips \
2021
tzdata \
21-
less \
22-
&& rm -rf /var/lib/apt/lists/* \
23-
&& mkdir -p $APP_PATH
22+
git \
23+
postgresql-client && \
24+
rm -rf /var/lib/apt/lists/*
25+
26+
# Builder stage for gems, node modules, and assets
27+
FROM base AS build
28+
29+
# Build toolchain and headers
30+
RUN apt-get update -qq && apt-get install --no-install-recommends -y \
31+
build-essential \
32+
libpq-dev \
33+
pkg-config \
34+
python3 \
35+
node-gyp \
36+
libyaml-dev && rm -rf /var/lib/apt/lists/*
37+
38+
# Install Node.js and Yarn (Node 20 LTS)
39+
ARG NODE_VERSION=20
40+
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \
41+
apt-get install -y nodejs && \
42+
npm install -g [email protected]
43+
44+
45+
# Bundle install
46+
COPY Gemfile Gemfile.lock ./
47+
ENV BUNDLE_PATH=/usr/local/bundle \
48+
BUNDLE_DEPLOYMENT=1
49+
ARG BUNDLER_VERSION=2.7.2
50+
RUN gem update --system --no-document && \
51+
gem install -N bundler -v ${BUNDLER_VERSION} && \
52+
bundle install && \
53+
bundle exec bootsnap precompile --gemfile && \
54+
rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git
55+
56+
# JS deps
57+
COPY package.json yarn.lock ./
58+
RUN yarn install --frozen-lockfile
59+
60+
# App code
61+
COPY . .
62+
63+
# Precompile bootsnap and assets
64+
RUN bundle exec bootsnap precompile app/ lib/
65+
# If using sprockets, keep assets:precompile; js/cssbundling will run via rake task
66+
RUN ./bin/rails assets:precompile
67+
68+
# Final image
69+
FROM base AS app
70+
71+
# Copy built artifacts
72+
COPY --from=build /usr/local/bundle /usr/local/bundle
2473

25-
RUN gem install bundler --version "$BUNDLE_VERSION" \
26-
&& rm -rf $GEM_HOME/cache/*
74+
# Set bundle and gem paths for runtime
75+
ENV BUNDLE_PATH=/usr/local/bundle \
76+
GEM_HOME=/usr/local/bundle \
77+
BUNDLE_DEPLOYMENT=1
2778

28-
# navigate to app directory
29-
WORKDIR $APP_PATH
79+
# Non-root user
80+
RUN useradd -u 1000 -m rails && chown -R rails:rails /rails /usr/local/bundle
81+
USER rails
3082

31-
EXPOSE $RAILS_PORT
83+
# Copy app code
84+
COPY --from=build --chown=1000:1000 /rails /rails
3285

33-
ENTRYPOINT [ "bundle", "exec" ]
86+
EXPOSE 3000
87+
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
88+
CMD ["./bin/rails", "server", "-b", "0.0.0.0", "-p", "3000"]

Gemfile

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@ gem 'jbuilder' # Build JSON APIs with ease [https://github.com/rails/jbuilder]
1818
gem 'jsbundling-rails' # Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
1919
gem 'mini_magick', '~> 4.12'
2020
# Motor Admin allows you to deploy a no-code admin panel for your application in less than a minute
21-
gem 'motor-admin', '~> 0.4.7'
22-
gem 'pg', '~> 1.1' # Use postgresql as the database for Active Record
21+
gem 'motor-admin', '>= 0.4.30'
22+
gem 'pg', '~> 1.5' # Use postgresql as the database for Active Record
2323
gem 'premailer-rails', '~> 1.12' # This gem is a drop in solution for styling HTML emails with CSS
2424
gem 'puma', '~> 6.0' # Use the Puma web server [https://github.com/puma/puma]
25-
gem 'rails', '~> 7.2.2.1' # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
25+
gem 'rails', '~> 8.0' # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
2626
# Pagination
2727
gem 'pagy', '~> 9.4.0'
2828
# gem 'kaminari'
2929
# gem 'kaminari-tailwind'
30-
gem 'redis', '~> 4.0' # Use Redis adapter to run Action Cable in production
30+
gem 'redis', '~> 5.0' # Use Redis adapter to run Action Cable in production
3131
# An ActionMailer adapter to send email using SendGrid's HTTPS Web API (instead of SMTP).
32-
gem 'rack-attack' # Rack middleware for blocking & throttling abusive requests
32+
gem 'rack-attack', '>= 6.7' # Rack middleware for blocking & throttling abusive requests (Rack 3 compatible)
3333
gem 'sendgrid-actionmailer', '~> 3.2'
34-
gem 'simple_form', '~> 5.1' # Gem to pimp up forms
34+
gem 'simple_form', '~> 5.3' # Gem to pimp up forms
3535
gem 'sitemap_generator' # A dynamic sitemap generator gem for the Ruby on Rails framework
36-
gem 'sprockets-rails' # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
37-
gem 'stimulus-rails' # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
38-
gem 'turbo-rails' # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
36+
gem 'sprockets-rails', '>= 3.5' # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
37+
gem 'stimulus-rails', '>= 1.3' # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
38+
gem 'turbo-rails', '>= 2.0' # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
3939
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
4040
gem 'rails_cloudflare_turnstile'
4141
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
@@ -62,10 +62,8 @@ group :development do
6262
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
6363
# gem "spring"
6464

65-
gem 'annotate', '~> 3.2', '>= 3.2.0'
66-
6765
# Capistrano - deployment gems
68-
gem 'capistrano', '~> 3.11'
66+
gem 'capistrano', '~> 3.19'
6967
gem 'capistrano-asdf'
7068
gem 'capistrano-passenger', '~> 0.2.0'
7169
gem 'capistrano-rails', '~> 1.4'

0 commit comments

Comments
 (0)