Upgrated to rails 7.2.0

This commit is contained in:
David Böhm
2024-08-10 13:12:05 +02:00
parent d018d30485
commit 769423c42b
25 changed files with 362 additions and 155 deletions

8
.rubocop.yml Normal file
View File

@@ -0,0 +1,8 @@
# Omakase Ruby styling for Rails
inherit_gem: { rubocop-rails-omakase: rubocop.yml }
# Overwrite or add rules to create your own house style
#
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
# Layout/SpaceInsideArrayLiteralBrackets:
# Enabled: false

View File

@@ -1,25 +1,34 @@
# syntax = docker/dockerfile:1 # 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 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 # Rails app lives here
WORKDIR /rails WORKDIR /rails
# Install base packages
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libjemalloc2 libsqlite3-0 libvips && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Set production environment # Set production environment
ENV RAILS_ENV="production" \ ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \ BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/usr/local/bundle" \ BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development" BUNDLE_WITHOUT="development"
# Throw-away build stage to reduce size of final image # Throw-away build stage to reduce size of final image
FROM base as build FROM base AS build
# Install packages needed to build gems # Install packages needed to build gems
RUN apt-get update -qq && \ RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git libvips pkg-config apt-get install --no-install-recommends -y build-essential git pkg-config && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Install application gems # Install application gems
COPY Gemfile Gemfile.lock ./ COPY Gemfile Gemfile.lock ./
@@ -37,22 +46,20 @@ RUN bundle exec bootsnap precompile app/ lib/
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
# Final stage for app image # Final stage for app image
FROM base FROM base
# Install packages needed for deployment
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libsqlite3-0 libvips && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Copy built artifacts: gems, application # 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 COPY --from=build /rails /rails
# Run and own only the runtime files as a non-root user for security # 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 chown -R rails:rails db log storage tmp
USER rails:rails USER 1000:1000
# Entrypoint prepares the database. # Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"] ENTRYPOINT ["/rails/bin/docker-entrypoint"]

29
Gemfile
View File

@@ -1,34 +1,23 @@
source 'https://rubygems.org' source 'https://rubygems.org'
ruby '3.3.4'
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem 'rails', '~> 7.1.3', '>= 7.1.3.4' gem 'rails', '~> 7.2.0', '>= 7.2.0'
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem 'sprockets-rails' gem 'sprockets-rails'
# Use sqlite3 as the database for Active Record # Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4' gem 'sqlite3', '~> 1.4'
# 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'
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] # Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem 'importmap-rails' gem 'importmap-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'
# Use Tailwind CSS [https://github.com/rails/tailwindcss-rails] # Use Tailwind CSS [https://github.com/rails/tailwindcss-rails]
gem 'tailwindcss-rails' gem 'tailwindcss-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 Redis adapter to run Action Cable in production # Use Redis adapter to run Action Cable in production
gem 'redis', '>= 4.0.1' gem 'redis', '>= 4.0.1'
@@ -45,11 +34,19 @@ gem 'tzinfo-data', platforms: %i[windows jruby]
gem 'bootsnap', require: false gem 'bootsnap', 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] gem 'debug', platforms: %i[mri windows], require: "debug/prelude"
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
gem "brakeman", require: false
# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false
# Usefull to seed some meaningful entries
gem 'faker', '~> 3.4' gem 'faker', '~> 3.4'
end end
@@ -70,6 +67,8 @@ group :test do
gem 'selenium-webdriver' gem 'selenium-webdriver'
end end
# Used to display svg files inline (helper icon)
gem 'inline_svg', '~> 1.9' gem 'inline_svg', '~> 1.9'
gem "pdf-reader", "~> 2.12" # Used by pdf_analyzer for extracting pageformats
gem 'pdf-reader', '~> 2.12'

View File

