Several changes to adapt Rails 8

This commit is contained in:
Christoph Haas 2025-04-04 00:58:27 +02:00
parent 7cb02d8a7d
commit 52777edb65
11 changed files with 112 additions and 83 deletions

2
.gitignore vendored
View file

@ -64,3 +64,5 @@ debshots-workspace.code-workspace
!/app/assets/builds/.keep !/app/assets/builds/.keep
/node_modules /node_modules
/config/credentials/development.key

View file

@ -16,7 +16,7 @@ WORKDIR /rails
# Install base packages # Install base packages
RUN apt-get update -qq && \ RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libjemalloc2 libvips libpq-dev nodejs && \ apt-get install --no-install-recommends -y curl libjemalloc2 libvips libpq-dev nodejs telnet && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Set production environment # Set production environment

52
Gemfile
View file

@ -1,23 +1,23 @@
source "https://rubygems.org" source 'https://rubygems.org'
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 8.0.2" gem 'rails', '~> 8.0.2'
# The modern asset pipeline for Rails [https://github.com/rails/propshaft] # The modern asset pipeline for Rails [https://github.com/rails/propshaft]
gem "propshaft" gem 'propshaft'
# Use sqlite3 as the database for Active Record # Use sqlite3 as the database for Active Record
gem "sqlite3", ">= 2.1" gem 'sqlite3', '>= 2.1'
# Use the Puma web server [https://github.com/puma/puma] # Use the Puma web server [https://github.com/puma/puma]
gem "puma", ">= 5.0" gem 'puma', '>= 5.0'
# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails] # Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
gem "jsbundling-rails" gem 'jsbundling-rails'
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
# gem "turbo-rails" # gem "turbo-rails"
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
# gem "stimulus-rails" # gem "stimulus-rails"
# Bundle and process CSS [https://github.com/rails/cssbundling-rails] # Bundle and process CSS [https://github.com/rails/cssbundling-rails]
gem "cssbundling-rails" gem 'cssbundling-rails'
# Build JSON APIs with ease [https://github.com/rails/jbuilder] # Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder" gem 'jbuilder'
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7" # gem "bcrypt", "~> 3.1.7"
@ -26,9 +26,9 @@ gem "jbuilder"
gem 'shrine', '~> 3.0' gem 'shrine', '~> 3.0'
# Use the database-backed adapters for Rails.cache, Active Job, and Action Cable # Use the database-backed adapters for Rails.cache, Active Job, and Action Cable
gem "solid_cache" gem 'solid_cable'
gem "solid_queue" gem 'solid_cache'
gem "solid_cable" gem 'solid_queue'
# To create variants (different sizes) of screenshot images # To create variants (different sizes) of screenshot images
gem 'fastimage' gem 'fastimage'
@ -36,38 +36,38 @@ gem 'image_processing'
gem 'mini_magick' gem 'mini_magick'
# Reduces boot times through caching; required in config/boot.rb # Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false gem 'bootsnap', require: false
# Deploy this application anywhere as a Docker container [https://kamal-deploy.org] # Deploy this application anywhere as a Docker container [https://kamal-deploy.org]
gem "kamal", require: false gem 'kamal', require: false
# Add HTTP asset caching/compression and X-Sendfile acceleration to Puma [https://github.com/basecamp/thruster/] # Add HTTP asset caching/compression and X-Sendfile acceleration to Puma [https://github.com/basecamp/thruster/]
gem "thruster", require: false gem 'thruster', require: false
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2" # gem "image_processing", "~> 1.2"
group :development, :test do group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri windows ], require: "debug/prelude" gem 'debug', platforms: %i[mri windows], require: 'debug/prelude'
# Static analysis for security vulnerabilities [https://brakemanscanner.org/] # Static analysis for security vulnerabilities [https://brakemanscanner.org/]
gem "brakeman", require: false gem 'brakeman', require: false
# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/] # Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false gem 'rubocop-rails-omakase', require: false
end end
group :development do group :development do
# Use console on exceptions pages [https://github.com/rails/web-console] # Use console on exceptions pages [https://github.com/rails/web-console]
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code. # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem "web-console"
gem 'listen', '~> 3.5' gem 'listen', '~> 3.5'
gem 'web-console'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
#gem 'better_errors' # gem 'better_errors'
#gem 'binding_of_caller' # gem 'binding_of_caller'
#gem 'spring' # gem 'spring'
#gem 'spring-watcher-listen', '~> 2.0.0' # gem 'spring-watcher-listen', '~> 2.0.0'
gem 'rails-erd' gem 'rails-erd'
@ -102,8 +102,8 @@ end
group :test do group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara" gem 'capybara'
gem "selenium-webdriver" gem 'selenium-webdriver'
end end
# TODO… https://github.com/galetahub/simple-captcha # TODO… https://github.com/galetahub/simple-captcha
@ -134,7 +134,7 @@ gem 'font-awesome-rails'
# gem "recaptcha", require: "recaptcha/rails" # gem "recaptcha", require: "recaptcha/rails"
#gem 'sprockets-rails' # gem 'sprockets-rails'
# gem "activemodel-serializers-xml" # gem "activemodel-serializers-xml"
@ -159,6 +159,6 @@ gem 'gravtastic'
gem 'bzip2-ffi' gem 'bzip2-ffi'
#gem "dartsass-rails", "~> 0.5.1" # gem "dartsass-rails", "~> 0.5.1"
gem 'rails-healthcheck' gem 'rails-healthcheck'

