├── 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
│ ├── javascripts
│ │ └── application.js
│ └── stylesheets
│ │ └── application.css
├── models
│ ├── concerns
│ │ └── .keep
│ ├── application_record.rb
│ └── post.rb
├── controllers
│ ├── concerns
│ │ └── .keep
│ ├── application_controller.rb
│ └── home_controller.rb
├── views
│ ├── layouts
│ │ ├── mailer.text.erb
│ │ ├── mailer.html.erb
│ │ └── application.html.erb
│ └── home
│ │ └── show.html.erb
├── helpers
│ └── application_helper.rb
├── jobs
│ └── application_job.rb
├── mailers
│ └── application_mailer.rb
└── javascript
│ └── packs
│ ├── application.js
│ └── hello_react.jsx
├── .docker
├── .bashrc
├── .pryrc
└── .psqlrc
├── .postcssrc.yml
├── .pryrc
├── bin
├── rake
├── bundle
├── rails
├── yarn
├── webpack
├── webpack-dev-server
├── setup
└── update
├── config
├── webpack
│ ├── environment.js
│ ├── test.js
│ ├── production.js
│ └── development.js
├── initializers
│ ├── web-console.rb
│ ├── mime_types.rb
│ ├── filter_parameter_logging.rb
│ ├── application_controller_renderer.rb
│ ├── cookies_serializer.rb
│ ├── backtrace_silencers.rb
│ ├── wrap_parameters.rb
│ ├── assets.rb
│ ├── inflections.rb
│ └── content_security_policy.rb
├── environment.rb
├── routes.rb
├── boot.rb
├── sidekiq.yml
├── database.yml
├── credentials.yml.enc
├── locales
│ └── en.yml
├── storage.yml
├── application.rb
├── puma.rb
├── webpacker.yml
└── environments
│ ├── test.rb
│ ├── development.rb
│ └── production.rb
├── config.ru
├── Rakefile
├── db
├── migrate
│ └── 20180930124218_add_posts.rb
└── seeds.rb
├── .gitignore
├── package.json
├── .babelrc
├── docker-compose.dip.yml
├── dip.yml
├── Dockerfile
├── Gemfile
├── docker-compose.yml
├── README.md
└── Gemfile.lock
/vendor/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/assets/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/tasks/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/assets/images/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/models/concerns/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/controllers/concerns/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.docker/.bashrc:
--------------------------------------------------------------------------------
1 | alias be="bundle exec"
2 |
--------------------------------------------------------------------------------
/public/apple-touch-icon-precomposed.png:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/views/layouts/mailer.text.erb:
--------------------------------------------------------------------------------
1 | <%= yield %>
2 |
--------------------------------------------------------------------------------
/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/views/home/show.html.erb:
--------------------------------------------------------------------------------
1 | <%= javascript_pack_tag 'hello_react' %>
2 |
--------------------------------------------------------------------------------
/.postcssrc.yml:
--------------------------------------------------------------------------------
1 | plugins:
2 | postcss-import: {}
3 | postcss-cssnext: {}
4 |
--------------------------------------------------------------------------------
/app/jobs/application_job.rb:
--------------------------------------------------------------------------------
1 | class ApplicationJob < ActiveJob::Base
2 | end
3 |
--------------------------------------------------------------------------------
/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | end
3 |
--------------------------------------------------------------------------------
/.pryrc:
--------------------------------------------------------------------------------
1 | Pry.config.history.should_save = true
2 | Pry.config.history.file = File.join(__dir__, '.pry_history')
3 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require_relative '../config/boot'
3 | require 'rake'
4 | Rake.application.run
5 |
--------------------------------------------------------------------------------
/app/models/application_record.rb:
--------------------------------------------------------------------------------
1 | class ApplicationRecord < ActiveRecord::Base
2 | self.abstract_class = true
3 | end
4 |
--------------------------------------------------------------------------------
/config/webpack/environment.js:
--------------------------------------------------------------------------------
1 | const { environment } = require('@rails/webpacker')
2 |
3 | module.exports = environment
4 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2 |
--------------------------------------------------------------------------------
/app/assets/config/manifest.js:
--------------------------------------------------------------------------------
1 | //= link_tree ../images
2 | //= link_directory ../javascripts .js
3 | //= link_directory ../stylesheets .css
4 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/app/mailers/application_mailer.rb:
--------------------------------------------------------------------------------
1 | class ApplicationMailer < ActionMailer::Base
2 | default from: 'from@example.com'
3 | layout 'mailer'
4 | end
5 |
--------------------------------------------------------------------------------
/app/models/post.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Post < ApplicationRecord
4 | validates :title, :content, presence: true
5 | end
6 |
--------------------------------------------------------------------------------
/app/controllers/home_controller.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class HomeController < ApplicationController
4 | def show
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/config/initializers/web-console.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | config.web_console.whitelisted_ips = '172.0.0.0/8'
3 | end if Rails.env.development?
4 |
--------------------------------------------------------------------------------
/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/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
3 | root to: "home#show"
4 | end
5 |
--------------------------------------------------------------------------------
/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/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/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 |
--------------------------------------------------------------------------------
/config/sidekiq.yml:
--------------------------------------------------------------------------------
1 | ---
2 | :concurrency: <%= ENV['SIDEKIQ_CONCURRENCY'] || ENV['RAILS_MAX_THREADS'] || 10 %>
3 |
4 | development:
5 | :concurrency: 2
6 |
7 | timeout: 25
8 |
9 | :queues:
10 | - default
11 | - mailers
12 |
--------------------------------------------------------------------------------
/.docker/.pryrc:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | if ENV["HISTFILE"]
4 | hist_dir = ENV["HISTFILE"].sub(/\/[^\/]+$/, "")
5 | Pry.config.history.should_save = true
6 | Pry.config.history.file = File.join(hist_dir, ".pry_history")
7 | end
8 |
--------------------------------------------------------------------------------
/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 += [:password]
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 |
--------------------------------------------------------------------------------
/db/migrate/20180930124218_add_posts.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class AddPosts < ActiveRecord::Migration[5.2]
4 | def change
5 | create_table :posts do |t|
6 | t.string :title
7 | t.text :content
8 | t.timestamps
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.bundle/
2 | /.env
3 | /.env.*
4 | /.pry_history
5 | /.vscode
6 | /config/master.key
7 | /coverage/
8 | /log/
9 | !/log/.keep
10 | /node_modules/
11 | /public/assets/
12 | /public/packs/
13 | /public/packs-test/
14 | /storage/
15 | !/storage/.keep
16 | /tmp/
17 | !/tmp/.keep
18 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/views/layouts/mailer.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 | <%= yield %>
12 |
13 |
14 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "app",
3 | "private": true,
4 | "dependencies": {
5 | "@rails/webpacker": "3.5",
6 | "babel-preset-react": "^6.24.1",
7 | "prop-types": "^15.6.2",
8 | "react": "^16.5.2",
9 | "react-dom": "^16.5.2"
10 | },
11 | "devDependencies": {
12 | "webpack-dev-server": "2.11.2"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/bin/yarn:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | APP_ROOT = File.expand_path('..', __dir__)
3 | Dir.chdir(APP_ROOT) do
4 | begin
5 | exec "yarnpkg", *ARGV
6 | rescue Errno::ENOENT
7 | $stderr.puts "Yarn executable was not detected in the system."
8 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9 | exit 1
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | App
5 | <%= csrf_meta_tags %>
6 | <%= csp_meta_tag %>
7 |
8 | <%= stylesheet_link_tag 'application', media: 'all' %>
9 | <%= javascript_include_tag 'application' %>
10 | <%= javascript_pack_tag 'application' %>
11 |
12 |
13 |
14 | <%= yield %>
15 |
16 |
17 |
--------------------------------------------------------------------------------
/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 "rubygems"
11 | require "bundler/setup"
12 |
13 | require "webpacker"
14 | require "webpacker/webpack_runner"
15 | Webpacker::WebpackRunner.run(ARGV)
16 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | default: &default
2 | adapter: postgresql
3 | host: <%= ENV['DB_HOST'] %>
4 | username: <%= ENV['DB_USER'] %>
5 | password: <%= ENV['DB_PASSWORD'] %>
6 | pool: <%= ENV['DB_POOL_SIZE'] || 5 %>
7 | timeout: 5000
8 |
9 | development:
10 | <<: *default
11 | database: app
12 |
13 | test:
14 | <<: *default
15 | database: app_test
16 |
17 | production:
18 | <<: *default
19 | database: app
20 |
--------------------------------------------------------------------------------
/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 "rubygems"
11 | require "bundler/setup"
12 |
13 | require "webpacker"
14 | require "webpacker/dev_server_runner"
15 | Webpacker::DevServerRunner.run(ARGV)
16 |
--------------------------------------------------------------------------------
/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| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/config/credentials.yml.enc:
--------------------------------------------------------------------------------
1 | PiQs/kootBVTlWVSYAH7DXDGXqWY7pjQnrcbB/xeXftgvQpAry2Ylxmm1H1jHXJHaCafrEy7pvcohzZ6+cUTEI6bWnFwyl9on5myys3TX+Ei/P4N+usc5d/tVARCxdCN39yJePWmnnkfIz44ADp6Y4lPbepUkAu/hwJaiaMPuUXphDj/SXaTuzuehVaLhEBcoQh2HIsAc2/KTWeNnmZMDN4r1hwli5+eGODruIX078ikj81VIYXzex56jMv/s5UOkU1fyDbOWLz/KgJYr8xr+Tq4pBObqDsWPVhi+jLSqZnhAAYcmi3UbJnwhMpCWY19xpefnZlR1Fs0OkgrfJxUsQdAENGnZ+/nzMfAdlLh8IWazIiFxiXz6DgHl53N9z9GJnztGIkLUMjHWVWqeJV7z3LDAKsYpVxnteTS--uDe8j8fHcGxX/3bo--M+BG6S7Ap75cmmfUOS11iw==
--------------------------------------------------------------------------------
/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 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 |
9 | Post.create!(title: "Awesome DIP", content: "Example modern RoR application on Docker.")
10 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "env",
5 | {
6 | "modules": false,
7 | "targets": {
8 | "browsers": "> 1%",
9 | "uglify": true
10 | },
11 | "useBuiltIns": true
12 | }
13 | ],
14 | "react"
15 | ],
16 | "plugins": [
17 | "syntax-dynamic-import",
18 | "transform-object-rest-spread",
19 | [
20 | "transform-class-properties",
21 | {
22 | "spec": true
23 | }
24 | ]
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/javascript/packs/application.js:
--------------------------------------------------------------------------------
1 | /* eslint no-console:0 */
2 | // This file is automatically compiled by Webpack, along with any other files
3 | // present in this directory. You're encouraged to place your actual application logic in
4 | // a relevant structure within app/javascript and only use these pack files to reference
5 | // that code so it'll be compiled.
6 | //
7 | // To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
8 | // layout file, like app/views/layouts/application.html.erb
9 |
10 | console.log('Hello World from Webpacker')
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 |
--------------------------------------------------------------------------------
/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into application.js, which will include all the files
2 | // listed below.
3 | //
4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
5 | // vendor/assets/javascripts directory can be referenced here using a relative path.
6 | //
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 | // compiled file. JavaScript code in this file should be added after the last require_* statement.
9 | //
10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11 | // about supported directives.
12 | //
13 | //= require rails-ujs
14 | //= require activestorage
15 | //= require_tree .
16 |
--------------------------------------------------------------------------------
/app/javascript/packs/hello_react.jsx:
--------------------------------------------------------------------------------
1 | // Run this example by adding <%= javascript_pack_tag 'hello_react' %> to the head of your layout file,
2 | // like app/views/layouts/application.html.erb. All it does is render Hello React
at the bottom
3 | // of the page.
4 |
5 | import React from 'react'
6 | import ReactDOM from 'react-dom'
7 | import PropTypes from 'prop-types'
8 |
9 | const Hello = props => (
10 | Hello {props.name}!
11 | )
12 |
13 | Hello.defaultProps = {
14 | name: 'David'
15 | }
16 |
17 | Hello.propTypes = {
18 | name: PropTypes.string
19 | }
20 |
21 | document.addEventListener('DOMContentLoaded', () => {
22 | ReactDOM.render(
23 | ,
24 | document.body.appendChild(document.createElement('div')),
25 | )
26 | })
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 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'fileutils'
3 | include FileUtils
4 |
5 | # path to your application root.
6 | APP_ROOT = File.expand_path('..', __dir__)
7 |
8 | def system!(*args)
9 | system(*args) || abort("\n== Command #{args} failed ==")
10 | end
11 |
12 | chdir APP_ROOT do
13 | # This script is a starting point to setup your application.
14 | # Add necessary setup steps to this file.
15 |
16 | puts '== Installing dependencies =='
17 | system! 'gem install bundler --conservative'
18 | system('bundle check') || system!('bundle install')
19 |
20 | # Install JavaScript dependencies
21 | system! 'bin/yarn'
22 |
23 | puts "\n== Preparing database =="
24 | system! "bundle exec rake db:create db:structure:load"
25 | system! "bundle exec rake db:test:prepare"
26 | system! "bundle exec rake db:seed"
27 | end
28 |
--------------------------------------------------------------------------------
/.docker/.psqlrc:
--------------------------------------------------------------------------------
1 | -- Don't display the "helpful" message on startup.
2 | \set QUIET 1
3 |
4 | -- psql writes to a temporary file before then moving that temporary file on top of the old history file
5 | -- a bind mount of a file only bind mounts the inode, so a rename like this won't ever work
6 | \set HISTFILE /var/log/psql_history/.psql_history
7 |
8 | -- Show how long each query takes to execute
9 | \timing
10 |
11 | -- Use best available output format
12 | \x auto
13 |
14 | -- Verbose error reports
15 | \set VERBOSITY verbose
16 |
17 | -- If a command is run more than once in a row,
18 | -- only store it once in the history
19 | \set HISTCONTROL ignoredups
20 | \set COMP_KEYWORD_CASE upper
21 |
22 | -- By default, NULL displays as an empty space. Is it actually an empty
23 | -- string, or is it null? This makes that distinction visible
24 | \pset null '[NULL]'
25 |
26 | \unset QUIET
27 |
--------------------------------------------------------------------------------
/docker-compose.dip.yml:
--------------------------------------------------------------------------------
1 | version: '3.4'
2 |
3 | services:
4 | app:
5 | networks:
6 | frontend:
7 |
8 | backend:
9 | networks:
10 | frontend:
11 |
12 | rails:
13 | environment:
14 | VIRTUAL_HOST: ${APP_HOST}
15 | VIRTUAL_PATH: '/'
16 | VIRTUAL_PORT: 3000
17 | networks:
18 | frontend:
19 |
20 | webpack:
21 | environment:
22 | WEBPACKER_DEV_SERVER_PUBLIC: webpack.${APP_HOST}
23 | VIRTUAL_HOST: webpack.${APP_HOST}
24 | VIRTUAL_PATH: '/'
25 | VIRTUAL_PORT: 3035
26 | networks:
27 | frontend:
28 |
29 | sidekiq:
30 | networks:
31 | frontend:
32 |
33 | mail:
34 | environment:
35 | VIRTUAL_HOST: mail.${APP_HOST}
36 | VIRTUAL_PATH: '/'
37 | VIRTUAL_PORT: 1080
38 | networks:
39 | frontend:
40 |
41 | networks:
42 | frontend:
43 | external:
44 | name: frontend
45 |
--------------------------------------------------------------------------------
/bin/update:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'fileutils'
3 | include FileUtils
4 |
5 | # path to your application root.
6 | APP_ROOT = File.expand_path('..', __dir__)
7 |
8 | def system!(*args)
9 | system(*args) || abort("\n== Command #{args} failed ==")
10 | end
11 |
12 | chdir APP_ROOT do
13 | # This script is a way to update your development environment automatically.
14 | # Add necessary update steps to this file.
15 |
16 | puts '== Installing dependencies =='
17 | system! 'gem install bundler --conservative'
18 | system('bundle check') || system!('bundle install')
19 |
20 | # Install JavaScript dependencies if using Yarn
21 | # system('bin/yarn')
22 |
23 | puts "\n== Updating database =="
24 | system! 'bin/rails db:migrate'
25 |
26 | puts "\n== Removing old logs and tempfiles =="
27 | system! 'bin/rails log:clear tmp:clear'
28 |
29 | puts "\n== Restarting application server =="
30 | system! 'bin/rails restart'
31 | end
32 |
--------------------------------------------------------------------------------
/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 http://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 |
--------------------------------------------------------------------------------
/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 |
15 | # # Specify URI for violation reports
16 | # # policy.report_uri "/csp-violation-report-endpoint"
17 | # end
18 |
19 | # If you are using UJS then enable automatic nonce generation
20 | # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
21 |
22 | # Report CSP violations to a specified URI
23 | # For further information see the following documentation:
24 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
25 | # Rails.application.config.content_security_policy_report_only = true
26 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require_relative 'boot'
2 |
3 | require "rails"
4 | # Pick the frameworks you want:
5 | require "active_model/railtie"
6 | require "active_job/railtie"
7 | require "active_record/railtie"
8 | require "active_storage/engine"
9 | require "action_controller/railtie"
10 | require "action_mailer/railtie"
11 | require "action_view/railtie"
12 | # require "action_cable/engine"
13 | require "sprockets/railtie"
14 | # require "rails/test_unit/railtie"
15 |
16 | # Require the gems listed in Gemfile, including any gems
17 | # you've limited to :test, :development, or :production.
18 | Bundler.require(*Rails.groups)
19 |
20 | module App
21 | class Application < Rails::Application
22 | # Initialize configuration defaults for originally generated Rails version.
23 | config.load_defaults 5.2
24 |
25 | # Settings in config/environments/* take precedence over those specified here.
26 | # Application configuration can go into files in config/initializers
27 | # -- all .rb files in that directory are automatically loaded after loading
28 | # the framework and any gems in your application.
29 |
30 | # Don't generate system test files.
31 | config.generators.system_tests = nil
32 |
33 | config.active_job.queue_adapter = :sidekiq
34 |
35 | config.active_record.schema_format = :sql
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/dip.yml:
--------------------------------------------------------------------------------
1 | version: '2'
2 |
3 | environment:
4 | RAILS_ENV: development
5 | DOCKER_TLD: docker
6 | APP_HOST: dip-rails.${DOCKER_TLD}
7 | WEB_PORT: 3000
8 | WEBPACK_PORT: 3035
9 | MAIL_WEB_PORT: 1080
10 |
11 | compose:
12 | files:
13 | - docker-compose.yml
14 | - docker-compose.dip.yml
15 |
16 | interaction:
17 | bash:
18 | service: backend
19 | command: /bin/bash
20 | compose_run_options: [no-deps]
21 |
22 | bundle:
23 | service: backend
24 | command: bundle
25 |
26 | yarn:
27 | service: webpack
28 | command: yarn
29 |
30 | rake:
31 | service: backend
32 | command: bundle exec rake
33 |
34 | rails:
35 | service: backend
36 | command: bundle exec rails
37 | subcommands:
38 | s:
39 | service: rails
40 | compose_run_options: [service-ports]
41 |
42 | webpack:
43 | service: webpack
44 | compose_run_options: [service-ports, use-aliases]
45 |
46 | sidekiq:
47 | service: sidekiq
48 |
49 | rspec:
50 | service: backend
51 | environment:
52 | RAILS_ENV: test
53 | command: bundle exec rspec
54 |
55 | psql:
56 | service: postgres
57 | command: psql -h postgres -U postgres
58 |
59 | 'redis-cli':
60 | service: redis
61 | command: redis-cli -h redis
62 |
63 | provision:
64 | - dip compose down --volumes
65 | - dip compose up -d postgres redis
66 | - dip bash -c ./bin/setup
67 |
--------------------------------------------------------------------------------
/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 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8 | threads threads_count, threads_count
9 |
10 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
11 | #
12 | port ENV.fetch("PORT") { 3000 }
13 |
14 | # Specifies the `environment` that Puma will run in.
15 | #
16 | environment ENV.fetch("RAILS_ENV") { "development" }
17 |
18 | # Specifies the number of `workers` to boot in clustered mode.
19 | # Workers are forked webserver processes. If using threads and workers together
20 | # the concurrency of the application would be max `threads` * `workers`.
21 | # Workers do not work on JRuby or Windows (both of which do not support
22 | # processes).
23 | #
24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
25 |
26 | # Use the `preload_app!` method when specifying a `workers` number.
27 | # This directive tells Puma to first boot the application and load code
28 | # before forking the application. This takes advantage of Copy On Write
29 | # process behavior so workers use less memory.
30 | #
31 | # preload_app!
32 |
33 | # Allow puma to be restarted by `rails restart` command.
34 | plugin :tmp_restart
35 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ruby:2.6.1
2 |
3 | ARG PG_VERSION
4 | ARG NODE_VERSION
5 | ARG NODE_VERSION_MAJOR
6 | ARG YARN_VERSION
7 | ARG TINI_VERSION=v0.18.0
8 |
9 | RUN curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
10 | && echo 'deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' $PG_VERSION > /etc/apt/sources.list.d/pgdg.list \
11 | && curl -o /tmp/nodejs.deb https://deb.nodesource.com/node_$NODE_VERSION_MAJOR.x/pool/main/n/nodejs/nodejs_$NODE_VERSION-1nodesource1_amd64.deb \
12 | && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
13 | && echo 'deb http://dl.yarnpkg.com/debian/ stable main' > /etc/apt/sources.list.d/yarn.list \
14 | && apt-get update -qq \
15 | && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
16 | build-essential \
17 | less \
18 | vim \
19 | postgresql-client-$PG_VERSION \
20 | /tmp/nodejs.deb \
21 | yarn=$YARN_VERSION-1 \
22 | && apt-get clean \
23 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
24 | && truncate -s 0 /var/log/*log
25 |
26 | ENV LANG=C.UTF-8 \
27 | GEM_HOME=/bundle \
28 | BUNDLE_JOBS=4 \
29 | BUNDLE_RETRY=3
30 | ENV BUNDLE_PATH $GEM_HOME
31 | ENV BUNDLE_BIN=$BUNDLE_PATH/bin
32 | ENV BUNDLE_APP_CONFIG=.bundle
33 |
34 | RUN gem update --system && \
35 | gem install bundler:2.0.1
36 |
37 | ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
38 | RUN chmod +x /tini
39 |
40 | RUN mkdir -p /app
41 |
42 | WORKDIR /app
43 | ENTRYPOINT ["/tini", "--"]
44 |
--------------------------------------------------------------------------------
/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_output_path: packs
7 | cache_path: tmp/cache/webpacker
8 |
9 | # Additional paths webpack should lookup modules
10 | # ['app/assets', 'engine/foo/app/assets']
11 | resolved_paths: []
12 |
13 | # Reload manifest.json on all requests so we reload latest compiled packs
14 | cache_manifest: false
15 |
16 | extensions:
17 | - .jsx
18 | - .js
19 | - .sass
20 | - .scss
21 | - .css
22 | - .module.sass
23 | - .module.scss
24 | - .module.css
25 | - .png
26 | - .svg
27 | - .gif
28 | - .jpeg
29 | - .jpg
30 |
31 | development:
32 | <<: *default
33 | compile: true
34 |
35 | # Reference: https://webpack.js.org/configuration/dev-server/
36 | dev_server:
37 | https: false
38 | host: localhost
39 | port: 3035
40 | public: localhost:3035
41 | hmr: false
42 | # Inline should be set to true if using HMR
43 | inline: true
44 | overlay: true
45 | compress: true
46 | disable_host_check: true
47 | use_local_ip: false
48 | quiet: false
49 | headers:
50 | 'Access-Control-Allow-Origin': '*'
51 | watch_options:
52 | ignored: /node_modules/
53 |
54 | test:
55 | <<: *default
56 | compile: true
57 |
58 | # Compile test packs to a separate directory
59 | public_output_path: packs-test
60 |
61 | production:
62 | <<: *default
63 |
64 | # Production depends on precompilation of packs prior to booting for performance.
65 | compile: false
66 |
67 | # Cache manifest.json for performance
68 | cache_manifest: true
69 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3 |
4 | ruby '2.6.1'
5 |
6 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
7 | gem 'rails', '6.0.0.rc1'
8 | # Use postgresql as the database for Active Record
9 | gem "pg", "~> 1.0"
10 | # Use Puma as the app server
11 | gem 'puma', '~> 3.11'
12 | # Use SCSS for stylesheets
13 | gem 'sass-rails', '~> 5.0'
14 | # Use Uglifier as compressor for JavaScript assets
15 | gem 'uglifier', '>= 1.3.0'
16 | # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
17 | gem 'webpacker'
18 | # See https://github.com/rails/execjs#readme for more supported runtimes
19 | # gem 'mini_racer', platforms: :ruby
20 |
21 | # Use CoffeeScript for .coffee assets and views
22 | gem 'coffee-rails', '~> 4.2'
23 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
24 | gem 'jbuilder', '~> 2.5'
25 | # Use ActiveModel has_secure_password
26 | # gem 'bcrypt', '~> 3.1.7'
27 |
28 | # Use sidekiq for background jobs
29 | gem 'sidekiq', '~> 5.2'
30 |
31 | # Use ActiveStorage variant
32 | # gem 'mini_magick', '~> 4.8'
33 |
34 | # Use Capistrano for deployment
35 | # gem 'capistrano-rails', group: :development
36 |
37 | # Reduces boot times through caching; required in config/boot.rb
38 | gem 'bootsnap', '>= 1.4.3', require: false
39 |
40 | group :development, :test do
41 | gem 'pry-byebug'
42 | gem 'pry-rails'
43 | end
44 |
45 | group :development do
46 | # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
47 | gem 'web-console', '>= 3.3.0'
48 | end
49 |
50 |
51 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
52 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
53 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Do not eager load code on boot. This avoids loading your whole application
11 | # just for the purpose of running a single test. If you are using a tool that
12 | # preloads Rails for running tests, you may have to set it to true.
13 | config.eager_load = false
14 |
15 | # Configure public file server for tests with Cache-Control for performance.
16 | config.public_file_server.enabled = true
17 | config.public_file_server.headers = {
18 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
19 | }
20 |
21 | # Show full error reports and disable caching.
22 | config.consider_all_requests_local = true
23 | config.action_controller.perform_caching = false
24 |
25 | # Raise exceptions instead of rendering exception templates.
26 | config.action_dispatch.show_exceptions = false
27 |
28 | # Disable request forgery protection in test environment.
29 | config.action_controller.allow_forgery_protection = false
30 |
31 | # Store uploaded files on the local file system in a temporary directory
32 | config.active_storage.service = :test
33 |
34 | config.action_mailer.perform_caching = false
35 |
36 | # Tell Action Mailer not to deliver emails to the real world.
37 | # The :test delivery method accumulates sent emails in the
38 | # ActionMailer::Base.deliveries array.
39 | config.action_mailer.delivery_method = :test
40 |
41 | # Print deprecation notices to the stderr.
42 | config.active_support.deprecation = :stderr
43 |
44 | # Raises error for missing translations
45 | # config.action_view.raise_on_missing_translations = true
46 | end
47 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.4'
2 |
3 | services:
4 | app: &app
5 | build:
6 | context: .
7 | dockerfile: ./Dockerfile
8 | args:
9 | PG_VERSION: '11'
10 | NODE_VERSION: '11.8.0'
11 | NODE_VERSION_MAJOR: '11'
12 | YARN_VERSION: '1.13.0'
13 | image: dip-rails:0.2.0
14 | tmpfs:
15 | - /tmp
16 | environment: &app_env
17 | RAILS_ENV: ${RAILS_ENV:-development}
18 | HISTFILE: /bundle/.bash_history
19 | MALLOC_ARENA_MAX: 2
20 | networks:
21 | default:
22 | volumes:
23 | - .:/app:cached
24 | - rails_cache:/app/tmp/cache
25 | - bundle:/bundle
26 | - node_modules:/app/node_modules
27 | - assets:/app/public/assets
28 | - packs:/app/public/packs
29 | - packs_test:/app/public/packs-test
30 | - .docker/.bashrc:/root/.bashrc:ro
31 | - .docker/.pryrc:/app/.pryrc:ro
32 | - .docker/.psqlrc:/root/.psqlrc:ro
33 | - postgres_history:/var/log/psql_history
34 |
35 | backend: &backend
36 | <<: *app
37 | environment: &backend_env
38 | <<: *app_env
39 | REDIS_URL: redis://redis:6379/
40 | SMTP_HOST: mail
41 | DB_HOST: postgres
42 | DB_USER: postgres
43 | DB_PASSWORD: postgres
44 | WEBPACKER_DEV_SERVER_HOST: webpack
45 | depends_on:
46 | - postgres
47 | - redis
48 |
49 | rails:
50 | <<: *backend
51 | command: bundle exec rails server -b 0.0.0.0
52 | ports:
53 | - ${WEB_PORT:-3000:3000}
54 |
55 | webpack:
56 | <<: *app
57 | command: ./bin/webpack-dev-server
58 | ports:
59 | - ${WEBPACK_PORT:-3035:3035}
60 | environment:
61 | <<: *app_env
62 | WEBPACKER_DEV_SERVER_HOST: 0.0.0.0
63 |
64 | sidekiq:
65 | <<: *backend
66 | command: bundle exec sidekiq -q mailers -q default
67 |
68 | postgres:
69 | image: postgres:11.1
70 | volumes:
71 | - .docker/.psqlrc:/root/.psqlrc:ro
72 | - postgres:/var/lib/postgresql/data
73 | - postgres_history:/var/log/psql_history
74 | ports:
75 | - 5432
76 |
77 | redis:
78 | image: redis:3.2-alpine
79 | volumes:
80 | - redis:/data
81 | ports:
82 | - 6379
83 |
84 | mail:
85 | image: drujensen/mailcatcher:latest
86 | ports:
87 | - 1025
88 | - ${MAIL_WEB_PORT:-1080:1080}
89 | networks:
90 | default:
91 |
92 | volumes:
93 | postgres:
94 | postgres_history:
95 | redis:
96 | bundle:
97 | node_modules:
98 | assets:
99 | rails_cache:
100 | packs:
101 | packs_test:
102 | bash_history:
103 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Verifies that versions and hashed value of the package contents in the project's package.json
3 | config.webpacker.check_yarn_integrity = true
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 on
7 | # every request. 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 = true
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 |
22 | config.cache_store = :memory_store
23 | config.public_file_server.headers = {
24 | 'Cache-Control' => "public, max-age=#{2.days.to_i}"
25 | }
26 | else
27 | config.action_controller.perform_caching = false
28 |
29 | config.cache_store = :null_store
30 | end
31 |
32 | # Store uploaded files on the local file system (see config/storage.yml for options)
33 | config.active_storage.service = :local
34 |
35 | # Don't care if the mailer can't send.
36 | config.action_mailer.raise_delivery_errors = false
37 | config.action_mailer.perform_caching = false
38 | config.action_mailer.delivery_method = :smtp
39 | config.action_mailer.smtp_settings = {address: ENV['SMTP_HOST'] || 'localhost', port: 1025}
40 |
41 | # Print deprecation notices to the Rails logger.
42 | config.active_support.deprecation = :log
43 |
44 | # Raise an error on page load if there are pending migrations.
45 | config.active_record.migration_error = :page_load
46 |
47 | # Highlight code that triggered database queries in logs.
48 | config.active_record.verbose_query_logs = true
49 |
50 | # Debug mode disables concatenation and preprocessing of assets.
51 | # This option may cause significant delays in view rendering with a large
52 | # number of complex assets.
53 | config.assets.debug = true
54 |
55 | # Suppress logger output for asset requests.
56 | config.assets.quiet = true
57 |
58 | # Raises error for missing translations
59 | # config.action_view.raise_on_missing_translations = true
60 |
61 | # Use an evented file watcher to asynchronously detect changes in source code,
62 | # routes, locales, etc. This feature depends on the listen gem.
63 | # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
64 | end
65 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | This is the exmaple of modern Ruby on Rails application.
2 | It consists of RoR 6, Postgres, Redis, Webpack, React.
3 | All services are described in the docker-compose.yml.
4 |
5 | # How to run?
6 |
7 | This application customized that we can run it in two ways. Either run by Docker Compose only or by DIP.
8 | This way we can smoothly and gradually move members of your team to use DIP.
9 | For veterans is nothing change. They as before run the application by `docker-compose up rails webpack`
10 | and open `localhost:3000` in a browser.
11 | BTW, you can try it now after hand setup (see provision section in dip.yml).
12 | For progressive users (yeap, I mean us) everything is simple.
13 | I hope you already read [how to set up local dns](https://github.com/bibendi/dip/tree/master/docs) for getting the best experience.
14 | And Nginx must be running by `dip nginx up`. That's all we have to do once. After reboot, it will start automatically.
15 | Also, I strongly recommend you [integrate DIP to your ZSH shell](https://github.com/bibendi/dip#integration-with-shell)
16 | for the best experience.
17 | Next simply run `provision` and the application will set up.
18 | If you choose not the `.docker` top level domain then you must add `DOCKER_TLD=yourdomain` to `~/.bashrc` and reopen the console.
19 | After that run `webpack` and in another console `rails s`.
20 | Also, you can leave webpack running in the background by `up -d webpack`. Where `up` is a alias for `docker-compose up`.
21 | Open http://dip-rails.docker and all should work.
22 |
23 | # Usage
24 |
25 | Assume that you have integrated DIP into ZSH shell,
26 | so all commands below run in a console without the `dip` "prefix".
27 |
28 | ```sh
29 | # provision application
30 | provision
31 |
32 | # run rails app with all debuging capabilities (i.e. `binding.pry`)
33 | rails s
34 |
35 | # run rails console
36 | rails c
37 |
38 | # run webpack
39 | up -d webpacker
40 | # `-d` - mean that service will run in detached (background) mode
41 | or
42 | webpack
43 |
44 | # run migrations
45 | rake db:migrate
46 |
47 | # pass env variables into application
48 | VERSION=20100905201547 rake db:migrate:down
49 |
50 | # run sidekiq
51 | up -d sidekiq
52 | or
53 | sidekiq
54 |
55 | # launch bash within app directory
56 | bash
57 |
58 | # Additional commands
59 |
60 | # update gems or packages
61 | bundle install
62 | yarn install
63 |
64 | # run psql console
65 | psql app
66 | # where `app` is a database name. It might be `app_test`.
67 |
68 | # run redis-cli
69 | redis-cli
70 |
71 | # run tests
72 | # TIP: `rspec` command is already auto prefixed with `RAILS_ENV=test`
73 | rspec spec/path/to/single/test.rb:23
74 |
75 | # run system tests
76 | # webpack should be running with test environment
77 | RAILS_ENV=test webpack
78 | rspec spec/system
79 |
80 | # shutdown all containers
81 | down
82 | ```
83 |
84 | # How this application has been created from scratch?
85 |
86 | The main goal of using Docker is not having all dependencies installed on the host machine.
87 | So the first question is how to create an application without having rails?
88 | First of all, in an empty directory, we should add `Dockerfile`, `docker-compose.yml` and `dip.yml`.
89 | Then run `dip bash` where we can temporarily install `rails` gem by running `gem install rails`.
90 | After that, we have to generate the skeleton of our application.
91 | Run `rails new -d postgresql --skip-turbolinks --skip-bundle --webpack=react --skip --skip-test --skip-system-test .`
92 | Type `exit` and we will return into the host machine.
93 | Next, fix files permissions by running `sudo chown -R $USER:$USER .`.
94 | The last step we will need to run `dip provision`.
95 | That's all! Farther we customize the application how do you like.
96 | I strongly recommend learning the source code of this application.
97 | Maybe you simply decide to pick up it entirely because most pitfalls are found.
98 |
99 |
100 | Will be continued...
101 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Verifies that versions and hashed value of the package contents in the project's package.json
3 | config.webpacker.check_yarn_integrity = false
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 JavaScripts and CSS.
28 | config.assets.js_compressor = :uglifier
29 | # config.assets.css_compressor = :sass
30 |
31 | # Do not fallback to assets pipeline if a precompiled asset is missed.
32 | config.assets.compile = false
33 |
34 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
35 |
36 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
37 | # config.action_controller.asset_host = 'http://assets.example.com'
38 |
39 | # Specifies the header that your server uses for sending files.
40 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
41 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
42 |
43 | # Store uploaded files on the local file system (see config/storage.yml for options)
44 | config.active_storage.service = :local
45 |
46 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
47 | # config.force_ssl = true
48 |
49 | # Use the lowest log level to ensure availability of diagnostic information
50 | # when problems arise.
51 | config.log_level = :debug
52 |
53 | # Prepend all log lines with the following tags.
54 | config.log_tags = [ :request_id ]
55 |
56 | # Use a different cache store in production.
57 | # config.cache_store = :mem_cache_store
58 |
59 | # Use a real queuing backend for Active Job (and separate queues per environment)
60 | # config.active_job.queue_adapter = :resque
61 | # config.active_job.queue_name_prefix = "app_#{Rails.env}"
62 |
63 | config.action_mailer.perform_caching = false
64 |
65 | # Ignore bad email addresses and do not raise email delivery errors.
66 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
67 | # config.action_mailer.raise_delivery_errors = false
68 |
69 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
70 | # the I18n.default_locale when a translation cannot be found).
71 | config.i18n.fallbacks = true
72 |
73 | # Send deprecation notices to registered listeners.
74 | config.active_support.deprecation = :notify
75 |
76 | # Use default logging formatter so that PID and timestamp are not suppressed.
77 | config.log_formatter = ::Logger::Formatter.new
78 |
79 | # Use a different logger for distributed setups.
80 | # require 'syslog/logger'
81 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
82 |
83 | if ENV["RAILS_LOG_TO_STDOUT"].present?
84 | logger = ActiveSupport::Logger.new(STDOUT)
85 | logger.formatter = config.log_formatter
86 | config.logger = ActiveSupport::TaggedLogging.new(logger)
87 | end
88 |
89 | # Do not dump schema after migrations.
90 | config.active_record.dump_schema_after_migration = false
91 | end
92 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | actioncable (6.0.0.rc1)
5 | actionpack (= 6.0.0.rc1)
6 | nio4r (~> 2.0)
7 | websocket-driver (>= 0.6.1)
8 | actionmailbox (6.0.0.rc1)
9 | actionpack (= 6.0.0.rc1)
10 | activejob (= 6.0.0.rc1)
11 | activerecord (= 6.0.0.rc1)
12 | activestorage (= 6.0.0.rc1)
13 | activesupport (= 6.0.0.rc1)
14 | mail (>= 2.7.1)
15 | actionmailer (6.0.0.rc1)
16 | actionpack (= 6.0.0.rc1)
17 | actionview (= 6.0.0.rc1)
18 | activejob (= 6.0.0.rc1)
19 | mail (~> 2.5, >= 2.5.4)
20 | rails-dom-testing (~> 2.0)
21 | actionpack (6.0.0.rc1)
22 | actionview (= 6.0.0.rc1)
23 | activesupport (= 6.0.0.rc1)
24 | rack (~> 2.0)
25 | rack-test (>= 0.6.3)
26 | rails-dom-testing (~> 2.0)
27 | rails-html-sanitizer (~> 1.0, >= 1.0.2)
28 | actiontext (6.0.0.rc1)
29 | actionpack (= 6.0.0.rc1)
30 | activerecord (= 6.0.0.rc1)
31 | activestorage (= 6.0.0.rc1)
32 | activesupport (= 6.0.0.rc1)
33 | nokogiri (>= 1.8.5)
34 | actionview (6.0.0.rc1)
35 | activesupport (= 6.0.0.rc1)
36 | builder (~> 3.1)
37 | erubi (~> 1.4)
38 | rails-dom-testing (~> 2.0)
39 | rails-html-sanitizer (~> 1.0, >= 1.0.3)
40 | activejob (6.0.0.rc1)
41 | activesupport (= 6.0.0.rc1)
42 | globalid (>= 0.3.6)
43 | activemodel (6.0.0.rc1)
44 | activesupport (= 6.0.0.rc1)
45 | activerecord (6.0.0.rc1)
46 | activemodel (= 6.0.0.rc1)
47 | activesupport (= 6.0.0.rc1)
48 | activestorage (6.0.0.rc1)
49 | actionpack (= 6.0.0.rc1)
50 | activejob (= 6.0.0.rc1)
51 | activerecord (= 6.0.0.rc1)
52 | marcel (~> 0.3.1)
53 | activesupport (6.0.0.rc1)
54 | concurrent-ruby (~> 1.0, >= 1.0.2)
55 | i18n (>= 0.7, < 2)
56 | minitest (~> 5.1)
57 | tzinfo (~> 1.1)
58 | zeitwerk (~> 2.1, >= 2.1.4)
59 | bindex (0.7.0)
60 | bootsnap (1.4.4)
61 | msgpack (~> 1.0)
62 | builder (3.2.3)
63 | byebug (11.0.1)
64 | coderay (1.1.2)
65 | coffee-rails (4.2.2)
66 | coffee-script (>= 2.2.0)
67 | railties (>= 4.0.0)
68 | coffee-script (2.4.1)
69 | coffee-script-source
70 | execjs
71 | coffee-script-source (1.12.2)
72 | concurrent-ruby (1.1.5)
73 | connection_pool (2.2.2)
74 | crass (1.0.4)
75 | erubi (1.8.0)
76 | execjs (2.7.0)
77 | ffi (1.11.1)
78 | globalid (0.4.2)
79 | activesupport (>= 4.2.0)
80 | i18n (1.6.0)
81 | concurrent-ruby (~> 1.0)
82 | jbuilder (2.9.1)
83 | activesupport (>= 4.2.0)
84 | loofah (2.2.3)
85 | crass (~> 1.0.2)
86 | nokogiri (>= 1.5.9)
87 | mail (2.7.1)
88 | mini_mime (>= 0.1.1)
89 | marcel (0.3.3)
90 | mimemagic (~> 0.3.2)
91 | method_source (0.9.2)
92 | mimemagic (0.3.3)
93 | mini_mime (1.0.1)
94 | mini_portile2 (2.4.0)
95 | minitest (5.11.3)
96 | msgpack (1.3.0)
97 | nio4r (2.3.1)
98 | nokogiri (1.10.3)
99 | mini_portile2 (~> 2.4.0)
100 | pg (1.1.4)
101 | pry (0.12.2)
102 | coderay (~> 1.1.0)
103 | method_source (~> 0.9.0)
104 | pry-byebug (3.7.0)
105 | byebug (~> 11.0)
106 | pry (~> 0.10)
107 | pry-rails (0.3.9)
108 | pry (>= 0.10.4)
109 | puma (3.12.1)
110 | rack (2.0.7)
111 | rack-protection (2.0.5)
112 | rack
113 | rack-proxy (0.6.5)
114 | rack
115 | rack-test (1.1.0)
116 | rack (>= 1.0, < 3)
117 | rails (6.0.0.rc1)
118 | actioncable (= 6.0.0.rc1)
119 | actionmailbox (= 6.0.0.rc1)
120 | actionmailer (= 6.0.0.rc1)
121 | actionpack (= 6.0.0.rc1)
122 | actiontext (= 6.0.0.rc1)
123 | actionview (= 6.0.0.rc1)
124 | activejob (= 6.0.0.rc1)
125 | activemodel (= 6.0.0.rc1)
126 | activerecord (= 6.0.0.rc1)
127 | activestorage (= 6.0.0.rc1)
128 | activesupport (= 6.0.0.rc1)
129 | bundler (>= 1.3.0)
130 | railties (= 6.0.0.rc1)
131 | sprockets-rails (>= 2.0.0)
132 | rails-dom-testing (2.0.3)
133 | activesupport (>= 4.2.0)
134 | nokogiri (>= 1.6)
135 | rails-html-sanitizer (1.0.4)
136 | loofah (~> 2.2, >= 2.2.2)
137 | railties (6.0.0.rc1)
138 | actionpack (= 6.0.0.rc1)
139 | activesupport (= 6.0.0.rc1)
140 | method_source
141 | rake (>= 0.8.7)
142 | thor (>= 0.20.3, < 2.0)
143 | rake (12.3.2)
144 | rb-fsevent (0.10.3)
145 | rb-inotify (0.10.0)
146 | ffi (~> 1.0)
147 | redis (4.1.2)
148 | sass (3.7.4)
149 | sass-listen (~> 4.0.0)
150 | sass-listen (4.0.0)
151 | rb-fsevent (~> 0.9, >= 0.9.4)
152 | rb-inotify (~> 0.9, >= 0.9.7)
153 | sass-rails (5.0.7)
154 | railties (>= 4.0.0, < 6)
155 | sass (~> 3.1)
156 | sprockets (>= 2.8, < 4.0)
157 | sprockets-rails (>= 2.0, < 4.0)
158 | tilt (>= 1.1, < 3)
159 | sidekiq (5.2.7)
160 | connection_pool (~> 2.2, >= 2.2.2)
161 | rack (>= 1.5.0)
162 | rack-protection (>= 1.5.0)
163 | redis (>= 3.3.5, < 5)
164 | sprockets (3.7.2)
165 | concurrent-ruby (~> 1.0)
166 | rack (> 1, < 3)
167 | sprockets-rails (3.2.1)
168 | actionpack (>= 4.0)
169 | activesupport (>= 4.0)
170 | sprockets (>= 3.0.0)
171 | thor (0.20.3)
172 | thread_safe (0.3.6)
173 | tilt (2.0.9)
174 | tzinfo (1.2.5)
175 | thread_safe (~> 0.1)
176 | uglifier (4.1.20)
177 | execjs (>= 0.3.0, < 3)
178 | web-console (4.0.0)
179 | actionview (>= 6.0.0.a)
180 | activemodel (>= 6.0.0.a)
181 | bindex (>= 0.4.0)
182 | railties (>= 6.0.0.a)
183 | webpacker (4.0.7)
184 | activesupport (>= 4.2)
185 | rack-proxy (>= 0.6.1)
186 | railties (>= 4.2)
187 | websocket-driver (0.7.1)
188 | websocket-extensions (>= 0.1.0)
189 | websocket-extensions (0.1.4)
190 | zeitwerk (2.1.6)
191 |
192 | PLATFORMS
193 | ruby
194 |
195 | DEPENDENCIES
196 | bootsnap (>= 1.4.3)
197 | coffee-rails (~> 4.2)
198 | jbuilder (~> 2.5)
199 | pg (~> 1.0)
200 | pry-byebug
201 | pry-rails
202 | puma (~> 3.11)
203 | rails (= 6.0.0.rc1)
204 | sass-rails (~> 5.0)
205 | sidekiq (~> 5.2)
206 | tzinfo-data
207 | uglifier (>= 1.3.0)
208 | web-console (>= 3.3.0)
209 | webpacker
210 |
211 | RUBY VERSION
212 | ruby 2.6.1p33
213 |
214 | BUNDLED WITH
215 | 1.17.3
216 |
--------------------------------------------------------------------------------