@@ -2,88 +2,87 @@ GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
Ascii85 (1.1.1) Ascii85 (1.1.1)
actioncable (7.1.3.4) actioncable (7.2.0)
actionpack (= 7.1.3.4) actionpack (= 7.2.0)
activesupport (= 7.1.3.4) activesupport (= 7.2.0)
nio4r (~> 2.0) nio4r (~> 2.0)
websocket-driver (>= 0.6.1) websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6) zeitwerk (~> 2.6)
actionmailbox (7.1.3.4) actionmailbox (7.2.0)
actionpack (= 7.1.3.4) actionpack (= 7.2.0)
activejob (= 7.1.3.4) activejob (= 7.2.0)
activerecord (= 7.1.3.4) activerecord (= 7.2.0)
activestorage (= 7.1.3.4) activestorage (= 7.2.0)
activesupport (= 7.1.3.4) activesupport (= 7.2.0)
mail (>= 2.7.1) mail (>= 2.8.0)
net-imap actionmailer (7.2.0)
net-pop actionpack (= 7.2.0)
net-smtp actionview (= 7.2.0)
actionmailer (7.1.3.4) activejob (= 7.2.0)
actionpack (= 7.1.3.4) activesupport (= 7.2.0)
actionview (= 7.1.3.4) mail (>= 2.8.0)
activejob (= 7.1.3.4)
activesupport (= 7.1.3.4)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
actionpack (7.1.3.4) actionpack (7.2.0)
actionview (= 7.1.3.4) actionview (= 7.2.0)
activesupport (= 7.1.3.4) activesupport (= 7.2.0)
nokogiri (>= 1.8.5) nokogiri (>= 1.8.5)
racc racc
rack (>= 2.2.4) rack (>= 2.2.4, < 3.2)
rack-session (>= 1.0.1) rack-session (>= 1.0.1)
rack-test (>= 0.6.3) rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6) rails-html-sanitizer (~> 1.6)
actiontext (7.1.3.4) useragent (~> 0.16)
actionpack (= 7.1.3.4) actiontext (7.2.0)
activerecord (= 7.1.3.4) actionpack (= 7.2.0)
activestorage (= 7.1.3.4) activerecord (= 7.2.0)
activesupport (= 7.1.3.4) activestorage (= 7.2.0)
activesupport (= 7.2.0)
globalid (>= 0.6.0) globalid (>= 0.6.0)
nokogiri (>= 1.8.5) nokogiri (>= 1.8.5)
actionview (7.1.3.4) actionview (7.2.0)
activesupport (= 7.1.3.4) activesupport (= 7.2.0)
builder (~> 3.1) builder (~> 3.1)
erubi (~> 1.11) erubi (~> 1.11)
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6) rails-html-sanitizer (~> 1.6)
activejob (7.1.3.4) activejob (7.2.0)
activesupport (= 7.1.3.4) activesupport (= 7.2.0)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (7.1.3.4) activemodel (7.2.0)
activesupport (= 7.1.3.4) activesupport (= 7.2.0)
activerecord (7.1.3.4) activerecord (7.2.0)
activemodel (= 7.1.3.4) activemodel (= 7.2.0)
activesupport (= 7.1.3.4) activesupport (= 7.2.0)
timeout (>= 0.4.0) timeout (>= 0.4.0)
activestorage (7.1.3.4) activestorage (7.2.0)
actionpack (= 7.1.3.4) actionpack (= 7.2.0)
activejob (= 7.1.3.4) activejob (= 7.2.0)
activerecord (= 7.1.3.4) activerecord (= 7.2.0)
activesupport (= 7.1.3.4) activesupport (= 7.2.0)
marcel (~> 1.0) marcel (~> 1.0)
activesupport (7.1.3.4) activesupport (7.2.0)
base64 base64
bigdecimal bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5) connection_pool (>= 2.2.5)
drb drb
i18n (>= 1.6, < 2) i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1) minitest (>= 5.1)
mutex_m securerandom (>= 0.3)
tzinfo (~> 2.0) tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7) addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0) public_suffix (>= 2.0.2, < 7.0)
afm (0.2.2) afm (0.2.2)
ast (2.4.2)
base64 (0.2.0) base64 (0.2.0)
bigdecimal (3.1.8) bigdecimal (3.1.8)
bindex (0.8.1) bindex (0.8.1)
bootsnap (1.18.3) bootsnap (1.18.4)
msgpack (~> 1.2) msgpack (~> 1.2)
brakeman (6.1.2)
racc
builder (3.3.0) builder (3.3.0)
capybara (3.40.0) capybara (3.40.0)
addressable addressable
@@ -133,6 +132,8 @@ GEM
jbuilder (2.12.0) jbuilder (2.12.0)
actionview (>= 5.0.0) actionview (>= 5.0.0)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
json (2.7.2)
language_server-protocol (3.17.0.3)
logger (1.6.0) logger (1.6.0)
loofah (2.22.0) loofah (2.22.0)
crass (~> 1.0.2) crass (~> 1.0.2)
@@ -148,7 +149,6 @@ GEM
mini_mime (1.1.5) mini_mime (1.1.5)
minitest (5.24.1) minitest (5.24.1)
msgpack (1.7.2) msgpack (1.7.2)
mutex_m (0.2.0)
net-imap (0.4.14) net-imap (0.4.14)
date date
net-protocol net-protocol
@@ -171,6 +171,10 @@ GEM
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux) nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
parallel (1.26.1)
parser (3.3.4.2)
ast (~> 2.4.1)
racc
pdf-reader (2.12.0) pdf-reader (2.12.0)
Ascii85 (~> 1.0) Ascii85 (~> 1.0)
afm (~> 0.2.1) afm (~> 0.2.1)
@@ -191,20 +195,20 @@ GEM
rackup (2.1.0) rackup (2.1.0)
rack (>= 3) rack (>= 3)
webrick (~> 1.8) webrick (~> 1.8)
rails (7.1.3.4) rails (7.2.0)
actioncable (= 7.1.3.4) actioncable (= 7.2.0)
actionmailbox (= 7.1.3.4) actionmailbox (= 7.2.0)
actionmailer (= 7.1.3.4) actionmailer (= 7.2.0)
actionpack (= 7.1.3.4) actionpack (= 7.2.0)
actiontext (= 7.1.3.4) actiontext (= 7.2.0)
actionview (= 7.1.3.4) actionview (= 7.2.0)
activejob (= 7.1.3.4) activejob (= 7.2.0)
activemodel (= 7.1.3.4) activemodel (= 7.2.0)
activerecord (= 7.1.3.4) activerecord (= 7.2.0)
activestorage (= 7.1.3.4) activestorage (= 7.2.0)
activesupport (= 7.1.3.4) activesupport (= 7.2.0)
bundler (>= 1.15.0) bundler (>= 1.15.0)
railties (= 7.1.3.4) railties (= 7.2.0)
rails-dom-testing (2.2.0) rails-dom-testing (2.2.0)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
minitest minitest
@@ -212,14 +216,15 @@ GEM
rails-html-sanitizer (1.6.0) rails-html-sanitizer (1.6.0)
loofah (~> 2.21) loofah (~> 2.21)
nokogiri (~> 1.14) nokogiri (~> 1.14)
railties (7.1.3.4) railties (7.2.0)
actionpack (= 7.1.3.4) actionpack (= 7.2.0)
activesupport (= 7.1.3.4) activesupport (= 7.2.0)
irb irb (~> 1.13)
rackup (>= 1.0.0) rackup (>= 1.0.0)
rake (>= 12.2) rake (>= 12.2)
thor (~> 1.0, >= 1.2.2) thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6) zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1) rake (13.2.1)
rdoc (6.7.0) rdoc (6.7.0)
psych (>= 4.0.0) psych (>= 4.0.0)
@@ -232,11 +237,42 @@ GEM
io-console (~> 0.5) io-console (~> 0.5)
rexml (3.3.4) rexml (3.3.4)
strscan strscan
rubocop (1.65.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.0)
parser (>= 3.3.1.0)
rubocop-minitest (0.35.1)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-performance (1.21.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.25.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails-omakase (1.0.0)
rubocop
rubocop-minitest
rubocop-performance
rubocop-rails
ruby-progressbar (1.13.0)
ruby-rc4 (0.1.5) ruby-rc4 (0.1.5)
ruby-vips (2.2.2) ruby-vips (2.2.2)
ffi (~> 1.12) ffi (~> 1.12)
logger logger
rubyzip (2.3.2) rubyzip (2.3.2)
securerandom (0.3.1)
selenium-webdriver (4.23.0) selenium-webdriver (4.23.0)
base64 (~> 0.2) base64 (~> 0.2)
logger (~> 1.4) logger (~> 1.4)
@@ -260,17 +296,17 @@ GEM
railties (>= 6.0.0) railties (>= 6.0.0)
stringio (3.1.1) stringio (3.1.1)
strscan (3.1.0) strscan (3.1.0)
tailwindcss-rails (2.6.5) tailwindcss-rails (2.7.2)
railties (>= 7.0.0) railties (>= 7.0.0)
tailwindcss-rails (2.6.5-aarch64-linux) tailwindcss-rails (2.7.2-aarch64-linux)
railties (>= 7.0.0) railties (>= 7.0.0)
tailwindcss-rails (2.6.5-arm-linux) tailwindcss-rails (2.7.2-arm-linux)
railties (>= 7.0.0) railties (>= 7.0.0)
tailwindcss-rails (2.6.5-arm64-darwin) tailwindcss-rails (2.7.2-arm64-darwin)
railties (>= 7.0.0) railties (>= 7.0.0)
tailwindcss-rails (2.6.5-x86_64-darwin) tailwindcss-rails (2.7.2-x86_64-darwin)
railties (>= 7.0.0) railties (>= 7.0.0)
tailwindcss-rails (2.6.5-x86_64-linux) tailwindcss-rails (2.7.2-x86_64-linux)
railties (>= 7.0.0) railties (>= 7.0.0)
thor (1.3.1) thor (1.3.1)
timeout (0.4.1) timeout (0.4.1)
@@ -282,6 +318,8 @@ GEM
railties (>= 6.0.0) railties (>= 6.0.0)
tzinfo (2.0.6) tzinfo (2.0.6)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
useragent (0.16.10)
web-console (4.2.1) web-console (4.2.1)
actionview (>= 6.0.0) actionview (>= 6.0.0)
activemodel (>= 6.0.0) activemodel (>= 6.0.0)
@@ -306,6 +344,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
bootsnap bootsnap
brakeman
capybara capybara
debug debug
faker (~> 3.4) faker (~> 3.4)
@@ -315,8 +354,9 @@ DEPENDENCIES
jbuilder jbuilder
pdf-reader (~> 2.12) pdf-reader (~> 2.12)
puma (>= 5.0) puma (>= 5.0)
rails (~> 7.1.3, >= 7.1.3.4) rails (~> 7.2.0, >= 7.2.0)
redis (>= 4.0.1) redis (>= 4.0.1)
rubocop-rails-omakase
selenium-webdriver selenium-webdriver
sprockets-rails sprockets-rails
sqlite3 (~> 1.4) sqlite3 (~> 1.4)
@@ -326,8 +366,5 @@ DEPENDENCIES
tzinfo-data tzinfo-data
web-console web-console
RUBY VERSION
ruby 3.3.4p94
BUNDLED WITH BUNDLED WITH
2.5.16 2.5.16

View File

@@ -1 +0,0 @@
<svg height="8" viewBox="0 0 8 8" width="8" xmlns="http://www.w3.org/2000/svg"><path d="m4 0c-1.1 0-2 1.12-2 2.5s.9 2.5 2 2.5 2-1.12 2-2.5-.9-2.5-2-2.5zm-2.09 5c-1.06.05-1.91.92-1.91 2v1h8v-1c0-1.08-.84-1.95-1.91-2-.54.61-1.28 1-2.09 1s-1.55-.39-2.09-1z"/></svg>

Before

Width:  |  Height:  |  Size: 262 B

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M26 6V1H6v5H2v12h4v5l8 8h12V18h4V6h-4zM8 3h16v3H8V3zm7 26v-7H8v-8h16v15h-9z"/></svg>

Before

Width:  |  Height:  |  Size: 153 B

View File

@@ -1,2 +1,4 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
allow_browser versions: :modern
end end

View File

@@ -0,0 +1,22 @@
{
"name": "Plottservice",
"icons": [
{
"src": "/icon.png",
"type": "image/png",
"sizes": "512x512"
},
{
"src": "/icon.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "maskable"
}
],
"start_url": "/",
"display": "standalone",
"scope": "/",
"description": "Plottservice.",
"theme_color": "red",
"background_color": "red"
}

View File

@@ -0,0 +1,26 @@
// Add a service worker for processing Web Push notifications:
//
// self.addEventListener("push", async (event) => {
// const { title, options } = await event.data.json()
// event.waitUntil(self.registration.showNotification(title, options))
// })
//
// self.addEventListener("notificationclick", function(event) {
// event.notification.close()
// event.waitUntil(
// clients.matchAll({ type: "window" }).then((clientList) => {
// for (let i = 0; i < clientList.length; i++) {
// let client = clientList[i]
// let clientPath = (new URL(client.url)).pathname
//
// if (clientPath == event.notification.data.path && "focus" in client) {
// return client.focus()
// }
// }
//
// if (clients.openWindow) {
// return clients.openWindow(event.notification.data.path)
// }
// })
// )
// })

7
bin/brakeman Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
ARGV.unshift("--ensure-latest")
load Gem.bin_path("brakeman", "brakeman")

View File

@@ -1,5 +1,10 @@
#!/bin/bash -e #!/bin/bash -e
# Enable jemalloc for reduced memory usage and latency.
if [ -z "${LD_PRELOAD+x}" ] && [ -f /usr/lib/*/libjemalloc.so.2 ]; then
export LD_PRELOAD="$(echo /usr/lib/*/libjemalloc.so.2)"
fi
# If running the rails server then create or migrate existing database # If running the rails server then create or migrate existing database
if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then
./bin/rails db:prepare ./bin/rails db:prepare

8
bin/rubocop Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
# explicit rubocop config increases performance slightly while avoiding config confusion.
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
load Gem.bin_path("rubocop", "rubocop")

View File

@@ -1,8 +1,8 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require "fileutils" require "fileutils"
# path to your application root.
APP_ROOT = File.expand_path("..", __dir__) APP_ROOT = File.expand_path("..", __dir__)
APP_NAME = "plottservice"
def system!(*args) def system!(*args)
system(*args, exception: true) system(*args, exception: true)
@@ -30,4 +30,8 @@ FileUtils.chdir APP_ROOT do
puts "\n== Restarting application server ==" puts "\n== Restarting application server =="
system! "bin/rails restart" system! "bin/rails restart"
# puts "\n== Configuring puma-dev =="
# system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
# system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
end end

View File

@@ -1,6 +1,6 @@
require_relative 'boot' require_relative "boot"
require 'rails/all' require "rails/all"
# Require the gems listed in Gemfile, including any gems # Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production. # you've limited to :test, :development, or :production.
@@ -9,7 +9,7 @@ Bundler.require(*Rails.groups)
module Plottservice module Plottservice
class Application < Rails::Application class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version. # Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.1 config.load_defaults 7.2
# Please, add to the `ignore` list any other `lib` subdirectories that do # Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded. # not contain `.rb` files, or that should not be reloaded or eager loaded.

View File

@@ -14,7 +14,7 @@ Rails.application.configure do
# Show full error reports. # Show full error reports.
config.consider_all_requests_local = true config.consider_all_requests_local = true
# Enable server timing # Enable server timing.
config.server_timing = true config.server_timing = true
# Enable/disable caching. By default caching is disabled. # Enable/disable caching. By default caching is disabled.
@@ -24,9 +24,7 @@ Rails.application.configure do
config.action_controller.enable_fragment_cache_logging = true config.action_controller.enable_fragment_cache_logging = true
config.cache_store = :memory_store config.cache_store = :memory_store
config.public_file_server.headers = { config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
"Cache-Control" => "public, max-age=#{2.days.to_i}"
}
else else
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
@@ -39,8 +37,12 @@ Rails.application.configure do
# Don't care if the mailer can't send. # Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false config.action_mailer.raise_delivery_errors = false
# Disable caching for Action Mailer templates even if Action Controller
# caching is enabled.
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
# Print deprecation notices to the Rails logger. # Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log config.active_support.deprecation = :log
@@ -66,11 +68,14 @@ Rails.application.configure do
# config.i18n.raise_on_missing_translations = true # config.i18n.raise_on_missing_translations = true
# Annotate rendered view with file names. # Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true config.action_view.annotate_rendered_view_with_filenames = true
# Uncomment if you wish to allow Action Cable access from any origin. # Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true # config.action_cable.disable_request_forgery_protection = true
# Raise error when a before_action's only/except options reference missing actions # Raise error when a before_action's only/except options reference missing actions.
config.action_controller.raise_on_missing_callback_actions = true config.action_controller.raise_on_missing_callback_actions = true
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
# config.generators.apply_rubocop_autocorrect_after_generate!
end end

View File

@@ -51,6 +51,9 @@ Rails.application.configure do
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true config.force_ssl = true
# Skip http-to-https redirect for the default health check endpoint.
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
# Log to STDOUT by default # Log to STDOUT by default
config.logger = ActiveSupport::Logger.new(STDOUT) config.logger = ActiveSupport::Logger.new(STDOUT)
.tap { |logger| logger.formatter = ::Logger::Formatter.new } .tap { |logger| logger.formatter = ::Logger::Formatter.new }
@@ -71,6 +74,8 @@ Rails.application.configure do
# config.active_job.queue_adapter = :resque # config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "plottservice_production" # config.active_job.queue_name_prefix = "plottservice_production"
# Disable caching for Action Mailer templates even if Action Controller
# caching is enabled.
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors. # Ignore bad email addresses and do not raise email delivery errors.

View File

@@ -18,10 +18,7 @@ Rails.application.configure do
config.eager_load = ENV["CI"].present? config.eager_load = ENV["CI"].present?
# Configure public file server for tests with Cache-Control for performance. # Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
}
# Show full error reports and disable caching. # Show full error reports and disable caching.
config.consider_all_requests_local = true config.consider_all_requests_local = true
@@ -37,6 +34,8 @@ Rails.application.configure do
# Store uploaded files on the local file system in a temporary directory. # Store uploaded files on the local file system in a temporary directory.
config.active_storage.service = :test config.active_storage.service = :test
# Disable caching for Action Mailer templates even if Action Controller
# caching is enabled.
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world. # Tell Action Mailer not to deliver emails to the real world.
@@ -44,6 +43,10 @@ Rails.application.configure do
# ActionMailer::Base.deliveries array. # ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test config.action_mailer.delivery_method = :test
# Unlike controllers, the mailer instance doesn't have any context about the
# incoming request so you'll need to provide the :host parameter yourself.
config.action_mailer.default_url_options = { host: "www.example.com" }
# Print deprecation notices to the stderr. # Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr config.active_support.deprecation = :stderr
@@ -59,6 +62,6 @@ Rails.application.configure do
# Annotate rendered view with file names. # Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true # config.action_view.annotate_rendered_view_with_filenames = true
# Raise error when a before_action's only/except options reference missing actions # Raise error when a before_action's only/except options reference missing actions.
config.action_controller.raise_on_missing_callback_actions = true config.action_controller.raise_on_missing_callback_actions = true
end end