View file

@ -124,6 +124,9 @@ GEM
responders responders
warden (~> 1.2.3) warden (~> 1.2.3)
dotenv (3.1.7) dotenv (3.1.7)
dotenv-rails (3.1.7)
dotenv (= 3.1.7)
railties (>= 6.1)
down (5.4.2) down (5.4.2)
addressable (~> 2.8) addressable (~> 2.8)
drb (2.2.1) drb (2.2.1)
@ -480,7 +483,7 @@ GEM
activejob (>= 7.2) activejob (>= 7.2)
activerecord (>= 7.2) activerecord (>= 7.2)
railties (>= 7.2) railties (>= 7.2)
solid_queue (1.1.3) solid_queue (1.1.4)
activejob (>= 7.1) activejob (>= 7.1)
activerecord (>= 7.1) activerecord (>= 7.1)
concurrent-ruby (>= 1.3.1) concurrent-ruby (>= 1.3.1)
@ -572,6 +575,7 @@ DEPENDENCIES
cssbundling-rails cssbundling-rails
debug debug
devise devise
dotenv-rails
factory_bot_rails factory_bot_rails
fastimage fastimage
font-awesome-rails font-awesome-rails

BIN
bun.lockb Executable file

Binary file not shown.

View file

@ -2,16 +2,16 @@
# and seeing results in the browser, you must do so from the web console (running inside the dev process), # and seeing results in the browser, you must do so from the web console (running inside the dev process),
# not a terminal started via bin/rails console! Add "console" to any action or any ERB template view # not a terminal started via bin/rails console! Add "console" to any action or any ERB template view
# to make the web console appear. # to make the web console appear.
# development: development:
# adapter: async adapter: async
# test: test:
# adapter: test adapter: test
# production: production:
# adapter: solid_cable adapter: solid_cable
# connects_to: connects_to:
# database: database:
# writing: cable writing: cable
# polling_interval: 0.1.seconds polling_interval: 0.1.seconds
# message_retention: 1.day message_retention: 1.day

16
config/cache.yml Normal file
View file

@ -0,0 +1,16 @@
default: &default
store_options:
# Cap age of oldest cache entry to fulfill retention policies
# max_age: <%= 60.days.to_i %>
max_size: <%= 256.megabytes %>
namespace: <%= Rails.env %>
development:
<<: *default
test:
<<: *default
production:
database: cache
<<: *default

View file

