Skip to content

Commit 050730c

Browse files
authored
Merge pull request #44 from jeremiaheb/rails-7-1
Rails 7.1
2 parents c064286 + 9d09f22 commit 050730c

15 files changed

+2566
-134
lines changed

.dockerignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
2+
3+
# Ignore git directory.
4+
/.git/
5+
6+
# Ignore bundler config.
7+
/.bundle
8+
9+
# Ignore all environment files (except templates).
10+
/.env*
11+
!/.env*.erb
12+
13+
# Ignore all default key files.
14+
/config/master.key
15+
/config/credentials/*.key
16+
17+
# Ignore all logfiles and tempfiles.
18+
/log/*
19+
/tmp/*
20+
!/log/.keep
21+
!/tmp/.keep
22+
23+
# Ignore pidfiles, but keep the directory.
24+
/tmp/pids/*
25+
!/tmp/pids/.keep
26+
27+
# Ignore storage (uploaded files in development and any SQLite databases).
28+
/storage/*
29+
!/storage/.keep
30+
/tmp/storage/*
31+
!/tmp/storage/.keep
32+
33+
# Ignore assets.
34+
/node_modules/
35+
/app/assets/builds/*
36+
!/app/assets/builds/.keep
37+
/public/assets

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# See https://git-scm.com/docs/gitattributes for more about git attribute files.
2+
3+
# Mark the database schema as having been generated.
4+
db/schema.rb linguist-generated
5+
6+
# Mark any vendored files as having been vendored.
7+
vendor/* linguist-vendored
8+
config/credentials/*.yml.enc diff=rails_credentials
9+
config/credentials.yml.enc diff=rails_credentials

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
# Ignore bundler config.
88
/.bundle
99

10-
# Ignore the default SQLite database.
11-
/db/*.sqlite3
12-
/db/*.sqlite3-*
10+
# Ignore all environment files (except templates).
11+
/.env*
12+
!/.env*.erb
1313

1414
# Ignore all logfiles and tempfiles.
1515
/log/*
@@ -22,7 +22,7 @@
2222
!/tmp/pids/
2323
!/tmp/pids/.keep
2424

25-
# Ignore uploaded files in development.
25+
# Ignore storage (uploaded files in development and any SQLite databases).
2626
/storage/*
2727
!/storage/.keep
2828
/tmp/storage/*

Dockerfile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# syntax = docker/dockerfile:1
2+
3+
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
4+
ARG RUBY_VERSION=3.2.6
5+
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
6+
7+
# Rails app lives here
8+
WORKDIR /rails
9+
10+
# Set production environment
11+
ENV RAILS_ENV="production" \
12+
BUNDLE_DEPLOYMENT="1" \
13+
BUNDLE_PATH="/usr/local/bundle" \
14+
BUNDLE_WITHOUT="development"
15+
16+
17+
# Throw-away build stage to reduce size of final image
18+
FROM base as build
19+
20+
# Install packages needed to build gems
21+
RUN apt-get update -qq && \
22+
apt-get install --no-install-recommends -y build-essential git libvips pkg-config
23+
24+
# Install application gems
25+
COPY Gemfile Gemfile.lock ./
26+
RUN bundle install && \
27+
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
28+
bundle exec bootsnap precompile --gemfile
29+
30+
# Copy application code
31+
COPY . .
32+
33+
# Precompile bootsnap code for faster boot times
34+
RUN bundle exec bootsnap precompile app/ lib/
35+
36+
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
37+
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
38+
39+
40+
# Final stage for app image
41+
FROM base
42+
43+
# Install packages needed for deployment
44+
RUN apt-get update -qq && \
45+
apt-get install --no-install-recommends -y curl libsqlite3-0 libvips && \
46+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
47+
48+
# Copy built artifacts: gems, application
49+
COPY --from=build /usr/local/bundle /usr/local/bundle
50+
COPY --from=build /rails /rails
51+
52+
# Run and own only the runtime files as a non-root user for security
53+
RUN useradd rails --create-home --shell /bin/bash && \
54+
chown -R rails:rails db log storage tmp
55+
USER rails:rails
56+
57+
# Entrypoint prepares the database.
58+
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
59+
60+
# Start the server by default, this can be overwritten at runtime
61+
EXPOSE 3000
62+
CMD ["./bin/rails", "server"]

Gemfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
source "https://rubygems.org"
22

3-
ruby "3.0.7"
4-
gem "rails", "~> 7.0.8", ">= 7.0.8.7"
3+
ruby "3.2.6"
4+
gem "rails", "~> 7.1.5", ">= 7.1.5.1"
55

66
gem 'pg', '~> 1.5', '>= 1.5.9'
77

8-
gem 'puma', '~> 5.0'
8+
gem "puma", ">= 5.0"
9+
10+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
11+
gem "tzinfo-data", platforms: %i[ windows jruby ]
912

1013
gem 'sass-rails', '~> 5.0'
1114
gem 'coffee-rails'
@@ -40,7 +43,7 @@ group :development, :test do
4043
gem 'factory_girl_rails'
4144

4245
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
43-
gem "debug", platforms: %i[ mri mingw x64_mingw ]
46+
gem "debug", platforms: %i[ mri windows ]
4447

4548
# TODO: Upgrade to faker 3.x after upgrade to Ruby 3 is complete
4649
gem 'faker', '~> 3.4', '>= 3.4.2'
@@ -58,14 +61,11 @@ group :development do
5861
end
5962

6063
group :test do
61-
# Adds support for Capybara system testing and selenium driver
64+
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
6265
gem 'capybara'
6366
gem 'selenium-webdriver'
6467
end
6568

6669
group :production do
6770
gem 'rails_12factor'
6871
end
69-
70-
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
71-
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

0 commit comments

Comments
 (0)