├── log
└── .keep
├── storage
└── .keep
├── tmp
├── .keep
└── pids
│ └── .keep
├── vendor
└── .keep
├── lib
├── assets
│ └── .keep
└── tasks
│ └── .keep
├── public
├── favicon.ico
├── apple-touch-icon.png
├── apple-touch-icon-precomposed.png
├── robots.txt
├── 500.html
├── 422.html
└── 404.html
├── app
├── assets
│ ├── images
│ │ └── .keep
│ ├── config
│ │ └── manifest.js
│ └── stylesheets
│ │ └── application.css
├── models
│ ├── concerns
│ │ └── .keep
│ └── application_record.rb
├── controllers
│ ├── concerns
│ │ └── .keep
│ └── application_controller.rb
├── helpers
│ └── application_helper.rb
├── channels
│ └── application_cable
│ │ ├── channel.rb
│ │ └── connection.rb
├── mailers
│ └── application_mailer.rb
├── jobs
│ ├── sentry_job.rb
│ └── application_job.rb
├── javascript
│ ├── channels
│ │ ├── index.js
│ │ └── consumer.js
│ └── packs
│ │ └── application.js
└── views
│ └── layouts
│ ├── mailer.html.erb
│ └── application.html.erb
├── .browserslistrc
├── .ruby-version
├── .rspec
├── spec
├── support
│ ├── active_job.rb
│ └── factory_bot.rb
├── factory_bot_spec.rb
├── rails_helper.rb
└── spec_helper.rb
├── bin
├── docker
│ ├── bash
│ ├── yarn
│ ├── bundle
│ ├── start
│ ├── entrypoints
│ │ ├── wait-for-postgres.sh
│ │ └── wait-for-web.sh
│ ├── setup
│ └── prepare-to-start-rails
├── rake
├── rails
├── heroku
│ └── release-tasks.sh
├── webpack
├── webpack-dev-server
├── yarn
├── setup
└── bundle
├── config
├── webpack
│ ├── environment.js
│ ├── test.js
│ ├── production.js
│ └── development.js
├── environment.rb
├── initializers
│ ├── opinionated_defaults
│ │ ├── sentry_raven.rb
│ │ ├── generators.rb
│ │ ├── logger.rb
│ │ ├── default_url_options.rb
│ │ ├── locale.rb
│ │ ├── web_console.rb
│ │ ├── lograge.rb
│ │ ├── assets.rb
│ │ ├── sidekiq.rb
│ │ └── action_mailer.rb
│ ├── mime_types.rb
│ ├── application_controller_renderer.rb
│ ├── cookies_serializer.rb
│ ├── filter_parameter_logging.rb
│ ├── permissions_policy.rb
│ ├── wrap_parameters.rb
│ ├── backtrace_silencers.rb
│ ├── assets.rb
│ ├── inflections.rb
│ └── content_security_policy.rb
├── schedule.yml
├── boot.rb
├── cable.yml
├── routes.rb
├── application.rb
├── sidekiq.yml
├── locales
│ └── en.yml
├── storage.yml
├── puma.rb
├── webpacker.yml
├── environments
│ ├── test.rb
│ ├── development.rb
│ └── production.rb
└── database.yml
├── config.ru
├── Rakefile
├── postcss.config.js
├── .gitattributes
├── db
├── seeds.rb
└── schema.rb
├── .github
├── workflows
│ ├── standard.yml
│ ├── linters.yml
│ └── tests.yml
└── dependabot.yml.sample
├── Procfile
├── package.json
├── .env.example
├── .dockerignore
├── .gitignore
├── docker-compose.ci.yml
├── Gemfile
├── app.json
├── babel.config.js
├── docker-compose.yml
├── README.md
├── Dockerfile
└── Gemfile.lock
/log/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/storage/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tmp/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/assets/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/tasks/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tmp/pids/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/assets/images/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.browserslistrc:
--------------------------------------------------------------------------------
1 | defaults
2 |
--------------------------------------------------------------------------------
/.ruby-version:
--------------------------------------------------------------------------------
1 | ruby-3.0.1
2 |
--------------------------------------------------------------------------------
/app/models/concerns/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.rspec:
--------------------------------------------------------------------------------
1 | --require spec_helper
2 |
--------------------------------------------------------------------------------
/app/controllers/concerns/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/apple-touch-icon-precomposed.png:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/spec/support/active_job.rb:
--------------------------------------------------------------------------------
1 | ActiveJob::Base.queue_adapter = :test
2 |
--------------------------------------------------------------------------------
/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | end
3 |
--------------------------------------------------------------------------------
/bin/docker/bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | docker-compose run --rm web bash
5 |
--------------------------------------------------------------------------------
/bin/docker/yarn:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | exec docker-compose --rm web yarn "$@"
5 |
--------------------------------------------------------------------------------
/bin/docker/bundle:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | exec docker-compose --rm web bundle "$@"
5 |
--------------------------------------------------------------------------------
/app/assets/config/manifest.js:
--------------------------------------------------------------------------------
1 | //= link_tree ../images
2 | //= link_directory ../stylesheets .css
3 |
--------------------------------------------------------------------------------
/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | end
3 |
--------------------------------------------------------------------------------
/bin/docker/start:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | echo "== Turning on Docker =="
5 | docker-compose up
6 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require_relative "../config/boot"
3 | require "rake"
4 | Rake.application.run
5 |
--------------------------------------------------------------------------------
/spec/support/factory_bot.rb:
--------------------------------------------------------------------------------
1 | RSpec.configure do |config|
2 | config.include FactoryBot::Syntax::Methods
3 | end
4 |
--------------------------------------------------------------------------------
/config/webpack/environment.js:
--------------------------------------------------------------------------------
1 | const { environment } = require('@rails/webpacker')
2 |
3 | module.exports = environment
4 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2 |
--------------------------------------------------------------------------------
/spec/factory_bot_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | describe FactoryBot do
4 | it { FactoryBot.lint traits: true }
5 | end
6 |
--------------------------------------------------------------------------------
/app/channels/application_cable/channel.rb:
--------------------------------------------------------------------------------
1 | module ApplicationCable
2 | class Channel < ActionCable::Channel::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/channels/application_cable/connection.rb:
--------------------------------------------------------------------------------
1 | module ApplicationCable
2 | class Connection < ActionCable::Connection::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/mailers/application_mailer.rb:
--------------------------------------------------------------------------------
1 | class ApplicationMailer < ActionMailer::Base
2 | default from: "from@example.com"
3 | layout "mailer"
4 | end
5 |
--------------------------------------------------------------------------------
/app/jobs/sentry_job.rb:
--------------------------------------------------------------------------------
1 | class SentryJob < ApplicationJob
2 | queue_as :sentry
3 |
4 | def perform(event)
5 | Raven.send_event(event)
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | APP_PATH = File.expand_path('../config/application', __dir__)
3 | require_relative "../config/boot"
4 | require "rails/commands"
5 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require_relative "application"
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require_relative "config/environment"
4 |
5 | run Rails.application
6 | Rails.application.load_server
7 |
--------------------------------------------------------------------------------
/config/webpack/test.js:
--------------------------------------------------------------------------------
1 | process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2 |
3 | const environment = require('./environment')
4 |
5 | module.exports = environment.toWebpackConfig()
6 |
--------------------------------------------------------------------------------
/config/initializers/opinionated_defaults/sentry_raven.rb:
--------------------------------------------------------------------------------
1 | if defined?(Raven)
2 | Raven.configure do |config|
3 | config.async = ->(event) { SentryJob.perform_later(event) }
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/config/webpack/production.js:
--------------------------------------------------------------------------------
1 | process.env.NODE_ENV = process.env.NODE_ENV || 'production'
2 |
3 | const environment = require('./environment')
4 |
5 | module.exports = environment.toWebpackConfig()
6 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/config/webpack/development.js:
--------------------------------------------------------------------------------
1 | process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2 |
3 | const environment = require('./environment')
4 |
5 | module.exports = environment.toWebpackConfig()
6 |
--------------------------------------------------------------------------------
/config/schedule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Add any task you'd like to run a specific times.
3 | #
4 | # Daily Usage Summary:
5 | # :cron: 0 6 * * *
6 | # :class: Slack::UsageSummaryJob
7 | # :queue: slack__usage_summary
8 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
2 |
3 | require "bundler/setup" # Set up gems listed in the Gemfile.
4 | require "bootsnap/setup" # Speed up boot time by caching expensive operations.
5 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | # Add your own tasks in files placed in lib/tasks ending in .rake,
2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3 |
4 | require_relative "config/application"
5 |
6 | Rails.application.load_tasks
7 |
--------------------------------------------------------------------------------
/app/javascript/channels/index.js:
--------------------------------------------------------------------------------
1 | // Load all the channels within this directory and all subdirectories.
2 | // Channel files must be named *_channel.js.
3 |
4 | const channels = require.context('.', true, /_channel\.js$/)
5 | channels.keys().forEach(channels)
6 |
--------------------------------------------------------------------------------
/config/initializers/application_controller_renderer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # ActiveSupport::Reloader.to_prepare do
4 | # ApplicationController.renderer.defaults.merge!(
5 | # http_host: 'example.org',
6 | # https: false
7 | # )
8 | # end
9 |
--------------------------------------------------------------------------------
/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: [
3 | require('postcss-import'),
4 | require('postcss-flexbugs-fixes'),
5 | require('postcss-preset-env')({
6 | autoprefixer: {
7 | flexbox: 'no-2009'
8 | },
9 | stage: 3
10 | })
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Specify a serializer for the signed and encrypted cookie jars.
4 | # Valid options are :json, :marshal, and :hybrid.
5 | Rails.application.config.action_dispatch.cookies_serializer = :json
6 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += %i[
5 | passw secret token _key crypt salt certificate otp ssn
6 | ]
7 |
--------------------------------------------------------------------------------
/app/jobs/application_job.rb:
--------------------------------------------------------------------------------
1 | class ApplicationJob < ActiveJob::Base
2 | # Automatically retry jobs that encountered a deadlock
3 | # retry_on ActiveRecord::Deadlocked
4 |
5 | # Most jobs are safe to ignore if the underlying records are no longer available
6 | # discard_on ActiveJob::DeserializationError
7 | end
8 |
--------------------------------------------------------------------------------
/app/views/layouts/mailer.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 | <%= yield %>
12 |
13 |
14 |
--------------------------------------------------------------------------------
/config/cable.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: redis
3 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
4 |
5 | test:
6 | adapter: test
7 |
8 | production:
9 | adapter: redis
10 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
11 | channel_prefix: App_production
12 |
--------------------------------------------------------------------------------
/app/javascript/channels/consumer.js:
--------------------------------------------------------------------------------
1 | // Action Cable provides the framework to deal with WebSockets in Rails.
2 | // You can generate new channels where WebSocket features live using the `bin/rails generate channel` command.
3 |
4 | import { createConsumer } from "@rails/actioncable"
5 |
6 | export default createConsumer()
7 |
--------------------------------------------------------------------------------
/app/models/application_record.rb:
--------------------------------------------------------------------------------
1 | class ApplicationRecord < ActiveRecord::Base
2 | self.abstract_class = true
3 |
4 | scope :newest, -> { order(created_at: :desc) }
5 | scope :oldest, -> { order(created_at: :asc) }
6 | scope :freshest, -> { order(updated_at: :desc) }
7 | scope :stalest, -> { order(updated_at: :asc) }
8 | end
9 |
--------------------------------------------------------------------------------
/config/initializers/opinionated_defaults/generators.rb:
--------------------------------------------------------------------------------
1 | # Disable a few of the generators I often just delete after they're created.
2 | Rails.application.config.generators do |g|
3 | g.assets false
4 | g.helper false
5 | g.view_specs false
6 | g.decorator false
7 | g.system_tests = nil
8 | g.jbuilder false
9 | end
10 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
3 |
4 | mount Sidekiq::Web => "/sidekiq" if defined?(Sidekiq) && defined?(Sidekiq::Web)
5 | mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
6 | end
7 |
--------------------------------------------------------------------------------
/config/initializers/opinionated_defaults/logger.rb:
--------------------------------------------------------------------------------
1 | # By default Rails will keep writing to logs/development.log, this can lead to really large files.
2 | # Let's configure this to be at most 50mb.
3 | if Rails.env.development?
4 | Rails.logger = ActiveSupport::Logger.new(Rails.application.config.paths["log"].first, 1, 50.megabytes)
5 | end
6 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
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 the yarn lockfile as having been generated.
7 | yarn.lock linguist-generated
8 |
9 | # Mark any vendored files as having been vendored.
10 | vendor/* linguist-vendored
11 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7 | # Character.create(name: 'Luke', movie: movies.first)
8 |
--------------------------------------------------------------------------------
/.github/workflows/standard.yml:
--------------------------------------------------------------------------------
1 | name: Standard
2 |
3 | on:
4 | push:
5 | branches-ignore:
6 | - master
7 | jobs:
8 | standard:
9 | runs-on: ubuntu-latest
10 |
11 | steps:
12 | - uses: actions/checkout@v2
13 | - name: Set up Ruby
14 | uses: ruby/setup-ruby@v1
15 | with:
16 | bundler-cache: true
17 | - name: Run Standard
18 | run: bundle exec standardrb
19 |
--------------------------------------------------------------------------------
/bin/docker/entrypoints/wait-for-postgres.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | # Wait for Postgres to start before doing anything
5 | echo ""
6 | echo "== ⏱ Waiting for Postgres before running: $@ =="
7 | dockerize -wait tcp://postgres:5432 -timeout 60s -wait-retry-interval 5s
8 |
9 | # Then exec the container's main process (what's set as CMD in the Dockerfile).
10 | echo ""
11 | echo "== 🏎 Running: $@ =="
12 | exec "$@"
13 |
--------------------------------------------------------------------------------
/Procfile:
--------------------------------------------------------------------------------
1 | # The Procfile is used by Heroku to define which services you'd like to run.
2 | ## Release tasks are used to automated running migrations on deploy.
3 | release: ./bin/heroku/release-tasks.sh
4 |
5 | ## Web Instance, this'll serve TCP requests
6 | web: ./bin/rails server -p ${PORT:-5000}
7 |
8 | ## Sidekiq is the de-facto standard choice for running Background tasks
9 | # worker: ./bin/bundle exec sidekiq -C config/sidekiq.yml
10 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "app",
3 | "private": true,
4 | "dependencies": {
5 | "@rails/actioncable": "^6.0.0",
6 | "@rails/activestorage": "^6.0.0",
7 | "@rails/ujs": "^6.0.0",
8 | "@rails/webpacker": "5.4.3",
9 | "turbolinks": "^5.2.0",
10 | "webpack": "^4.46.0",
11 | "webpack-cli": "^3.3.12"
12 | },
13 | "version": "0.1.0",
14 | "devDependencies": {
15 | "webpack-dev-server": "^3"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/bin/docker/entrypoints/wait-for-web.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | # Wait for Web to start before doing anything
5 | echo ""
6 | echo "== ⏱ Waiting for Postgres & Web to start before running: $@ =="
7 | dockerize -wait tcp://postgres:5432 -wait tcp://web:3000 -timeout 60s -wait-retry-interval 5s
8 |
9 | # Then exec the container's main process (what's set as CMD in the Dockerfile).
10 | echo ""
11 | echo "== 🏎 Running: $@ =="
12 | exec "$@"
13 |
--------------------------------------------------------------------------------
/config/initializers/permissions_policy.rb:
--------------------------------------------------------------------------------
1 | # Define an application-wide HTTP permissions policy. For further
2 | # information see https://developers.google.com/web/updates/2018/06/feature-policy
3 | #
4 | # Rails.application.config.permissions_policy do |f|
5 | # f.camera :none
6 | # f.gyroscope :none
7 | # f.microphone :none
8 | # f.usb :none
9 | # f.fullscreen :self
10 | # f.payment :self, "https://secure.example.com"
11 | # end
12 |
--------------------------------------------------------------------------------
/bin/heroku/release-tasks.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "Running Release Tasks"
4 |
5 | # These run after a deploy has been build, but before it has been released.
6 | if [ "$DURING_RELEASE_RUN_MIGRATIONS" == "enabled" ]; then
7 | echo "Running Migrations"
8 | bundle exec rake db:migrate || exit $?
9 | fi
10 |
11 | if [ "$DURING_RELEASE_SEED_DB" == "enabled" ]; then
12 | echo "Running Seeds"
13 | bundle exec rake db:seed || exit $?
14 | fi
15 |
16 | echo "Done"
17 |
--------------------------------------------------------------------------------
/config/initializers/opinionated_defaults/default_url_options.rb:
--------------------------------------------------------------------------------
1 | # Sets the default URL options to the URL env.
2 | if ENV["URL"].present?
3 | Rails.application.default_url_options = {
4 | host: ENV.fetch("URL", "127.0.0.1"),
5 | protocol: ENV.fetch("URL_PROTOCOL", "https")
6 | }
7 | elsif ENV["HEROKU_APP_NAME"].present?
8 | Rails.application.default_url_options = {
9 | protocol: "https",
10 | host: "#{ENV["HEROKU_APP_NAME"]}.herokuapp.com"
11 | }
12 | end
13 |
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | # If you want, you can run:
2 | # $ docker-compose up redis postgres
3 | # $ bundle exec rails s
4 | # I know for some people it's a little more performant :)
5 | REDIS_URL=redis://@127.0.0.1:6379/1
6 | DATABASE_URL=postgres://postgres:postgres@127.0.0.1:5432/
7 |
8 | # Set a default host value - Useful for mailers & _url routes.
9 | URL=127.0.0.1:3000
10 | URL_PROTOCOL=http
11 |
12 | # Set a rails master key
13 | # RAILS_MASTER_KEY="bundle exec rake secret | cut -c -32"
14 |
--------------------------------------------------------------------------------
/config/initializers/opinionated_defaults/locale.rb:
--------------------------------------------------------------------------------
1 | # Let break our locales into different files nested into subfiles
2 |
3 | Rails.application.configure do
4 | config.i18n.load_path += Dir[Rails.root.join("config/locales/**/*.{rb,yml}")]
5 | config.i18n.fallbacks = true
6 | # config.i18n.available_locales = [:en, :'en-GB', :de]
7 |
8 | ## If you're using the rack-contrib gem - You can use this middleware to auto set the locale.
9 | # config.middleware.use Rack::Locale
10 | end
11 |
--------------------------------------------------------------------------------
/bin/webpack:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4 | ENV["NODE_ENV"] ||= "development"
5 |
6 | require "pathname"
7 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8 | Pathname.new(__FILE__).realpath)
9 |
10 | require "bundler/setup"
11 |
12 | require "webpacker"
13 | require "webpacker/webpack_runner"
14 |
15 | APP_ROOT = File.expand_path("..", __dir__)
16 | Dir.chdir(APP_ROOT) do
17 | Webpacker::WebpackRunner.run(ARGV)
18 | end
19 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | App
5 |
6 | <%= csrf_meta_tags %>
7 | <%= csp_meta_tag %>
8 |
9 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
10 | <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
11 |
12 |
13 |
14 | <%= yield %>
15 |
16 |
17 |
--------------------------------------------------------------------------------
/bin/webpack-dev-server:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4 | ENV["NODE_ENV"] ||= "development"
5 |
6 | require "pathname"
7 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8 | Pathname.new(__FILE__).realpath)
9 |
10 | require "bundler/setup"
11 |
12 | require "webpacker"
13 | require "webpacker/dev_server_runner"
14 |
15 | APP_ROOT = File.expand_path("..", __dir__)
16 | Dir.chdir(APP_ROOT) do
17 | Webpacker::DevServerRunner.run(ARGV)
18 | end
19 |
--------------------------------------------------------------------------------
/app/javascript/packs/application.js:
--------------------------------------------------------------------------------
1 | // This file is automatically compiled by Webpack, along with any other files
2 | // present in this directory. You're encouraged to place your actual application logic in
3 | // a relevant structure within app/javascript and only use these pack files to reference
4 | // that code so it'll be compiled.
5 |
6 | import Rails from "@rails/ujs"
7 | import Turbolinks from "turbolinks"
8 | import * as ActiveStorage from "@rails/activestorage"
9 | import "channels"
10 |
11 | Rails.start()
12 | Turbolinks.start()
13 | ActiveStorage.start()
14 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json]
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code
7 | # by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'".
8 | Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"]
9 |
--------------------------------------------------------------------------------
/bin/yarn:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | APP_ROOT = File.expand_path('..', __dir__)
3 | Dir.chdir(APP_ROOT) do
4 | yarn = ENV["PATH"].split(File::PATH_SEPARATOR).
5 | select { |dir| File.expand_path(dir) != __dir__ }.
6 | product(["yarn", "yarn.cmd", "yarn.ps1"]).
7 | map { |dir, file| File.expand_path(file, dir) }.
8 | find { |file| File.executable?(file) }
9 |
10 | if yarn
11 | exec yarn, *ARGV
12 | else
13 | $stderr.puts "Yarn executable was not detected in the system."
14 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
15 | exit 1
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/config/initializers/opinionated_defaults/web_console.rb:
--------------------------------------------------------------------------------
1 | # This adds the IP range for docker host, this allows us to use the web-console gem within docker.
2 | Rails.application.configure do
3 | if Rails.env.development? && defined?(WebConsole)
4 | config.web_console.permissions = %w[172.0.0.0/10]
5 |
6 | # We have to reset the permissions like this as it's memorized within an initializer which is called
7 | # between the config/environments/development.rb file & this file.
8 | WebConsole::Request.permissions = WebConsole::Permissions.new(config.web_console.permissions)
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = "1.0"
5 |
6 | # Add additional assets to the asset load path.
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 | # Add Yarn node_modules folder to the asset load path.
9 | Rails.application.config.assets.paths << Rails.root.join("node_modules")
10 |
11 | # Precompile additional assets.
12 | # application.js, application.css, and all non-JS/CSS in the app/assets
13 | # folder are already added.
14 | # Rails.application.config.assets.precompile += %w( admin.js admin.css )
15 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/.github/workflows/linters.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: Linters
3 |
4 | on:
5 | push:
6 | branches-ignore:
7 | - master
8 |
9 | jobs:
10 | # https://github.com/github/super-linter
11 | super_linter:
12 | if: false
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Checkout Code
16 | uses: actions/checkout@v2
17 | - name: Lint Code Base
18 | uses: docker://github/super-linter:v2.1.0
19 |
20 | # https://github.com/devmasx/brakeman-linter-action
21 | brakeman:
22 | runs-on: ubuntu-latest
23 | steps:
24 | - uses: actions/checkout@v1
25 | - name: Brakeman
26 | uses: devmasx/brakeman-linter-action@v1.0.0
27 | env:
28 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
29 |
--------------------------------------------------------------------------------
/bin/docker/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require "fileutils"
3 |
4 | # path to your application root.
5 | APP_ROOT = File.expand_path("../../", __dir__)
6 |
7 | def system!(*args)
8 | system(*args) || abort("\n== Command #{args} failed ==")
9 | end
10 |
11 | FileUtils.chdir APP_ROOT do
12 | # This turns sets up up the docker image
13 | puts "\n== Copying sample files =="
14 | FileUtils.cp ".env.template", ".env" unless File.exist?(".env")
15 |
16 | puts "== Pulling Images =="
17 | system! "docker-compose pull"
18 |
19 | puts "== Building Container =="
20 | system! "docker-compose build"
21 |
22 | puts "== Installing Libraries =="
23 | system! "docker-compose run --rm web ./bin/setup"
24 |
25 | puts "== 🎉 Success, now you can run ./bin/docker/start"
26 | end
27 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
6 | * vendor/assets/stylesheets directory can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10 | * files in this directory. Styles in this file should be added after the last require_* statement.
11 | * It is generally better to create a new file per style scope.
12 | *
13 | *= require_tree .
14 | *= require_self
15 | */
16 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require_relative "boot"
2 |
3 | require "rails/all"
4 |
5 | # Require the gems listed in Gemfile, including any gems
6 | # you've limited to :test, :development, or :production.
7 | Bundler.require(*Rails.groups)
8 |
9 | module App
10 | class Application < Rails::Application
11 | # Initialize configuration defaults for originally generated Rails version.
12 | config.load_defaults 6.1
13 |
14 | # Configuration for the application, engines, and railties goes here.
15 | #
16 | # These settings can be overridden in specific environments using the files
17 | # in config/environments, which are processed later.
18 | #
19 | # config.time_zone = "Central Time (US & Canada)"
20 | # config.eager_load_paths << Rails.root.join("extras")
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/config/sidekiq.yml:
--------------------------------------------------------------------------------
1 | # Sample configuration file for Sidekiq.
2 | # Options here can still be overridden by cmd line args.
3 | # Place this file at config/sidekiq.yml and Sidekiq will
4 | # pick it up automatically.
5 | ---
6 | :verbose: false
7 | :concurrency: 3
8 | :max_retries: 3
9 |
10 | # Set timeout to 8 on Heroku, longer if you manage your own systems.
11 | :timeout: 8
12 |
13 | # Sidekiq will run this file through ERB when reading it so you can
14 | # even put in dynamic logic, like a host-specific queue.
15 | # http://www.mikeperham.com/2013/11/13/advanced-sidekiq-host-specific-queues/
16 | :queues:
17 | - critical
18 | - sentry
19 | - mailers
20 | - default
21 | - action_mailbox_routing
22 | - action_mailbox_incineration
23 | - active_storage_analysis
24 | - active_storage_purge
25 | - low
26 |
--------------------------------------------------------------------------------
/.dockerignore:
--------------------------------------------------------------------------------
1 | .git
2 | .gitignore
3 |
4 | #
5 | # OS X
6 | #
7 | .DS_Store
8 | .AppleDouble
9 | .LSOverride
10 | # Icon must end with two \r
11 | Icon
12 | # Thumbnails
13 | ._*
14 | # Files that might appear on external disk
15 | .Spotlight-V100
16 | .Trashes
17 | # Directories potentially created on remote AFP share
18 | .AppleDB
19 | .AppleDesktop
20 | Network Trash Folder
21 | Temporary Items
22 | .apdisk
23 |
24 | #
25 | # Rails
26 | #
27 | *.rbc
28 | capybara-*.html
29 | log
30 | db/*.sqlite3
31 | db/*.sqlite3-journal
32 | public/system
33 | yarn-error.log
34 | yarn-debug.log*
35 | .yarn-integrity
36 | external_dns.log
37 |
38 | coverage/
39 | spec/tmp
40 | **.orig
41 |
42 | .bundle
43 |
44 | .ruby-gemset
45 |
46 | .rvmrc
47 |
48 | # if using bower-rails ignore default bower_components path bower.json files
49 | vendor/assets/bower_components
50 | *.bowerrc
51 | bower.json
52 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # This file is auto-generated from the current state of the database. Instead
2 | # of editing this file, please use the migrations feature of Active Record to
3 | # incrementally modify your database, and then regenerate this schema definition.
4 | #
5 | # This file is the source Rails uses to define your schema when running `rails
6 | # db:schema:load`. When creating a new database, `rails db:schema:load` tends to
7 | # be faster and is potentially less error prone than running all of your
8 | # migrations from scratch. Old migrations may fail to apply correctly if those
9 | # migrations use external dependencies or application code.
10 | #
11 | # It's strongly recommended that you check this file into your version control system.
12 |
13 | ActiveRecord::Schema.define(version: 0) do
14 | # These are extensions that must be enabled in order to support this database
15 | enable_extension "plpgsql"
16 | end
17 |
--------------------------------------------------------------------------------
/config/initializers/opinionated_defaults/lograge.rb:
--------------------------------------------------------------------------------
1 | # By default Rails can generate very verbose logs.
2 | # I'm a fan of: https://github.com/roidrage/lograge
3 | # It makes every request a single line in the logs.
4 | if defined?(Lograge)
5 | Rails.application.configure do
6 | config.lograge.enabled = true
7 | config.lograge.custom_options = lambda do |event|
8 | # No params? Must be ActionCable.
9 | return {} if event.payload[:params].blank?
10 |
11 | exceptions = %w[controller action format authenticity_token]
12 |
13 | {
14 | params: event.payload[:params].except(*exceptions)
15 | }
16 | end
17 |
18 | config.lograge.custom_payload do |controller|
19 | {
20 | host: controller.request.host,
21 | remote_ip: controller.request.remote_ip,
22 | api_key: controller.request.headers.env["HTTP_X_APIKEY"]
23 | }
24 | end
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/config/initializers/opinionated_defaults/assets.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Add some sensible caching headers all assets. Sometimes Nginx adds these, but not always.
3 | config.static_cache_control = "public, max-age=31536000"
4 | config.public_file_server.headers = {
5 | "Cache-Control" => "public, max-age=31536000",
6 | "Expires" => 1.year.from_now.to_formatted_s(:rfc822)
7 | }
8 |
9 | # Enable serving of images, stylesheets, and JavaScripts from an asset server (Normally https://cdn.yourdomain.com).
10 | if ENV["ASSET_HOST"]
11 | config.action_controller.asset_host = ENV["ASSET_HOST"]
12 | config.action_mailer.asset_host = ENV["ASSET_HOST"]
13 | elsif ENV["HEROKU_APP_NAME"].present?
14 | config.action_controller.asset_host = "https://#{ENV["HEROKU_APP_NAME"]}.herokuapp.com"
15 | config.action_mailer.asset_host = "https://#{ENV["HEROKU_APP_NAME"]}.herokuapp.com"
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/bin/docker/prepare-to-start-rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | require "fileutils"
5 |
6 | # path to your application root.
7 | APP_ROOT = File.expand_path("../../", __dir__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | FileUtils.chdir APP_ROOT do
14 | # This script is a way to prepare your environment for when Docker is about to start Rails.
15 | # This script is idempotent, so that you can run it at anytime and get an expectable outcome.
16 | # Add necessary setup steps to this file.
17 |
18 | puts "\n== Clearing up any previous Rails Instances =="
19 | system "rm -rf tmp/pids/server.pid"
20 |
21 | puts "== Checking dependencies =="
22 | system! "gem install bundler --conservative"
23 | system("bundle check") || system!("bundle install")
24 |
25 | # Install JavaScript dependencies
26 | system("bin/yarn")
27 | end
28 |
--------------------------------------------------------------------------------
/.github/dependabot.yml.sample:
--------------------------------------------------------------------------------
1 | version: 2
2 |
3 | # Dependabot: Disabled by default as it can be scary to see a bunch of Pull Requests open on a new template.
4 | #
5 | # Plus, I'm also worried about Dependabot as an vector for stealing test API data (e.g someone pushing a compromised
6 | # version of a library).
7 |
8 | updates:
9 |
10 | # Maintain dependencies for GitHub Actions
11 | - package-ecosystem: "github-actions"
12 | directory: "/"
13 | schedule:
14 | interval: "daily"
15 |
16 | # Maintain dependencies for npm
17 | - package-ecosystem: "npm"
18 | directory: "/"
19 | schedule:
20 | interval: "daily"
21 |
22 | # Maintain dependencies for Bundler
23 | - package-ecosystem: "bundler"
24 | directory: "/"
25 | schedule:
26 | interval: "daily"
27 |
28 | # Maintain dependencies for Docker
29 | - package-ecosystem: "docker"
30 | directory: "/"
31 | schedule:
32 | interval: "daily"
33 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # The following keys must be escaped otherwise they will not be retrieved by
20 | # the default I18n backend:
21 | #
22 | # true, false, on, off, yes, no
23 | #
24 | # Instead, surround them with single quotes.
25 | #
26 | # en:
27 | # 'true': 'foo'
28 | #
29 | # To learn more, please read the Rails Internationalization guide
30 | # available at https://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2 | #
3 | # If you find yourself ignoring temporary files generated by your text editor
4 | # or operating system, you probably want to add a global ignore instead:
5 | # git config --global core.excludesfile '~/.gitignore_global'
6 |
7 | # Ignore bundler config.
8 | /.bundle
9 |
10 | # Ignore all logfiles and tempfiles.
11 | /log/*
12 | /tmp/*
13 | !/log/.keep
14 | !/tmp/.keep
15 |
16 | # Ignore pidfiles, but keep the directory.
17 | /tmp/pids/*
18 | !/tmp/pids/
19 | !/tmp/pids/.keep
20 |
21 | # Ignore uploaded files in development.
22 | /storage/*
23 | !/storage/.keep
24 |
25 | /public/assets
26 | .byebug_history
27 |
28 | # Ignore master key for decrypting credentials and more.
29 | /config/master.key
30 |
31 | /public/packs
32 | /public/packs-test
33 | /node_modules
34 | /yarn-error.log
35 | yarn-debug.log*
36 | .yarn-integrity
37 |
38 | # Ignore .envs - They store environmental variables
39 | .env
40 |
41 | # Ignore the vendor bundle
42 | vendor/bundle/
43 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | require "fileutils"
5 |
6 | # path to your application root.
7 | APP_ROOT = File.expand_path("..", __dir__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | FileUtils.chdir APP_ROOT do
14 | # This script is a way to setup or update your development environment automatically.
15 | # This script is idempotent, so that you can run it at anytime and get an expectable outcome.
16 | # Add necessary setup steps to this file.
17 |
18 | puts "== Installing dependencies =="
19 | system! "gem install bundler --conservative"
20 | system("bundle check") || system!("bundle install")
21 |
22 | # Install JavaScript dependencies
23 | system("bin/yarn")
24 |
25 | puts "\n== Preparing database =="
26 | system! "bin/rails db:prepare"
27 |
28 | puts "\n== Removing old logs and tempfiles =="
29 | system! "bin/rails log:clear tmp:clear"
30 |
31 | puts "\n== Restarting application server =="
32 | system! "bin/rails restart"
33 | end
34 |
--------------------------------------------------------------------------------
/docker-compose.ci.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is used to run the test suite within CI without requiring extra services.
3 | #
4 | ## Usage:
5 | #
6 | # docker-compose -f docker-compose.ci.yml build test
7 | # docker-compose -f docker-compose.ci.yml run --rm test
8 | version: '3'
9 |
10 | x-ci-app: &ci-app
11 | build:
12 | context: .
13 | dockerfile: Dockerfile
14 | target: development
15 | environment:
16 | DATABASE_URL: postgres://postgres:postgres@postgres:5432/
17 | RAILS_ENV: test
18 | RACK_ENV: test
19 | BUNDLE_PATH: /usr/src/app/vendor/bundle
20 | entrypoint: ./bin/docker/entrypoints/wait-for-postgres.sh
21 | volumes:
22 | - .:/usr/src/app:cached
23 | depends_on:
24 | - postgres
25 |
26 | services:
27 | postgres:
28 | image: postgres:13.2-alpine
29 | environment:
30 | POSTGRES_USER: postgres
31 | POSTGRES_PASSWORD: postgres
32 | restart: on-failure
33 | logging:
34 | driver: none
35 |
36 | test:
37 | <<: *ci-app
38 | command: bash -c "./bin/setup && ./bin/rake assets:precompile && ./bin/bundle exec rspec"
39 |
--------------------------------------------------------------------------------
/config/storage.yml:
--------------------------------------------------------------------------------
1 | test:
2 | service: Disk
3 | root: <%= Rails.root.join("tmp/storage") %>
4 |
5 | local:
6 | service: Disk
7 | root: <%= Rails.root.join("storage") %>
8 |
9 | # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10 | # amazon:
11 | # service: S3
12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14 | # region: us-east-1
15 | # bucket: your_own_bucket
16 |
17 | # Remember not to checkin your GCS keyfile to a repository
18 | # google:
19 | # service: GCS
20 | # project: your_project
21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22 | # bucket: your_own_bucket
23 |
24 | # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25 | # microsoft:
26 | # service: AzureStorage
27 | # storage_account_name: your_account_name
28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29 | # container: your_container_name
30 |
31 | # mirror:
32 | # service: Mirror
33 | # primary: local
34 | # mirrors: [ amazon, google, microsoft ]
35 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3 | ruby "3.0.1"
4 |
5 | gem "barnes", "~> 0.0.8"
6 | gem "bootsnap", ">= 1.4.4", require: false
7 | gem "image_processing", "~> 1.12"
8 | gem "lograge", "~> 0.11.2"
9 | gem "pg", "~> 1.1"
10 | gem "premailer-rails", "~> 1.11"
11 | gem "puma", "~> 5.0"
12 | gem "rails", "~> 6.1.4", ">= 6.1.4.1"
13 | gem "redis", "~> 4.2"
14 | gem "sass-rails", ">= 6"
15 | gem "sentry-raven", "~> 3.1"
16 | gem "sidekiq", "~> 6.1"
17 | gem "sidekiq-cron", "~> 1.2"
18 | gem "turbolinks", "~> 5"
19 | gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]
20 | gem "webpacker", "~> 5.0"
21 |
22 | group :development, :test do
23 | gem "byebug", platforms: %i[mri mingw x64_mingw]
24 | gem "dotenv-rails", "~> 2.7"
25 | gem "factory_bot_rails"
26 | gem "rspec-rails", "~> 4.0"
27 | end
28 |
29 | group :development do
30 | gem "letter_opener", "~> 1.7"
31 | gem "letter_opener_web", "~> 1.4"
32 | gem "listen", "~> 3.3"
33 | gem "rack-mini-profiler", "~> 2.0"
34 | gem "standardrb", "~> 1.0", require: false
35 | gem "web-console", ">= 4.1.0"
36 | end
37 |
38 | group :test do
39 | gem "capybara", ">= 3.26"
40 | gem "selenium-webdriver"
41 | gem "webdrivers"
42 | end
43 |
--------------------------------------------------------------------------------
/config/initializers/content_security_policy.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Define an application-wide content security policy
4 | # For further information see the following documentation
5 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
6 |
7 | # Rails.application.config.content_security_policy do |policy|
8 | # policy.default_src :self, :https
9 | # policy.font_src :self, :https, :data
10 | # policy.img_src :self, :https, :data
11 | # policy.object_src :none
12 | # policy.script_src :self, :https
13 | # policy.style_src :self, :https
14 | # # If you are using webpack-dev-server then specify webpack-dev-server host
15 | # policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
16 |
17 | # # Specify URI for violation reports
18 | # # policy.report_uri "/csp-violation-report-endpoint"
19 | # end
20 |
21 | # If you are using UJS then enable automatic nonce generation
22 | # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
23 |
24 | # Set the nonce only to specific directives
25 | # Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
26 |
27 | # Report CSP violations to a specified URI
28 | # For further information see the following documentation:
29 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
30 | # Rails.application.config.content_security_policy_report_only = true
31 |
--------------------------------------------------------------------------------
/config/initializers/opinionated_defaults/sidekiq.rb:
--------------------------------------------------------------------------------
1 | # Sidekiq is the de-facto standard choice for running Background tasks
2 | # You should use it to perform API requests & long running tasks.
3 | if defined?(Sidekiq) && ENV["REDIS_URL"].present?
4 | require "sidekiq/web"
5 | require "sidekiq/cron/web" if defined?(Sidekiq::Cron)
6 |
7 | # https://github.com/mperham/sidekiq/wiki/Monitoring#rails-http-basic-auth-from-routes
8 | Sidekiq::Web.use Rack::Auth::Basic do |username, password|
9 | ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(username),
10 | ::Digest::SHA256.hexdigest(ENV["SIDEKIQ_USERNAME"])) &
11 | ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(password),
12 | ::Digest::SHA256.hexdigest(ENV["SIDEKIQ_PASSWORD"]))
13 | end
14 |
15 | # https://github.com/ondrejbartas/sidekiq-cron
16 | # Sidekiq-cron - It's a very sensible approach to performing scheduled tasks.
17 | if Sidekiq.server? && defined?(Sidekiq::Cron)
18 | Rails.application.config.after_initialize do
19 | schedule_file = Rails.root.join("config/schedule.yml")
20 | schedule_file_yaml = YAML.load_file(schedule_file) if schedule_file.exist?
21 |
22 | # Use https://crontab.guru to confirm times
23 | Sidekiq::Cron::Job.load_from_hash(schedule_file_yaml) if schedule_file_yaml
24 | end
25 | end
26 |
27 | Sidekiq.configure_client do |_config|
28 | # Any client specific configuration
29 | end
30 |
31 | Rails.application.config.cache_store = :redis_cache_store, {
32 | url: ENV["REDIS_URL"],
33 | network_timeout: 5
34 | }
35 | Rails.application.config.active_job.queue_adapter = :sidekiq
36 | ActiveJob::Base.queue_adapter = :sidekiq
37 | else
38 | Rails.application.config.active_job.queue_adapter = :inline
39 | ActiveJob::Base.queue_adapter = :inline
40 | end
41 |
--------------------------------------------------------------------------------
/public/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | We're sorry, but something went wrong (500)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
We're sorry, but something went wrong.
62 |
63 |
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/config/initializers/opinionated_defaults/action_mailer.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Default to Mailtrap if we have it, then fallback to sendgrid then SENDGRID_USERNAME.
3 | # If nothing is present. don't send emails (Which each environment can override if needed).
4 | if ENV["MAILTRAP_API_TOKEN"].present?
5 | require "net/http"
6 | require "uri"
7 | require "json"
8 | first_inbox = JSON.parse(Net::HTTP.get(URI.parse("https://mailtrap.io/api/v1/inboxes.json?api_token=#{ENV["MAILTRAP_API_TOKEN"]}")))[0]
9 | config.action_mailer.delivery_method = :smtp
10 | config.action_mailer.smtp_settings = {
11 | user_name: first_inbox["username"],
12 | password: first_inbox["password"],
13 | address: first_inbox["domain"],
14 | domain: first_inbox["domain"],
15 | port: first_inbox["smtp_ports"][0],
16 | authentication: :cram_md5
17 | }
18 | elsif ENV["SENDGRID_API_KEY"].present?
19 | # If you're using SendGrid you need to create an API key at:
20 | # https://app.sendgrid.com/settings/api_keys
21 | # with full access to "Mail Send" permissions.
22 | config.action_mailer.smtp_settings = {
23 | address: "smtp.sendgrid.net",
24 | port: 587,
25 | authentication: :plain,
26 | user_name: "apikey",
27 | password: ENV["SENDGRID_API_KEY"],
28 | domain: "heroku.com",
29 | enable_starttls_auto: true
30 | }
31 | elsif Rails.env.development? && defined?(LetterOpenerWeb)
32 | # https://github.com/fgrehm/letter_opener_web
33 | # Preview mailers in your browser.
34 | config.action_mailer.delivery_method = :letter_opener_web
35 | config.action_mailer.perform_deliveries = true
36 | else
37 | config.action_mailer.perform_deliveries = false
38 | end
39 |
40 | # Enable previewing mailers in review environments.
41 | config.action_mailer.show_previews = (ENV["ENABLE_MAILER_PREVIEWS"].present? || Rails.env.development?)
42 | end
43 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | # Puma can serve each request in a thread from an internal thread pool.
2 | # The `threads` method setting takes two numbers: a minimum and maximum.
3 | # Any libraries that use thread pools should be configured to match
4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum
5 | # and maximum; this matches the default thread size of Active Record.
6 | #
7 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
8 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
9 | threads min_threads_count, max_threads_count
10 |
11 | # Specifies the `worker_timeout` threshold that Puma will use to wait before
12 | # terminating a worker in development environments.
13 | #
14 | worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
15 |
16 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
17 | #
18 | port ENV.fetch("PORT", 3000)
19 |
20 | # Specifies the `environment` that Puma will run in.
21 | #
22 | environment ENV.fetch("RAILS_ENV") { "development" }
23 |
24 | # Specifies the `pidfile` that Puma will use.
25 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
26 |
27 | # Specifies the number of `workers` to boot in clustered mode.
28 | # Workers are forked web server processes. If using threads and workers together
29 | # the concurrency of the application would be max `threads` * `workers`.
30 | # Workers do not work on JRuby or Windows (both of which do not support
31 | # processes).
32 | #
33 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
34 |
35 | # Use the `preload_app!` method when specifying a `workers` number.
36 | # This directive tells Puma to first boot the application and load code
37 | # before forking the application. This takes advantage of Copy On Write
38 | # process behavior so workers use less memory.
39 | #
40 | # preload_app!
41 |
42 | # Allow puma to be restarted by `rails restart` command.
43 | plugin :tmp_restart
44 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Docker-Rails-Template",
3 | "description": "A starting point I use for my Ruby on Rails apps",
4 | "env": {
5 | "DURING_RELEASE_RUN_MIGRATIONS": {
6 | "required": true,
7 | "value": "enabled"
8 | },
9 | "DURING_RELEASE_SEED_DB": {
10 | "required": false,
11 | "value": "enabled"
12 | },
13 | "LANG": {
14 | "required": true,
15 | "value": "en_US.UTF-8"
16 | },
17 | "RACK_ENV": {
18 | "required": true,
19 | "value": "production"
20 | },
21 | "RAILS_ENV": {
22 | "required": true,
23 | "value": "production"
24 | },
25 | "RAILS_LOG_TO_STDOUT": {
26 | "required": true,
27 | "value": "enabled"
28 | },
29 | "RAILS_MAX_THREADS": {
30 | "required": true,
31 | "value": "18"
32 | },
33 | "RAILS_SERVE_STATIC_FILES": {
34 | "required": true,
35 | "value": "enabled"
36 | },
37 | "SECRET_KEY_BASE": {
38 | "required": false
39 | },
40 | "SIDEKIQ_PASSWORD": {
41 | "required": false
42 | },
43 | "SIDEKIQ_USERNAME": {
44 | "required": false
45 | },
46 | "URL": {
47 | "required": false
48 | }
49 | },
50 | "buildpacks": [
51 | {
52 | "url": "heroku/metrics"
53 | },
54 | {
55 | "url": "https://github.com/heroku/heroku-buildpack-activestorage-preview"
56 | },
57 | {
58 | "url": "heroku/ruby"
59 | }
60 | ],
61 | "environments": {
62 | "production": {
63 | "addons": [
64 | "heroku-redis:hobby-dev",
65 | "heroku-postgresql:hobby-dev",
66 | "sendgrid",
67 | "papertrail",
68 | "sentry"
69 | ],
70 | "formation": {}
71 | },
72 | "review": {
73 | "addons": [
74 | "heroku-redis:hobby-dev",
75 | "heroku-postgresql:hobby-dev",
76 | "mailtrap",
77 | "papertrail"
78 | ],
79 | "formation": {}
80 | },
81 | "test": {}
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The change you wanted was rejected (422)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The change you wanted was rejected.
62 |
Maybe you tried to change something you didn't have access to.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/config/webpacker.yml:
--------------------------------------------------------------------------------
1 | # Note: You must restart bin/webpack-dev-server for changes to take effect
2 |
3 | default: &default
4 | source_path: app/javascript
5 | source_entry_path: packs
6 | public_root_path: public
7 | public_output_path: packs
8 | cache_path: tmp/cache/webpacker
9 | webpack_compile_output: true
10 |
11 | # Additional paths webpack should lookup modules
12 | # ['app/assets', 'engine/foo/app/assets']
13 | additional_paths: []
14 |
15 | # Reload manifest.json on all requests so we reload latest compiled packs
16 | cache_manifest: false
17 |
18 | # Extract and emit a css file
19 | extract_css: false
20 |
21 | static_assets_extensions:
22 | - .jpg
23 | - .jpeg
24 | - .png
25 | - .gif
26 | - .tiff
27 | - .ico
28 | - .svg
29 | - .eot
30 | - .otf
31 | - .ttf
32 | - .woff
33 | - .woff2
34 |
35 | extensions:
36 | - .mjs
37 | - .js
38 | - .sass
39 | - .scss
40 | - .css
41 | - .module.sass
42 | - .module.scss
43 | - .module.css
44 | - .png
45 | - .svg
46 | - .gif
47 | - .jpeg
48 | - .jpg
49 |
50 | development:
51 | <<: *default
52 | compile: true
53 |
54 | # Reference: https://webpack.js.org/configuration/dev-server/
55 | dev_server:
56 | https: false
57 | host: localhost
58 | port: 3035
59 | public: localhost:3035
60 | hmr: false
61 | # Inline should be set to true if using HMR
62 | inline: true
63 | overlay: true
64 | compress: true
65 | disable_host_check: true
66 | use_local_ip: false
67 | quiet: false
68 | pretty: false
69 | headers:
70 | 'Access-Control-Allow-Origin': '*'
71 | watch_options:
72 | ignored: '**/node_modules/**'
73 |
74 |
75 | test:
76 | <<: *default
77 | compile: true
78 |
79 | # Compile test packs to a separate directory
80 | public_output_path: packs-test
81 |
82 | production:
83 | <<: *default
84 |
85 | # Production depends on precompilation of packs prior to booting for performance.
86 | compile: false
87 |
88 | # Extract and emit a css file
89 | extract_css: true
90 |
91 | # Cache manifest.json for performance
92 | cache_manifest: true
93 |
--------------------------------------------------------------------------------
/.github/workflows/tests.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: Tests
3 |
4 | on:
5 | push:
6 |
7 | jobs:
8 | test:
9 | runs-on: ubuntu-latest
10 |
11 | steps:
12 | - uses: actions/checkout@v1
13 | - name: Pull docker images
14 | run: |
15 | docker pull ruby:3.0.1-alpine --quiet
16 | docker-compose -f docker-compose.ci.yml pull --quiet
17 |
18 | # Cache the docker layers to help speed up the Docker build times.
19 | - uses: satackey/action-docker-layer-caching@v0
20 | with:
21 | key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile') }}
22 | restore-keys: |
23 | ${{ runner.os }}-docker-
24 |
25 | # We as store the node_modules & gems outside of the build, we can use actions/cache to persist them between
26 | # runs of this action.
27 | - name: Cache Assets
28 | uses: actions/cache@v2
29 | with:
30 | path: |
31 | **/node_modules
32 | public/assets
33 | public/packs-test
34 | key: ${{ runner.os }}-assets-${{ hashFiles('**/yarn.lock') }}
35 | - name: Cache gems
36 | uses: actions/cache@v2
37 | with:
38 | path: |
39 | vendor/bundle
40 | key: ${{ runner.os }}-bundle-${{ hashFiles('**/Gemfile.lock') }}
41 |
42 | # Build the Docker image we're testing our app on.
43 | - name: Build Latest
44 | run: |
45 | docker-compose -f docker-compose.ci.yml build --build-arg USER_ID="$(id -u)" --build-arg GROUP_ID="$(id -u)" test
46 | # Download the node_modules & gems, along with setting up a clean database.
47 | - name: Setup Environment
48 | run: |
49 | docker-compose -f docker-compose.ci.yml run --rm --user="$(id -u):$(id -g)" test ./bin/setup
50 | # Finally run the tests :D
51 | - name: Run tests
52 | run: |
53 | docker-compose -f docker-compose.ci.yml run --rm --user="$(id -u):$(id -g)" test
54 |
55 | # This will remove any dangling docker data & stop our cache from ballooning out of control.
56 | - name: Clean Up After Tests
57 | run: |
58 | docker image prune -f
59 | docker volume prune -f
60 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = function(api) {
2 | var validEnv = ['development', 'test', 'production']
3 | var currentEnv = api.env()
4 | var isDevelopmentEnv = api.env('development')
5 | var isProductionEnv = api.env('production')
6 | var isTestEnv = api.env('test')
7 |
8 | if (!validEnv.includes(currentEnv)) {
9 | throw new Error(
10 | 'Please specify a valid `NODE_ENV` or ' +
11 | '`BABEL_ENV` environment variables. Valid values are "development", ' +
12 | '"test", and "production". Instead, received: ' +
13 | JSON.stringify(currentEnv) +
14 | '.'
15 | )
16 | }
17 |
18 | return {
19 | presets: [
20 | isTestEnv && [
21 | '@babel/preset-env',
22 | {
23 | targets: {
24 | node: 'current'
25 | }
26 | }
27 | ],
28 | (isProductionEnv || isDevelopmentEnv) && [
29 | '@babel/preset-env',
30 | {
31 | forceAllTransforms: true,
32 | useBuiltIns: 'entry',
33 | corejs: 3,
34 | modules: false,
35 | exclude: ['transform-typeof-symbol']
36 | }
37 | ]
38 | ].filter(Boolean),
39 | plugins: [
40 | 'babel-plugin-macros',
41 | '@babel/plugin-syntax-dynamic-import',
42 | isTestEnv && 'babel-plugin-dynamic-import-node',
43 | '@babel/plugin-transform-destructuring',
44 | [
45 | '@babel/plugin-proposal-class-properties',
46 | {
47 | loose: true
48 | }
49 | ],
50 | [
51 | '@babel/plugin-proposal-object-rest-spread',
52 | {
53 | useBuiltIns: true
54 | }
55 | ],
56 | [
57 | '@babel/plugin-proposal-private-methods',
58 | {
59 | loose: true
60 | }
61 | ],
62 | [
63 | '@babel/plugin-proposal-private-property-in-object',
64 | {
65 | loose: true
66 | }
67 | ],
68 | [
69 | '@babel/plugin-transform-runtime',
70 | {
71 | helpers: false
72 | }
73 | ],
74 | [
75 | '@babel/plugin-transform-regenerator',
76 | {
77 | async: false
78 | }
79 | ]
80 | ].filter(Boolean)
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | require "active_support/core_ext/integer/time"
2 |
3 | # The test environment is used exclusively to run your application's
4 | # test suite. You never need to work with it otherwise. Remember that
5 | # your test database is "scratch space" for the test suite and is wiped
6 | # and recreated between test runs. Don't rely on the data there!
7 |
8 | Rails.application.configure do
9 | # Settings specified here will take precedence over those in config/application.rb.
10 |
11 | config.cache_classes = true
12 |
13 | # Do not eager load code on boot. This avoids loading your whole application
14 | # just for the purpose of running a single test. If you are using a tool that
15 | # preloads Rails for running tests, you may have to set it to true.
16 | config.eager_load = false
17 |
18 | # Configure public file server for tests with Cache-Control for performance.
19 | config.public_file_server.enabled = true
20 | config.public_file_server.headers = {
21 | "Cache-Control" => "public, max-age=#{1.hour.to_i}"
22 | }
23 |
24 | # Show full error reports and disable caching.
25 | config.consider_all_requests_local = true
26 | config.action_controller.perform_caching = false
27 | config.cache_store = :null_store
28 |
29 | # Raise exceptions instead of rendering exception templates.
30 | config.action_dispatch.show_exceptions = false
31 |
32 | # Disable request forgery protection in test environment.
33 | config.action_controller.allow_forgery_protection = false
34 |
35 | # Store uploaded files on the local file system in a temporary directory.
36 | config.active_storage.service = :test
37 |
38 | config.action_mailer.perform_caching = false
39 |
40 | # Tell Action Mailer not to deliver emails to the real world.
41 | # The :test delivery method accumulates sent emails in the
42 | # ActionMailer::Base.deliveries array.
43 | config.action_mailer.delivery_method = :test
44 |
45 | # Print deprecation notices to the stderr.
46 | config.active_support.deprecation = :stderr
47 |
48 | # Raise exceptions for disallowed deprecations.
49 | config.active_support.disallowed_deprecation = :raise
50 |
51 | # Tell Active Support which deprecation messages to disallow.
52 | config.active_support.disallowed_deprecation_warnings = []
53 |
54 | # Raises error for missing translations.
55 | # config.i18n.raise_on_missing_translations = true
56 |
57 | # Annotate rendered view with file names.
58 | # config.action_view.annotate_rendered_view_with_filenames = true
59 | end
60 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is a set up for Ruby on Rails 6, running a worker & webpack.
3 | # Gems are cached within a volume, which speeds up development when adding new gems.
4 | #
5 | ## Usage:
6 | #
7 | # docker-compose build
8 | # docker-compose run --rm web bin/setup
9 | # docker-compose up
10 | version: "3"
11 |
12 | x-app: &app
13 | build:
14 | context: .
15 | dockerfile: Dockerfile
16 | target: development
17 | tmpfs:
18 | - /tmp
19 | environment:
20 | REDIS_URL: redis://@redis:6379/1
21 | DATABASE_URL: postgres://postgres:postgres@postgres:5432/
22 | WEBPACKER_DEV_SERVER_HOST: webpacker
23 | entrypoint: ./bin/docker/entrypoints/wait-for-web.sh
24 | volumes:
25 | - .:/usr/src/app:cached
26 | - bundler:/usr/local/bundle:delegated
27 | - bootsnap_cache:/usr/src/bootsnap:delegated
28 | - rails_cache:/usr/src/app/tmp/cache:delegated
29 | - packs:/usr/src/app/public/packs:delegated
30 | - node_modules:/usr/src/app/node_modules:delegated
31 | - yarn_cache:/usr/src/yarn:delegated
32 | - letter_opener:/usr/src/app/tmp/letter_opener:delegated
33 | depends_on:
34 | - postgres
35 | - redis
36 |
37 | services:
38 | postgres:
39 | image: postgres:13.2-alpine
40 | volumes:
41 | - postgresql:/var/lib/postgresql/data:delegated
42 | # Uncomment to access this containers Postgres instance via port 5432
43 | #ports:
44 | #- "127.0.0.1:5432:5432"
45 | environment:
46 | PSQL_HISTFILE: /root/log/.psql_history
47 | POSTGRES_USER: postgres
48 | POSTGRES_PASSWORD: postgres
49 | restart: on-failure
50 | logging:
51 | driver: none
52 |
53 | redis:
54 | image: redis:6.0.12-alpine
55 | volumes:
56 | - redis:/data:delegated
57 | # Uncomment to access this containers Redis instance via port 6379
58 | #ports:
59 | #- "127.0.0.1:6379:6379"
60 | restart: on-failure
61 | logging:
62 | driver: none
63 |
64 | web:
65 | <<: *app
66 | entrypoint: ./bin/docker/entrypoints/wait-for-postgres.sh
67 | command: bash -c "./bin/docker/prepare-to-start-rails && ./bin/rails server -p 3000 -b '0.0.0.0'"
68 | ports:
69 | - "127.0.0.1:3000:3000"
70 |
71 | worker:
72 | <<: *app
73 | command: bundle exec sidekiq -C config/sidekiq.yml
74 |
75 | webpacker:
76 | <<: *app
77 | command: ./bin/webpack-dev-server
78 | environment:
79 | WEBPACKER_DEV_SERVER_HOST: 0.0.0.0
80 | ports:
81 | - "127.0.0.1:3035:3035"
82 |
83 | volumes:
84 | postgresql:
85 | redis:
86 | bundler:
87 | bootsnap_cache:
88 | rails_cache:
89 | packs:
90 | node_modules:
91 | yarn_cache:
92 | letter_opener:
93 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | [](https://github.com/Ruby-Starter-Kits/Docker-Rails-Template/generate)
4 |
5 |
6 |
7 | # Rails App
8 |
9 | Welcome to your [Ruby On Rails](https://rubyonrails.org/) app.
10 |
11 | ## Setup & Running Locally
12 |
13 | Clone down the repo, install [Docker](https://hub.docker.com/editions/community/docker-ce-desktop-mac/) & run:
14 |
15 | ```bash
16 | $ ./bin/docker/setup
17 | $ ./bin/docker/start
18 | ```
19 |
20 | This will build the docker image, then setup the `bin/setup` file which will run `bundle`, `yarn` & create the database.
21 |
22 | Then navigate your browser to https://127.0.0.1:3000/ to see your site.
23 |
24 | ### Running one of commands
25 |
26 | To run a one off command, run it within the web service, e.g:
27 |
28 | ```bash
29 | $ ./bin/docker/bundle exec rails db:migrate
30 | $ ./bin/docker/bundle
31 | $ ./bin/docker/yarn
32 | ```
33 |
34 | ### Restoring a database
35 |
36 | If you have an existing database dump in a file called `latest.dump`, you can restore it by turning on just the postgres service in one terminal tab, and running `pg_restore` in a secondary tab:
37 |
38 | ```bash
39 | $ docker-compose up postgres
40 | $ pg_restore --verbose --clean --no-acl --no-owner -j 2 -h localhost -d App_development --username postgres latest.dump
41 | ```
42 |
43 | ## Tests
44 |
45 | The template comes preconfigured with [RSpec](https://rspec.info/) for tests, and comes with a [GitHub Action](https://github.com/Ruby-Starter-Kits/Docker-Rails-Template/blob/master/.github/workflows/tests.yml) to run them when you push to GitHub.
46 |
47 | You can run RSpec locally by running:
48 |
49 | ```bash
50 | $ docker-compose -f docker-compose.ci.yml run --rm test
51 | ```
52 |
53 | ## Linting
54 |
55 | This app uses [Standard](https://github.com/testdouble/standard) for Ruby and includes a [GitHub Action](https://github.com/Ruby-Starter-Kits/Docker-Rails-Template/blob/master/.github/workflows/standard.yml) to check future commits are up to standard.
56 |
57 | ## Contributing
58 |
59 | This was generated by [Ruby-Starter-Kits/Docker-Rails-Generator](https://github.com/Ruby-Starter-Kits/Docker-Rails-Generator), if you have any ideas please report them there :)
60 |
61 | ## Usage
62 |
63 | Feel free to use these as a starting point for your own Ruby on Rails project!
64 |
65 | ## Resources
66 |
67 | * [Ruby on Rails Guides](https://guides.rubyonrails.org/)
68 | * [Ruby on Rails API Documentation](https://api.rubyonrails.org/)
69 | * [Heroku](https://www.heroku.com/)
70 | * [Docker-Rails-Generator](https://github.com/Ruby-Starter-Kits/Docker-Rails-Generator)
71 |
72 | ## License
73 |
74 | [MIT](https://opensource.org/licenses/MIT)
75 |
76 | Copyright (c) 2020-present, [Mike Rogers](https://mikerogers.io/)
77 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | require "active_support/core_ext/integer/time"
2 |
3 | Rails.application.configure do
4 | # Settings specified here will take precedence over those in config/application.rb.
5 |
6 | # In the development environment your application's code is reloaded any time
7 | # it changes. This slows down response time but is perfect for development
8 | # since you don't have to restart the web server when you make code changes.
9 | config.cache_classes = false
10 |
11 | # Do not eager load code on boot.
12 | config.eager_load = false
13 |
14 | # Show full error reports.
15 | config.consider_all_requests_local = true
16 |
17 | # Enable/disable caching. By default caching is disabled.
18 | # Run rails dev:cache to toggle caching.
19 | if Rails.root.join("tmp", "caching-dev.txt").exist?
20 | config.action_controller.perform_caching = true
21 | config.action_controller.enable_fragment_cache_logging = true
22 |
23 | config.cache_store = :memory_store
24 | config.public_file_server.headers = {
25 | "Cache-Control" => "public, max-age=#{2.days.to_i}"
26 | }
27 | else
28 | config.action_controller.perform_caching = false
29 |
30 | config.cache_store = :null_store
31 | end
32 |
33 | # Store uploaded files on the local file system (see config/storage.yml for options).
34 | config.active_storage.service = :local
35 |
36 | # Don't care if the mailer can't send.
37 | config.action_mailer.raise_delivery_errors = false
38 |
39 | config.action_mailer.perform_caching = false
40 |
41 | # Print deprecation notices to the Rails logger.
42 | config.active_support.deprecation = :log
43 |
44 | # Raise exceptions for disallowed deprecations.
45 | config.active_support.disallowed_deprecation = :raise
46 |
47 | # Tell Active Support which deprecation messages to disallow.
48 | config.active_support.disallowed_deprecation_warnings = []
49 |
50 | # Raise an error on page load if there are pending migrations.
51 | config.active_record.migration_error = :page_load
52 |
53 | # Highlight code that triggered database queries in logs.
54 | config.active_record.verbose_query_logs = true
55 |
56 | # Debug mode disables concatenation and preprocessing of assets.
57 | # This option may cause significant delays in view rendering with a large
58 | # number of complex assets.
59 | config.assets.debug = true
60 |
61 | # Suppress logger output for asset requests.
62 | config.assets.quiet = true
63 |
64 | # Raises error for missing translations.
65 | # config.i18n.raise_on_missing_translations = true
66 |
67 | # Annotate rendered view with file names.
68 | # config.action_view.annotate_rendered_view_with_filenames = true
69 |
70 | # Use an evented file watcher to asynchronously detect changes in source code,
71 | # routes, locales, etc. This feature depends on the listen gem.
72 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker
73 |
74 | # Uncomment if you wish to allow Action Cable access from any origin.
75 | # config.action_cable.disable_request_forgery_protection = true
76 | end
77 |
--------------------------------------------------------------------------------
/spec/rails_helper.rb:
--------------------------------------------------------------------------------
1 | # This file is copied to spec/ when you run 'rails generate rspec:install'
2 | require "spec_helper"
3 | ENV["RAILS_ENV"] ||= "test"
4 | require File.expand_path("../config/environment", __dir__)
5 | # Prevent database truncation if the environment is production
6 | abort("The Rails environment is running in production mode!") if Rails.env.production?
7 | require "rspec/rails"
8 | # Add additional requires below this line. Rails is not loaded until this point!
9 |
10 | # Requires supporting ruby files with custom matchers and macros, etc, in
11 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
12 | # run as spec files by default. This means that files in spec/support that end
13 | # in _spec.rb will both be required and run as specs, causing the specs to be
14 | # run twice. It is recommended that you do not name files matching this glob to
15 | # end with _spec.rb. You can configure this pattern with the --pattern
16 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
17 | #
18 | # The following line is provided for convenience purposes. It has the downside
19 | # of increasing the boot-up time by auto-requiring all files in the support
20 | # directory. Alternatively, in the individual `*_spec.rb` files, manually
21 | # require only the support files necessary.
22 | #
23 | Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require f }
24 |
25 | # Checks for pending migrations and applies them before tests are run.
26 | # If you are not using ActiveRecord, you can remove these lines.
27 | begin
28 | ActiveRecord::Migration.maintain_test_schema!
29 | rescue ActiveRecord::PendingMigrationError => e
30 | puts e.to_s.strip
31 | exit 1
32 | end
33 |
34 | RSpec.configure do |config|
35 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
36 | config.fixture_path = "#{::Rails.root}/spec/fixtures"
37 |
38 | # If you're not using ActiveRecord, or you'd prefer not to run each of your
39 | # examples within a transaction, remove the following line or assign false
40 | # instead of true.
41 | config.use_transactional_fixtures = true
42 |
43 | # You can uncomment this line to turn off ActiveRecord support entirely.
44 | # config.use_active_record = false
45 |
46 | # RSpec Rails can automatically mix in different behaviours to your tests
47 | # based on their file location, for example enabling you to call `get` and
48 | # `post` in specs under `spec/controllers`.
49 | #
50 | # You can disable this behaviour by removing the line below, and instead
51 | # explicitly tag your specs with their type, e.g.:
52 | #
53 | # RSpec.describe UsersController, type: :controller do
54 | # # ...
55 | # end
56 | #
57 | # The different available types are documented in the features, such as in
58 | # https://relishapp.com/rspec/rspec-rails/docs
59 | config.infer_spec_type_from_file_location!
60 |
61 | # Filter lines from Rails gems in backtraces.
62 | config.filter_rails_from_backtrace!
63 | # arbitrary gems may also be filtered via:
64 | # config.filter_gems_from_backtrace("gem name")
65 | end
66 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # PostgreSQL. Versions 9.3 and up are supported.
2 | #
3 | # Install the pg driver:
4 | # gem install pg
5 | # On macOS with Homebrew:
6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7 | # On macOS with MacPorts:
8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9 | # On Windows:
10 | # gem install pg
11 | # Choose the win32 build.
12 | # Install PostgreSQL and put its /bin directory on your path.
13 | #
14 | # Configure Using Gemfile
15 | # gem 'pg'
16 | #
17 | default: &default
18 | adapter: postgresql
19 | encoding: unicode
20 | # For details on connection pooling, see Rails configuration guide
21 | # https://guides.rubyonrails.org/configuring.html#database-pooling
22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23 | url: <%= ENV['DATABASE_URL'] %>
24 |
25 | development:
26 | <<: *default
27 | database: App_development
28 |
29 | # The specified database role being used to connect to postgres.
30 | # To create additional roles in postgres see `$ createuser --help`.
31 | # When left blank, postgres will use the default role. This is
32 | # the same name as the operating system user that initialized the database.
33 | #username: App
34 |
35 | # The password associated with the postgres role (username).
36 | #password:
37 |
38 | # Connect on a TCP socket. Omitted by default since the client uses a
39 | # domain socket that doesn't need configuration. Windows does not have
40 | # domain sockets, so uncomment these lines.
41 | #host: localhost
42 |
43 | # The TCP port the server listens on. Defaults to 5432.
44 | # If your server runs on a different port number, change accordingly.
45 | #port: 5432
46 |
47 | # Schema search path. The server defaults to $user,public
48 | #schema_search_path: myapp,sharedapp,public
49 |
50 | # Minimum log levels, in increasing order:
51 | # debug5, debug4, debug3, debug2, debug1,
52 | # log, notice, warning, error, fatal, and panic
53 | # Defaults to warning.
54 | #min_messages: notice
55 |
56 | # Warning: The database defined as "test" will be erased and
57 | # re-generated from your development database when you run "rake".
58 | # Do not set this db to the same as development or production.
59 | test:
60 | <<: *default
61 | database: App_test
62 |
63 | # As with config/credentials.yml, you never want to store sensitive information,
64 | # like your database password, in your source code. If your source code is
65 | # ever seen by anyone, they now have access to your database.
66 | #
67 | # Instead, provide the password as a unix environment variable when you boot
68 | # the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
69 | # for a full rundown on how to provide these environment variables in a
70 | # production deployment.
71 | #
72 | # On Heroku and other platform providers, you may have a full connection URL
73 | # available as an environment variable. For example:
74 | #
75 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
76 | #
77 | # You can use this database configuration with:
78 | #
79 | # production:
80 | # url: <%= ENV['DATABASE_URL'] %>
81 | #
82 | production:
83 | <<: *default
84 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'bundle' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "rubygems"
12 |
13 | m = Module.new do
14 | module_function
15 |
16 | def invoked_as_script?
17 | File.expand_path($0) == File.expand_path(__FILE__)
18 | end
19 |
20 | def env_var_version
21 | ENV["BUNDLER_VERSION"]
22 | end
23 |
24 | def cli_arg_version
25 | return unless invoked_as_script? # don't want to hijack other binstubs
26 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27 | bundler_version = nil
28 | update_index = nil
29 | ARGV.each_with_index do |a, i|
30 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31 | bundler_version = a
32 | end
33 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34 | bundler_version = $1
35 | update_index = i
36 | end
37 | bundler_version
38 | end
39 |
40 | def gemfile
41 | gemfile = ENV["BUNDLE_GEMFILE"]
42 | return gemfile if gemfile && !gemfile.empty?
43 |
44 | File.expand_path("../../Gemfile", __FILE__)
45 | end
46 |
47 | def lockfile
48 | lockfile =
49 | case File.basename(gemfile)
50 | when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51 | else "#{gemfile}.lock"
52 | end
53 | File.expand_path(lockfile)
54 | end
55 |
56 | def lockfile_version
57 | return unless File.file?(lockfile)
58 | lockfile_contents = File.read(lockfile)
59 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60 | Regexp.last_match(1)
61 | end
62 |
63 | def bundler_version
64 | @bundler_version ||=
65 | env_var_version || cli_arg_version ||
66 | lockfile_version
67 | end
68 |
69 | def bundler_requirement
70 | return "#{Gem::Requirement.default}.a" unless bundler_version
71 |
72 | bundler_gem_version = Gem::Version.new(bundler_version)
73 |
74 | requirement = bundler_gem_version.approximate_recommendation
75 |
76 | return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77 |
78 | requirement += ".a" if bundler_gem_version.prerelease?
79 |
80 | requirement
81 | end
82 |
83 | def load_bundler!
84 | ENV["BUNDLE_GEMFILE"] ||= gemfile
85 |
86 | activate_bundler
87 | end
88 |
89 | def activate_bundler
90 | gem_error = activation_error_handling do
91 | gem "bundler", bundler_requirement
92 | end
93 | return if gem_error.nil?
94 | require_error = activation_error_handling do
95 | require "bundler/version"
96 | end
97 | return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98 | warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99 | exit 42
100 | end
101 |
102 | def activation_error_handling
103 | yield
104 | nil
105 | rescue StandardError, LoadError => e
106 | e
107 | end
108 | end
109 |
110 | m.load_bundler!
111 |
112 | if m.invoked_as_script?
113 | load Gem.bin_path("bundler", "bundle")
114 | end
115 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ruby:3.0.1-alpine AS builder
2 | LABEL maintainer="Mike Rogers "
3 |
4 | RUN apk --no-cache add --virtual build-dependencies \
5 | build-base \
6 | openssl \
7 | # Nokogiri Libraries
8 | zlib-dev \
9 | libxml2-dev \
10 | libxslt-dev \
11 | # Postgres
12 | postgresql-dev \
13 | # JavaScript
14 | nodejs \
15 | yarn \
16 | # FFI Bindings in ruby (Run C Commands)
17 | libffi-dev \
18 | # Fixes watch file issues with things like HMR
19 | libnotify-dev
20 |
21 | # Dockerize allows us to wait for other containers to be ready before we run our own code.
22 | ENV DOCKERIZE_VERSION v0.6.1
23 | RUN wget -nv https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
24 | && tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
25 | && rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
26 |
27 | # Rails Specific libraries
28 | RUN apk --no-cache add \
29 | # ActiveStorage file inspection
30 | file \
31 | # Time zone data
32 | tzdata \
33 | # HTML to PDF conversion
34 | # ttf-ubuntu-font-family \
35 | # wkhtmltopdf \
36 | # Image Resizing
37 | imagemagick \
38 | vips \
39 | # Nice to have
40 | bash \
41 | git \
42 | # VIM is a handy editor for editing credentials
43 | vim \
44 | # Allows for mimemagic gem to be installed
45 | shared-mime-info
46 |
47 | # Install any extra dependencies via Aptfile - These are installed on Heroku
48 | # COPY Aptfile /usr/src/app/Aptfile
49 | # RUN apk add --update $(cat /usr/src/app/Aptfile | xargs)
50 |
51 | FROM builder AS development
52 |
53 | # Set common ENVs
54 | ENV BOOTSNAP_CACHE_DIR /usr/src/bootsnap
55 | ENV YARN_CACHE_FOLDER /usr/src/yarn
56 | ENV EDITOR vim
57 | ENV LANG en_US.UTF-8
58 | ENV BUNDLE_PATH /usr/local/bundle
59 | ENV RAILS_LOG_TO_STDOUT enabled
60 | ENV HISTFILE /usr/src/app/log/.bash_history
61 |
62 | # Set build args. These let linux users not run into file permission problems
63 | ARG USER_ID=${USER_ID:-1000}
64 | ARG GROUP_ID=${GROUP_ID:-1000}
65 |
66 | # Add non-root user and group with alpine first available uid, 1000
67 | RUN addgroup -g $USER_ID -S appgroup \
68 | && adduser -u $GROUP_ID -S appuser -G appgroup
69 |
70 | # Install multiple gems at the same time
71 | RUN bundle config set jobs $(nproc)
72 |
73 | # Create app directory in the conventional /usr/src/app
74 | RUN mkdir -p /usr/src/app \
75 | && mkdir -p /usr/src/app/node_modules \
76 | && mkdir -p /usr/src/app/public/packs \
77 | && mkdir -p /usr/src/app/tmp/cache \
78 | && mkdir -p $YARN_CACHE_FOLDER \
79 | && mkdir -p $BOOTSNAP_CACHE_DIR \
80 | && chown -R appuser:appgroup /usr/src/app \
81 | && chown -R appuser:appgroup $BUNDLE_PATH \
82 | && chown -R appuser:appgroup $BOOTSNAP_CACHE_DIR \
83 | && chown -R appuser:appgroup $YARN_CACHE_FOLDER
84 | WORKDIR /usr/src/app
85 |
86 | ENV PATH /usr/src/app/bin:$PATH
87 |
88 | # Add a script to be executed every time the container starts.
89 | COPY bin/docker/entrypoints/* /usr/bin/
90 | RUN chmod +x /usr/bin/wait-for-postgres.sh
91 | RUN chmod +x /usr/bin/wait-for-web.sh
92 | ENTRYPOINT ["/usr/bin/wait-for-postgres.sh"]
93 |
94 | # Define the user running the container
95 | USER appuser
96 |
97 | EXPOSE 3000
98 | CMD ["./bin/rails", "server", "-b", "0.0.0.0", "-p", "3000"]
99 |
100 | FROM development AS production
101 |
102 | ENV RAILS_ENV production
103 | ENV RACK_ENV production
104 | ENV NODE_ENV production
105 |
106 | COPY Gemfile /usr/src/app
107 | COPY .ruby-version /usr/src/app
108 | COPY Gemfile.lock /usr/src/app
109 |
110 | # Install Ruby Gems
111 | RUN bundle config set deployment 'true' \
112 | && bundle config set without 'development:test' \
113 | && bundle check || bundle install --jobs=$(nproc)
114 |
115 | COPY package.json /usr/src/app
116 | COPY yarn.lock /usr/src/app
117 |
118 | # Install Yarn Libraries
119 | RUN yarn install --frozen-lockfile --check-files
120 |
121 | # Chown files so non are root.
122 | COPY --chown=appuser:appgroup . /usr/src/app
123 |
124 | # Precompile the assets, yarn relay & bootsnap
125 | RUN RAILS_SERVE_STATIC_FILES=enabled \
126 | SECRET_KEY_BASE=secret-key-base \
127 | bundle exec rake assets:precompile \
128 | && bundle exec bootsnap precompile --gemfile app/ lib/
129 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3 | # The generated `.rspec` file contains `--require spec_helper` which will cause
4 | # this file to always be loaded, without a need to explicitly require it in any
5 | # files.
6 | #
7 | # Given that it is always loaded, you are encouraged to keep this file as
8 | # light-weight as possible. Requiring heavyweight dependencies from this file
9 | # will add to the boot time of your test suite on EVERY test run, even for an
10 | # individual file that may not need all of that loaded. Instead, consider making
11 | # a separate helper file that requires the additional dependencies and performs
12 | # the additional setup, and require it from the spec files that actually need
13 | # it.
14 | #
15 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16 | RSpec.configure do |config|
17 | # rspec-expectations config goes here. You can use an alternate
18 | # assertion/expectation library such as wrong or the stdlib/minitest
19 | # assertions if you prefer.
20 | config.expect_with :rspec do |expectations|
21 | # This option will default to `true` in RSpec 4. It makes the `description`
22 | # and `failure_message` of custom matchers include text for helper methods
23 | # defined using `chain`, e.g.:
24 | # be_bigger_than(2).and_smaller_than(4).description
25 | # # => "be bigger than 2 and smaller than 4"
26 | # ...rather than:
27 | # # => "be bigger than 2"
28 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29 | end
30 |
31 | # rspec-mocks config goes here. You can use an alternate test double
32 | # library (such as bogus or mocha) by changing the `mock_with` option here.
33 | config.mock_with :rspec do |mocks|
34 | # Prevents you from mocking or stubbing a method that does not exist on
35 | # a real object. This is generally recommended, and will default to
36 | # `true` in RSpec 4.
37 | mocks.verify_partial_doubles = true
38 | end
39 |
40 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41 | # have no way to turn it off -- the option exists only for backwards
42 | # compatibility in RSpec 3). It causes shared context metadata to be
43 | # inherited by the metadata hash of host groups and examples, rather than
44 | # triggering implicit auto-inclusion in groups with matching metadata.
45 | config.shared_context_metadata_behavior = :apply_to_host_groups
46 |
47 | # The settings below are suggested to provide a good initial experience
48 | # with RSpec, but feel free to customize to your heart's content.
49 | # # This allows you to limit a spec run to individual examples or groups
50 | # # you care about by tagging them with `:focus` metadata. When nothing
51 | # # is tagged with `:focus`, all examples get run. RSpec also provides
52 | # # aliases for `it`, `describe`, and `context` that include `:focus`
53 | # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
54 | # config.filter_run_when_matching :focus
55 | #
56 | # # Allows RSpec to persist some state between runs in order to support
57 | # # the `--only-failures` and `--next-failure` CLI options. We recommend
58 | # # you configure your source control system to ignore this file.
59 | # config.example_status_persistence_file_path = "spec/examples.txt"
60 | #
61 | # # Limits the available syntax to the non-monkey patched syntax that is
62 | # # recommended. For more details, see:
63 | # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
64 | # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
65 | # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
66 | # config.disable_monkey_patching!
67 | #
68 | # # Many RSpec users commonly either run the entire suite or an individual
69 | # # file, and it's useful to allow more verbose output when running an
70 | # # individual spec file.
71 | # if config.files_to_run.one?
72 | # # Use the documentation formatter for detailed output,
73 | # # unless a formatter has already been configured
74 | # # (e.g. via a command-line flag).
75 | # config.default_formatter = "doc"
76 | # end
77 | #
78 | # # Print the 10 slowest examples and example groups at the
79 | # # end of the spec run, to help surface which specs are running
80 | # # particularly slow.
81 | # config.profile_examples = 10
82 | #
83 | # # Run specs in random order to surface order dependencies. If you find an
84 | # # order dependency and want to debug it, you can fix the order by providing
85 | # # the seed, which is printed after each run.
86 | # # --seed 1234
87 | # config.order = :random
88 | #
89 | # # Seed global randomization in this process using the `--seed` CLI option.
90 | # # Setting this allows you to use `--seed` to deterministically reproduce
91 | # # test failures related to randomization by passing the same `--seed` value
92 | # # as the one that triggered the failure.
93 | # Kernel.srand config.seed
94 | end
95 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | require "active_support/core_ext/integer/time"
2 |
3 | Rails.application.configure do
4 | # Settings specified here will take precedence over those in config/application.rb.
5 |
6 | # Code is not reloaded between requests.
7 | config.cache_classes = true
8 |
9 | # Eager load code on boot. This eager loads most of Rails and
10 | # your application in memory, allowing both threaded web servers
11 | # and those relying on copy on write to perform better.
12 | # Rake tasks automatically ignore this option for performance.
13 | config.eager_load = true
14 |
15 | # Full error reports are disabled and caching is turned on.
16 | config.consider_all_requests_local = false
17 | config.action_controller.perform_caching = true
18 |
19 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
20 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
21 | # config.require_master_key = true
22 |
23 | # Disable serving static files from the `/public` folder by default since
24 | # Apache or NGINX already handles this.
25 | config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
26 |
27 | # Compress CSS using a preprocessor.
28 | # config.assets.css_compressor = :sass
29 |
30 | # Do not fallback to assets pipeline if a precompiled asset is missed.
31 | config.assets.compile = false
32 |
33 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
34 | # config.asset_host = 'http://assets.example.com'
35 |
36 | # Specifies the header that your server uses for sending files.
37 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
38 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
39 |
40 | # Store uploaded files on the local file system (see config/storage.yml for options).
41 | config.active_storage.service = :local
42 |
43 | # Mount Action Cable outside main process or domain.
44 | # config.action_cable.mount_path = nil
45 | # config.action_cable.url = 'wss://example.com/cable'
46 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
47 |
48 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
49 | # config.force_ssl = true
50 |
51 | # Include generic and useful information about system operation, but avoid logging too much
52 | # information to avoid inadvertent exposure of personally identifiable information (PII).
53 | config.log_level = :info
54 |
55 | # Prepend all log lines with the following tags.
56 | config.log_tags = [:request_id]
57 |
58 | # Use a different cache store in production.
59 | # config.cache_store = :mem_cache_store
60 |
61 | # Use a real queuing backend for Active Job (and separate queues per environment).
62 | # config.active_job.queue_adapter = :resque
63 | # config.active_job.queue_name_prefix = "App_production"
64 |
65 | config.action_mailer.perform_caching = false
66 |
67 | # Ignore bad email addresses and do not raise email delivery errors.
68 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
69 | # config.action_mailer.raise_delivery_errors = false
70 |
71 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
72 | # the I18n.default_locale when a translation cannot be found).
73 | config.i18n.fallbacks = true
74 |
75 | # Send deprecation notices to registered listeners.
76 | config.active_support.deprecation = :notify
77 |
78 | # Log disallowed deprecations.
79 | config.active_support.disallowed_deprecation = :log
80 |
81 | # Tell Active Support which deprecation messages to disallow.
82 | config.active_support.disallowed_deprecation_warnings = []
83 |
84 | # Use default logging formatter so that PID and timestamp are not suppressed.
85 | config.log_formatter = ::Logger::Formatter.new
86 |
87 | # Use a different logger for distributed setups.
88 | # require "syslog/logger"
89 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
90 |
91 | if ENV["RAILS_LOG_TO_STDOUT"].present?
92 | logger = ActiveSupport::Logger.new($stdout)
93 | logger.formatter = config.log_formatter
94 | config.logger = ActiveSupport::TaggedLogging.new(logger)
95 | end
96 |
97 | # Do not dump schema after migrations.
98 | config.active_record.dump_schema_after_migration = false
99 |
100 | # Inserts middleware to perform automatic connection switching.
101 | # The `database_selector` hash is used to pass options to the DatabaseSelector
102 | # middleware. The `delay` is used to determine how long to wait after a write
103 | # to send a subsequent read to the primary.
104 | #
105 | # The `database_resolver` class is used by the middleware to determine which
106 | # database is appropriate to use based on the time delay.
107 | #
108 | # The `database_resolver_context` class is used by the middleware to set
109 | # timestamps for the last write to the primary. The resolver uses the context
110 | # class timestamps to determine how long to wait before reading from the
111 | # replica.
112 | #
113 | # By default Rails will store a last write timestamp in the session. The
114 | # DatabaseSelector middleware is designed as such you can define your own
115 | # strategy for connection switching and pass that into the middleware through
116 | # these configuration options.
117 | # config.active_record.database_selector = { delay: 2.seconds }
118 | # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
119 | # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
120 | end
121 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | actioncable (6.1.4.1)
5 | actionpack (= 6.1.4.1)
6 | activesupport (= 6.1.4.1)
7 | nio4r (~> 2.0)
8 | websocket-driver (>= 0.6.1)
9 | actionmailbox (6.1.4.1)
10 | actionpack (= 6.1.4.1)
11 | activejob (= 6.1.4.1)
12 | activerecord (= 6.1.4.1)
13 | activestorage (= 6.1.4.1)
14 | activesupport (= 6.1.4.1)
15 | mail (>= 2.7.1)
16 | actionmailer (6.1.4.1)
17 | actionpack (= 6.1.4.1)
18 | actionview (= 6.1.4.1)
19 | activejob (= 6.1.4.1)
20 | activesupport (= 6.1.4.1)
21 | mail (~> 2.5, >= 2.5.4)
22 | rails-dom-testing (~> 2.0)
23 | actionpack (6.1.4.1)
24 | actionview (= 6.1.4.1)
25 | activesupport (= 6.1.4.1)
26 | rack (~> 2.0, >= 2.0.9)
27 | rack-test (>= 0.6.3)
28 | rails-dom-testing (~> 2.0)
29 | rails-html-sanitizer (~> 1.0, >= 1.2.0)
30 | actiontext (6.1.4.1)
31 | actionpack (= 6.1.4.1)
32 | activerecord (= 6.1.4.1)
33 | activestorage (= 6.1.4.1)
34 | activesupport (= 6.1.4.1)
35 | nokogiri (>= 1.8.5)
36 | actionview (6.1.4.1)
37 | activesupport (= 6.1.4.1)
38 | builder (~> 3.1)
39 | erubi (~> 1.4)
40 | rails-dom-testing (~> 2.0)
41 | rails-html-sanitizer (~> 1.1, >= 1.2.0)
42 | activejob (6.1.4.1)
43 | activesupport (= 6.1.4.1)
44 | globalid (>= 0.3.6)
45 | activemodel (6.1.4.1)
46 | activesupport (= 6.1.4.1)
47 | activerecord (6.1.4.1)
48 | activemodel (= 6.1.4.1)
49 | activesupport (= 6.1.4.1)
50 | activestorage (6.1.4.1)
51 | actionpack (= 6.1.4.1)
52 | activejob (= 6.1.4.1)
53 | activerecord (= 6.1.4.1)
54 | activesupport (= 6.1.4.1)
55 | marcel (~> 1.0.0)
56 | mini_mime (>= 1.1.0)
57 | activesupport (6.1.4.1)
58 | concurrent-ruby (~> 1.0, >= 1.0.2)
59 | i18n (>= 1.6, < 2)
60 | minitest (>= 5.1)
61 | tzinfo (~> 2.0)
62 | zeitwerk (~> 2.3)
63 | addressable (2.8.0)
64 | public_suffix (>= 2.0.2, < 5.0)
65 | ast (2.4.2)
66 | barnes (0.0.9)
67 | multi_json (~> 1)
68 | statsd-ruby (~> 1.1)
69 | bindex (0.8.1)
70 | bootsnap (1.9.1)
71 | msgpack (~> 1.0)
72 | builder (3.2.4)
73 | byebug (11.1.3)
74 | capybara (3.36.0)
75 | addressable
76 | matrix
77 | mini_mime (>= 0.1.3)
78 | nokogiri (~> 1.8)
79 | rack (>= 1.6.0)
80 | rack-test (>= 0.6.3)
81 | regexp_parser (>= 1.5, < 3.0)
82 | xpath (~> 3.2)
83 | childprocess (4.1.0)
84 | concurrent-ruby (1.1.9)
85 | connection_pool (2.2.5)
86 | crass (1.0.6)
87 | css_parser (1.10.0)
88 | addressable
89 | diff-lcs (1.4.4)
90 | dotenv (2.7.6)
91 | dotenv-rails (2.7.6)
92 | dotenv (= 2.7.6)
93 | railties (>= 3.2)
94 | erubi (1.10.0)
95 | et-orbi (1.2.6)
96 | tzinfo
97 | factory_bot (6.2.0)
98 | activesupport (>= 5.0.0)
99 | factory_bot_rails (6.2.0)
100 | factory_bot (~> 6.2.0)
101 | railties (>= 5.0.0)
102 | faraday (1.8.0)
103 | faraday-em_http (~> 1.0)
104 | faraday-em_synchrony (~> 1.0)
105 | faraday-excon (~> 1.1)
106 | faraday-httpclient (~> 1.0.1)
107 | faraday-net_http (~> 1.0)
108 | faraday-net_http_persistent (~> 1.1)
109 | faraday-patron (~> 1.0)
110 | faraday-rack (~> 1.0)
111 | multipart-post (>= 1.2, < 3)
112 | ruby2_keywords (>= 0.0.4)
113 | faraday-em_http (1.0.0)
114 | faraday-em_synchrony (1.0.0)
115 | faraday-excon (1.1.0)
116 | faraday-httpclient (1.0.1)
117 | faraday-net_http (1.0.1)
118 | faraday-net_http_persistent (1.2.0)
119 | faraday-patron (1.0.0)
120 | faraday-rack (1.0.0)
121 | ffi (1.15.4)
122 | fugit (1.5.2)
123 | et-orbi (~> 1.1, >= 1.1.8)
124 | raabro (~> 1.4)
125 | globalid (0.5.2)
126 | activesupport (>= 5.0)
127 | htmlentities (4.3.4)
128 | i18n (1.8.10)
129 | concurrent-ruby (~> 1.0)
130 | image_processing (1.12.1)
131 | mini_magick (>= 4.9.5, < 5)
132 | ruby-vips (>= 2.0.17, < 3)
133 | launchy (2.5.0)
134 | addressable (~> 2.7)
135 | letter_opener (1.7.0)
136 | launchy (~> 2.2)
137 | letter_opener_web (1.4.1)
138 | actionmailer (>= 3.2)
139 | letter_opener (~> 1.0)
140 | railties (>= 3.2)
141 | listen (3.7.0)
142 | rb-fsevent (~> 0.10, >= 0.10.3)
143 | rb-inotify (~> 0.9, >= 0.9.10)
144 | lograge (0.11.2)
145 | actionpack (>= 4)
146 | activesupport (>= 4)
147 | railties (>= 4)
148 | request_store (~> 1.0)
149 | loofah (2.12.0)
150 | crass (~> 1.0.2)
151 | nokogiri (>= 1.5.9)
152 | mail (2.7.1)
153 | mini_mime (>= 0.1.1)
154 | marcel (1.0.2)
155 | matrix (0.4.2)
156 | method_source (1.0.0)
157 | mini_magick (4.11.0)
158 | mini_mime (1.1.2)
159 | minitest (5.14.4)
160 | msgpack (1.4.2)
161 | multi_json (1.15.0)
162 | multipart-post (2.1.1)
163 | nio4r (2.5.8)
164 | nokogiri (1.12.5-x86_64-linux)
165 | racc (~> 1.4)
166 | parallel (1.21.0)
167 | parser (3.0.2.0)
168 | ast (~> 2.4.1)
169 | pg (1.2.3)
170 | premailer (1.15.0)
171 | addressable
172 | css_parser (>= 1.6.0)
173 | htmlentities (>= 4.0.0)
174 | premailer-rails (1.11.1)
175 | actionmailer (>= 3)
176 | premailer (~> 1.7, >= 1.7.9)
177 | public_suffix (4.0.6)
178 | puma (5.5.2)
179 | nio4r (~> 2.0)
180 | raabro (1.4.0)
181 | racc (1.6.0)
182 | rack (2.2.3)
183 | rack-mini-profiler (2.3.3)
184 | rack (>= 1.2.0)
185 | rack-proxy (0.7.0)
186 | rack
187 | rack-test (1.1.0)
188 | rack (>= 1.0, < 3)
189 | rails (6.1.4.1)
190 | actioncable (= 6.1.4.1)
191 | actionmailbox (= 6.1.4.1)
192 | actionmailer (= 6.1.4.1)
193 | actionpack (= 6.1.4.1)
194 | actiontext (= 6.1.4.1)
195 | actionview (= 6.1.4.1)
196 | activejob (= 6.1.4.1)
197 | activemodel (= 6.1.4.1)
198 | activerecord (= 6.1.4.1)
199 | activestorage (= 6.1.4.1)
200 | activesupport (= 6.1.4.1)
201 | bundler (>= 1.15.0)
202 | railties (= 6.1.4.1)
203 | sprockets-rails (>= 2.0.0)
204 | rails-dom-testing (2.0.3)
205 | activesupport (>= 4.2.0)
206 | nokogiri (>= 1.6)
207 | rails-html-sanitizer (1.4.2)
208 | loofah (~> 2.3)
209 | railties (6.1.4.1)
210 | actionpack (= 6.1.4.1)
211 | activesupport (= 6.1.4.1)
212 | method_source
213 | rake (>= 0.13)
214 | thor (~> 1.0)
215 | rainbow (3.0.0)
216 | rake (13.0.6)
217 | rb-fsevent (0.11.0)
218 | rb-inotify (0.10.1)
219 | ffi (~> 1.0)
220 | redis (4.5.1)
221 | regexp_parser (2.1.1)
222 | request_store (1.5.0)
223 | rack (>= 1.4)
224 | rexml (3.2.5)
225 | rspec-core (3.10.1)
226 | rspec-support (~> 3.10.0)
227 | rspec-expectations (3.10.1)
228 | diff-lcs (>= 1.2.0, < 2.0)
229 | rspec-support (~> 3.10.0)
230 | rspec-mocks (3.10.2)
231 | diff-lcs (>= 1.2.0, < 2.0)
232 | rspec-support (~> 3.10.0)
233 | rspec-rails (4.1.2)
234 | actionpack (>= 4.2)
235 | activesupport (>= 4.2)
236 | railties (>= 4.2)
237 | rspec-core (~> 3.10)
238 | rspec-expectations (~> 3.10)
239 | rspec-mocks (~> 3.10)
240 | rspec-support (~> 3.10)
241 | rspec-support (3.10.2)
242 | rubocop (1.22.3)
243 | parallel (~> 1.10)
244 | parser (>= 3.0.0.0)
245 | rainbow (>= 2.2.2, < 4.0)
246 | regexp_parser (>= 1.8, < 3.0)
247 | rexml
248 | rubocop-ast (>= 1.12.0, < 2.0)
249 | ruby-progressbar (~> 1.7)
250 | unicode-display_width (>= 1.4.0, < 3.0)
251 | rubocop-ast (1.12.0)
252 | parser (>= 3.0.1.1)
253 | rubocop-performance (1.11.5)
254 | rubocop (>= 1.7.0, < 2.0)
255 | rubocop-ast (>= 0.4.0)
256 | ruby-progressbar (1.11.0)
257 | ruby-vips (2.1.3)
258 | ffi (~> 1.12)
259 | ruby2_keywords (0.0.5)
260 | rubyzip (2.3.2)
261 | sass-rails (6.0.0)
262 | sassc-rails (~> 2.1, >= 2.1.1)
263 | sassc (2.4.0)
264 | ffi (~> 1.9)
265 | sassc-rails (2.1.2)
266 | railties (>= 4.0.0)
267 | sassc (>= 2.0)
268 | sprockets (> 3.0)
269 | sprockets-rails
270 | tilt
271 | selenium-webdriver (4.0.3)
272 | childprocess (>= 0.5, < 5.0)
273 | rexml (~> 3.2, >= 3.2.5)
274 | rubyzip (>= 1.2.2)
275 | semantic_range (3.0.0)
276 | sentry-raven (3.1.2)
277 | faraday (>= 1.0)
278 | sidekiq (6.2.2)
279 | connection_pool (>= 2.2.2)
280 | rack (~> 2.0)
281 | redis (>= 4.2.0)
282 | sidekiq-cron (1.2.0)
283 | fugit (~> 1.1)
284 | sidekiq (>= 4.2.1)
285 | sprockets (4.0.2)
286 | concurrent-ruby (~> 1.0)
287 | rack (> 1, < 3)
288 | sprockets-rails (3.2.2)
289 | actionpack (>= 4.0)
290 | activesupport (>= 4.0)
291 | sprockets (>= 3.0.0)
292 | standard (1.4.0)
293 | rubocop (= 1.22.3)
294 | rubocop-performance (= 1.11.5)
295 | standardrb (1.0.0)
296 | standard
297 | statsd-ruby (1.5.0)
298 | thor (1.1.0)
299 | tilt (2.0.10)
300 | turbolinks (5.2.1)
301 | turbolinks-source (~> 5.2)
302 | turbolinks-source (5.2.0)
303 | tzinfo (2.0.4)
304 | concurrent-ruby (~> 1.0)
305 | unicode-display_width (2.1.0)
306 | web-console (4.1.0)
307 | actionview (>= 6.0.0)
308 | activemodel (>= 6.0.0)
309 | bindex (>= 0.4.0)
310 | railties (>= 6.0.0)
311 | webdrivers (5.0.0)
312 | nokogiri (~> 1.6)
313 | rubyzip (>= 1.3.0)
314 | selenium-webdriver (~> 4.0)
315 | webpacker (5.4.3)
316 | activesupport (>= 5.2)
317 | rack-proxy (>= 0.6.1)
318 | railties (>= 5.2)
319 | semantic_range (>= 2.3.0)
320 | websocket-driver (0.7.5)
321 | websocket-extensions (>= 0.1.0)
322 | websocket-extensions (0.1.5)
323 | xpath (3.2.0)
324 | nokogiri (~> 1.8)
325 | zeitwerk (2.5.1)
326 |
327 | PLATFORMS
328 | x86_64-linux
329 |
330 | DEPENDENCIES
331 | barnes (~> 0.0.8)
332 | bootsnap (>= 1.4.4)
333 | byebug
334 | capybara (>= 3.26)
335 | dotenv-rails (~> 2.7)
336 | factory_bot_rails
337 | image_processing (~> 1.12)
338 | letter_opener (~> 1.7)
339 | letter_opener_web (~> 1.4)
340 | listen (~> 3.3)
341 | lograge (~> 0.11.2)
342 | pg (~> 1.1)
343 | premailer-rails (~> 1.11)
344 | puma (~> 5.0)
345 | rack-mini-profiler (~> 2.0)
346 | rails (~> 6.1.4, >= 6.1.4.1)
347 | redis (~> 4.2)
348 | rspec-rails (~> 4.0)
349 | sass-rails (>= 6)
350 | selenium-webdriver
351 | sentry-raven (~> 3.1)
352 | sidekiq (~> 6.1)
353 | sidekiq-cron (~> 1.2)
354 | standardrb (~> 1.0)
355 | turbolinks (~> 5)
356 | tzinfo-data
357 | web-console (>= 4.1.0)
358 | webdrivers
359 | webpacker (~> 5.0)
360 |
361 | RUBY VERSION
362 | ruby 3.0.1p64
363 |
364 | BUNDLED WITH
365 | 2.2.15
366 |
--------------------------------------------------------------------------------