View File

@@ -4,5 +4,5 @@
# Use this to limit dissemination of sensitive information. # Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
Rails.application.config.filter_parameters += [ Rails.application.config.filter_parameters += [
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
] ]

View File

@@ -2,34 +2,32 @@
# are invoked here are part of Puma's configuration DSL. For more information # are invoked here are part of Puma's configuration DSL. For more information
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
# Puma can serve each request in a thread from an internal thread pool. # Puma starts a configurable number of processes (workers) and each process
# The `threads` method setting takes two numbers: a minimum and maximum. # serves each request in a thread from an internal thread pool.
# Any libraries that use thread pools should be configured to match #
# the maximum value specified for Puma. Default is set to 5 threads for minimum # The ideal number of threads per worker depends both on how much time the
# and maximum; this matches the default thread size of Active Record. # application spends waiting for IO operations and on how much you wish to
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } # to prioritize throughput over latency.
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } #
threads min_threads_count, max_threads_count # As a rule of thumb, increasing the number of threads will increase how much
# traffic a given process can handle (throughput), but due to CRuby's
# Specifies that the worker count should equal the number of processors in production. # Global VM Lock (GVL) it has diminishing returns and will degrade the
if ENV["RAILS_ENV"] == "production" # response time (latency) of the application.
require "concurrent-ruby" #
worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count }) # The default is set to 3 threads as it's deemed a decent compromise between
workers worker_count if worker_count > 1 # throughput and latency for the average Rails application.
end #
# Any libraries that use a connection pool or another resource pool should
# Specifies the `worker_timeout` threshold that Puma will use to wait before # be configured to provide at least as many connections as the number of
# terminating a worker in development environments. # threads. This includes Active Record's `pool` parameter in `database.yml`.
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000. # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
port ENV.fetch("PORT") { 3000 } port ENV.fetch("PORT", 3000)
# Specifies the `environment` that Puma will run in.
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
# Allow puma to be restarted by `bin/rails restart` command. # Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart plugin :tmp_restart
# Only use a pidfile when requested
pidfile ENV["PIDFILE"] if ENV["PIDFILE"]