@ -0,0 +1 @@
p4iCDmwxjQ5zC6i3QVNCnlW++oxVLD0AKnflI6lsRBQ1bLTcBA3+8EFI9itIiv7WUJYF+0xGz1bqNq8e9Kk+tEq7C1GVgbuS3xEjG2I0Kt1GbTjvl0aeCd7WHR5xWHlCIXmZVhO/OL4SNc876WYpQqwWRwHkPND0QGAmfWOgy2H14V6LVYh1d7fhPdSYBr4b6oPMMQW6fqAjQ8Oq5TVUznRiRLQfFhAYz2DklMAoASjhAWK39U76JWYqu8VCq08+3V/geXYtQfcsvQ1twq08RFcJbZsCG7slOI8fPW5Oq2dCpw==--mvh3V6FOm1I5+pal--y0AKTyuXuwhXl6iMcT29tw==

View file

@ -1,39 +1,46 @@
# SQLite. Versions 3.8.0 and up are supported. default: &default
# gem install sqlite3 adapter: postgresql
# pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
# Ensure the SQLite 3 gem is defined in your Gemfile timeout: 5000
# gem 'sqlite3'
production:
# Store production database in the storage/ directory, which by default
# is mounted as a persistent Docker volume in config/deploy.yml.
primary:
<<: *default
# database: storage/production.sqlite3
url: <%= Rails.application.credentials.db.url %>
pool: 10
cache:
<<: *default
database: storage/production_cache.sqlite3
migrations_paths: db/cache_migrate
queue:
<<: *default
database: storage/production_queue.sqlite3
migrations_paths: db/queue_migrate
cable:
<<: *default
database: storage/production_cable.sqlite3
migrations_paths: db/cable_migrate
development: development:
<<: *default
adapter: postgresql adapter: postgresql
database: debshots_dev database: debshots_dev
username: debshots_dev username: debshots_dev
password: GonwannEn0 password: GonwannEn0
host: localhost host: localhost
pool: 5
timeout: 5000
# SQLite. Versions 3.8.0 and up are supported.
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
# Warning: The database defined as "test" will be erased and # Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production. # Do not set this db to the same as development or production.
test: test:
adapter: postgresql <<: *default
database: debshots_test database: storage/test.sqlite3
username: debshots_test
password: GonwannEn0
host: localhost
pool: 5
timeout: 5000
# production:
# adapter: postgresql
# database: debshots
# # username: debshots
# # password: GonwannEn0
# # host: localhost
# pool: 10
# timeout: 5000
production:
url: <%= ENV['DATABASE_URL'] %>
adapter: postgresql
pool: 10
timeout: 5000

View file

