Skip to content

Commit

Permalink
Upgrade from Rails 7.1 to Rails 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
binos30 committed Aug 13, 2024
1 parent 8d6a1f2 commit f226e7b
Show file tree
Hide file tree
Showing 27 changed files with 1,373 additions and 1,183 deletions.
17 changes: 12 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Ignore git directory.
/.git/
/.gitignore

# Ignore bundler config.
/.bundle
Expand Down Expand Up @@ -36,6 +37,17 @@
!/app/assets/builds/.keep
/public/assets

# Ignore CI service files.
/.github

# Ignore development files
/.devcontainer

# Ignore Docker-related files
/.dockerignore
/Dockerfile*

/.husky
/docs/

# Ignore yarn files
Expand All @@ -57,11 +69,6 @@ yarn-debug.log*

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
ruby-version: .ruby-version
bundler-cache: true

- name: Scan for security vulnerabilities in Ruby dependencies
- name: Scan for common Rails security vulnerabilities using static analysis
run: bin/brakeman --no-pager

lint:
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Temporary files generated by your text editor or operating system
# belong in git's global ignore instead:
# `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore`

# Ignore bundler config.
/.bundle
Expand Down
894 changes: 0 additions & 894 deletions .yarn/releases/yarn-4.3.1.cjs

This file was deleted.

925 changes: 925 additions & 0 deletions .yarn/releases/yarn-4.4.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.3.1.cjs
yarnPath: .yarn/releases/yarn-4.4.0.cjs
36 changes: 22 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
# syntax = docker/dockerfile:1

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
# docker build -t my-app .
# docker run -d -p 80:80 -p 443:443 --name my-app -e RAILS_MASTER_KEY=<value from config/master.key> my-app

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
ARG RUBY_VERSION=3.3.4
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim AS base
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base

# Rails app lives here
WORKDIR /rails

# Install base packages
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libjemalloc2 libvips postgresql-client && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Set production environment
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development:test"


# Throw-away build stage to reduce size of final image
FROM base AS build

# Install packages needed to build gems and node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential curl git libpq-dev libvips node-gyp pkg-config python-is-python3
apt-get install --no-install-recommends -y build-essential git libpq-dev node-gyp pkg-config python-is-python3 && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Install JavaScript dependencies
ARG NODE_VERSION=20.16.0
Expand All @@ -29,13 +38,13 @@ RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz
rm -rf /tmp/node-build-master

# Install application gems
COPY .ruby-version Gemfile Gemfile.lock ./
COPY Gemfile Gemfile.lock ./
RUN bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
bundle exec bootsnap precompile --gemfile

# Install yarn
ARG YARN_VERSION=4.3.1
ARG YARN_VERSION=4.4.0
RUN corepack enable && \
corepack prepare yarn@${YARN_VERSION} --activate

Expand All @@ -53,22 +62,21 @@ RUN bundle exec bootsnap precompile app/ lib/
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile


RUN rm -rf node_modules


# Final stage for app image
FROM base

# Install packages needed for deployment
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libvips postgresql-client && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Copy built artifacts: gems, application
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
COPY --from=build /rails /rails

# Run and own only the runtime files as a non-root user for security
RUN useradd rails --create-home --shell /bin/bash && \
RUN groupadd --system --gid 1000 rails && \
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
chown -R rails:rails db log storage tmp
USER rails:rails
USER 1000:1000

# Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
Expand Down
12 changes: 5 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

source "https://rubygems.org"

ruby file: ".ruby-version"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.3.4"
gem "rails", "~> 7.2.0"

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"
Expand Down Expand Up @@ -99,10 +97,10 @@ group :development, :test do
# Code style checking for Rails-related RSpec files [https://github.com/rubocop/rubocop-rspec_rails]
gem "rubocop-rspec_rails", require: false
# Interact with the Ruby syntax tree [https://github.com/ruby-syntax-tree/syntax_tree]
gem "syntax_tree"
gem "syntax_tree", require: false
# Provides a comprehensive suite of tools for Ruby programming: intellisense, diagnostics, inline documentation,
# and type checking [https://github.com/castwide/solargraph]
gem "solargraph"
gem "solargraph", require: false
end

group :development do
Expand All @@ -117,10 +115,10 @@ group :development do

## Code Formatting & Linting
# Configurable tool for analyzing Slim templates [https://github.com/sds/slim-lint]
gem "slim_lint"
gem "slim_lint", require: false
# A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates
# [https://github.com/threedaymonk/htmlbeautifier]
gem "htmlbeautifier"
gem "htmlbeautifier", require: false

# Optimize queries
gem "bullet"
Expand Down
Loading

0 comments on commit f226e7b

Please sign in to comment.