View File

@@ -1,15 +1,19 @@
Rails.application.routes.draw do Rails.application.routes.draw do
resources :jobs do resources :jobs do
member do member do
patch 'cancel' patch "cancel"
end end
end end
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
# Can be used by load balancers and uptime monitors to verify that the app is live. # Can be used by load balancers and uptime monitors to verify that the app is live.
get 'up' => 'rails/health#show', as: :rails_health_check get "up" => "rails/health#show", as: :rails_health_check
# Render dynamic PWA files from app/views/pwa/*
get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker
get "manifest" => "rails/pwa#manifest", as: :pwa_manifest
# Defines the root path route ("/") # Defines the root path route ("/")
root 'jobs#index' root "jobs#index"
end end

View File

@@ -52,6 +52,6 @@ class CreateActiveStorageTables < ActiveRecord::Migration[7.0]
setting = config.options[config.orm][:primary_key_type] setting = config.options[config.orm][:primary_key_type]
primary_key_type = setting || :primary_key primary_key_type = setting || :primary_key
foreign_key_type = setting || :bigint foreign_key_type = setting || :bigint
[primary_key_type, foreign_key_type] [ primary_key_type, foreign_key_type ]
end end
end end

2
db/schema.rb generated
View File

@@ -10,7 +10,7 @@
# #
# 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.1].define(version: 2024_08_01_153403) do ActiveRecord::Schema[7.1].define(version: 2024_08_10_095256) do
create_table "active_storage_attachments", force: :cascade do |t| create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false t.string "name", null: false
t.string "record_type", null: false t.string "record_type", null: false

View File

@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html>
<head>
<title>Your browser is not supported (406)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
.rails-default-error-page {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
.rails-default-error-page div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
.rails-default-error-page div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
.rails-default-error-page h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
.rails-default-error-page div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body class="rails-default-error-page">
<!-- This file lives in public/406-unsupported-browser.html -->
<div class="dialog">
<div>
<h1>Your browser is not supported.</h1>
<p>Please upgrade your browser to continue.</p>
</div>
</div>
</body>
</html>

BIN
public/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

3
public/icon.svg Normal file
View File

@@ -0,0 +1,3 @@
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="red"/>
</svg>

After

Width:  |  Height:  |  Size: 121 B