@ -1,4 +1,4 @@
require "active_support/core_ext/integer/time" require 'active_support/core_ext/integer/time'
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
@ -16,7 +16,7 @@ Rails.application.configure do
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
# Cache assets for far-future expiry since they are all digest stamped. # Cache assets for far-future expiry since they are all digest stamped.
config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" } config.public_file_server.headers = { 'cache-control' => "public, max-age=#{1.year.to_i}" }
# Enable serving of images, stylesheets, and JavaScripts from an asset server. # Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.asset_host = "http://assets.example.com" # config.asset_host = "http://assets.example.com"
@ -34,14 +34,14 @@ Rails.application.configure do
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
# Log to STDOUT with the current request id as a default log tag. # Log to STDOUT with the current request id as a default log tag.
config.log_tags = [ :request_id ] config.log_tags = [:request_id]
config.logger = ActiveSupport::TaggedLogging.logger(STDOUT) config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
# Change to "debug" to log everything (including potentially personally-identifiable information!) # Change to "debug" to log everything (including potentially personally-identifiable information!)
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')
# Prevent health checks from clogging up the logs. # Prevent health checks from clogging up the logs.
config.silence_healthcheck_path = "/up" config.silence_healthcheck_path = '/up'
# Don't log any deprecations. # Don't log any deprecations.
config.active_support.report_deprecations = false config.active_support.report_deprecations = false
@ -53,13 +53,12 @@ Rails.application.configure do
config.active_job.queue_adapter = :solid_queue config.active_job.queue_adapter = :solid_queue
config.solid_queue.connects_to = { database: { writing: :queue } } config.solid_queue.connects_to = { database: { writing: :queue } }
config.action_mailer.smtp_settings = { config.action_mailer.smtp_settings = {
# TODO: make configurable through ENV variables address: Rails.application.credentials.smtp.server,
address: 'dokku2.workaround.org', port: 25,
port: 25,
enable_starttls_auto: false enable_starttls_auto: false
} }
config.action_mailer.default_url_options = { config.action_mailer.default_url_options = {
host: "screenshots.debian.net", host: 'screenshots.debian.net',
protocol: 'https' protocol: 'https'
} }
@ -68,7 +67,7 @@ Rails.application.configure do
# config.action_mailer.raise_delivery_errors = false # config.action_mailer.raise_delivery_errors = false
# Set host to be used by links generated in mailer templates. # Set host to be used by links generated in mailer templates.
config.action_mailer.default_url_options = { host: "example.com" } config.action_mailer.default_url_options = { host: 'example.com' }
# Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit. # Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
# config.action_mailer.smtp_settings = { # config.action_mailer.smtp_settings = {
@ -89,8 +88,8 @@ Rails.application.configure do
config.package_sources = [ config.package_sources = [
{ {
description: 'Debian Unstable (Sid)', type: 'apt', url: 'http://ftp.de.debian.org/debian/dists/sid', description: 'Debian Unstable (Sid)', type: 'apt', url: 'http://ftp.de.debian.org/debian/dists/sid',
architectures: ['i386' ,'amd64'] architectures: %w[i386 amd64]
#components: ['main','restricted','universe','multiverse'] # components: ['main','restricted','universe','multiverse']
} }
] ]
@ -107,7 +106,7 @@ Rails.application.configure do
# Only use :id for inspections in production. # Only use :id for inspections in production.
# Needed (at least) for devise.rb to determine the oauth2 callback URL # Needed (at least) for devise.rb to determine the oauth2 callback URL
config.base_url = ENV['DEBSHOTS_BASE_URL'] || 'http://localhost:3000' config.base_url = ENV['DEBSHOTS_BASE_URL'] || 'http://localhost:3000'
config.active_record.attributes_for_inspect = [ :id ] config.active_record.attributes_for_inspect = [:id]
# Enable DNS rebinding protection and other `Host` header attacks. # Enable DNS rebinding protection and other `Host` header attacks.
# config.hosts = [ # config.hosts = [

6
db/schema.rb generated
View file

@ -10,9 +10,9 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2023_11_26_173151) do ActiveRecord::Schema[8.0].define(version: 2023_11_26_173151) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "pg_catalog.plpgsql"
create_table "action_mailbox_inbound_emails", force: :cascade do |t| create_table "action_mailbox_inbound_emails", force: :cascade do |t|
t.integer "status", default: 0, null: false t.integer "status", default: 0, null: false
@ -87,7 +87,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_26_173151) do
t.datetime "updated_at", precision: nil t.datetime "updated_at", precision: nil
t.integer "visits", default: 0 t.integer "visits", default: 0
t.index "(((setweight(to_tsvector('english'::regconfig, COALESCE((name)::text, ''::text)), 'A'::\"char\") || setweight(to_tsvector('english'::regconfig, COALESCE((description)::text, ''::text)), 'B'::\"char\")) || setweight(to_tsvector('english'::regconfig, COALESCE(long_description, ''::text)), 'C'::\"char\")))", name: "packages_fts", using: :gin t.index "(((setweight(to_tsvector('english'::regconfig, COALESCE((name)::text, ''::text)), 'A'::\"char\") || setweight(to_tsvector('english'::regconfig, COALESCE((description)::text, ''::text)), 'B'::\"char\")) || setweight(to_tsvector('english'::regconfig, COALESCE(long_description, ''::text)), 'C'::\"char\")))", name: "packages_fts", using: :gin
t.index ["name"], name: "packages_name_key", unique: true t.unique_constraint ["name"], name: "packages_name_key"
end end
create_table "screenshots", id: :serial, force: :cascade do |t| create_table "screenshots", id: :serial, force: :cascade do |t|