├── .gitignore ├── README.md ├── docker-compose.yml ├── kubernetes-rails.png ├── kubernetes ├── db-service.yaml ├── web-controller.yaml └── web-service.json ├── nginx ├── Dockerfile └── nginx.conf └── web ├── .gitignore ├── .rvmrc ├── Bowerfile ├── Dockerfile ├── Gemfile ├── Gemfile.lock ├── README.md ├── Rakefile ├── app ├── assets │ ├── config │ │ └── manifest.js │ ├── images │ │ └── .keep │ ├── javascripts │ │ ├── application.js │ │ ├── cable.coffee │ │ └── channels │ │ │ └── .keep │ └── stylesheets │ │ └── application.css ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── controllers │ ├── application_controller.rb │ ├── concerns │ │ └── .keep │ └── tasks_controller.rb ├── helpers │ └── application_helper.rb ├── jobs │ └── application_job.rb ├── mailers │ └── application_mailer.rb ├── models │ ├── application_record.rb │ └── concerns │ │ └── .keep └── views │ ├── layouts │ ├── application.html.erb │ ├── mailer.html.erb │ └── mailer.text.erb │ └── tasks │ └── index.html.erb ├── bin ├── bundle ├── rails ├── rake ├── setup ├── spring └── update ├── config.ru ├── config ├── application.rb ├── boot.rb ├── cable.yml ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── active_record_belongs_to_required_by_default.rb │ ├── application_controller_renderer.rb │ ├── assets.rb │ ├── backtrace_silencers.rb │ ├── bower_rails.rb │ ├── callback_terminator.rb │ ├── cookies_serializer.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── per_form_csrf_tokens.rb │ ├── request_forgery_protection.rb │ ├── session_store.rb │ └── wrap_parameters.rb ├── locales │ └── en.yml ├── puma.rb ├── routes.rb ├── secrets.yml └── unicorn.rb ├── db └── seeds.rb ├── init.sh ├── kubernetes-post-start.sh ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── log └── .keep ├── public ├── 404.html ├── 422.html ├── 500.html ├── favicon.ico └── robots.txt ├── test ├── controllers │ └── .keep ├── fixtures │ ├── .keep │ └── files │ │ └── .keep ├── helpers │ └── .keep ├── integration │ └── .keep ├── mailers │ └── .keep ├── models │ └── .keep └── test_helper.rb └── vendor └── assets ├── javascripts └── .keep └── stylesheets └── .keep /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | cookbooks 3 | tmp 4 | web/public/exports 5 | web/vendor/assets/bower_components 6 | web/public/assets 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kubernetes-Rails 2 | 3 | **NOTE** This is not production ready. The env is set to "production" as a proof of concept to show the asset pipeline is working in prod. 4 | 5 | This project is a working example of building a rails app using Docker, and deploying using Kubernetes to GCE. Each Pod consists of an NGINX and Rails container (running unicorn). This allows NGINX to host static files using an [emptyDir](http://kubernetes.io/v1.1/docs/user-guide/volumes.html#emptydir) volume instead of a a more [persistent volume](http://kubernetes.io/v1.1/docs/user-guide/volumes.html). 6 | 7 | ![Server setup diagram](kubernetes-rails.png) 8 | 9 | ## Run locally 10 | 1. `docker-machine create --driver virtualbox --virtualbox-disk-size "30000" --virtualbox-memory "8096" kubernetes-rails` 11 | 2. `docker-machine start kubernetes-rails` 12 | 3. `eval "$(docker-machine env kubernetes-rails)"` 13 | 4. `docker-compose build && docker-compose up -d` 14 | 5. `docker-compose run --rm web rake db:create` 15 | 16 | ## Build images 17 | You will need to change **foxio-rnd** to your GCE project name. 18 | 19 | 1. `docker build -t gcr.io/foxio-rnd/rails-image:v1 web/.` 20 | 2. `gcloud docker push gcr.io/foxio-rnd/rails-image:v1` **Note** pushing can take a long time and use a lot of bandwidth. This actually times out sometimes. Just run it again if it does that. 21 | 3. `docker build -t gcr.io/foxio-rnd/nginx-image:v1 nginx/.` 22 | 4. `gcloud docker push gcr.io/foxio-rnd/nginx-image:v1` 23 | 24 | 25 | ## GCE deploy 26 | 1. `gcloud container clusters create kubernetes-rails --num-nodes 2 --machine-type g1-small` 27 | 2. `kubectl run db --image=postgres --port=5432` 28 | 3. `kubectl expose rc db` 29 | 4. Update kubernetes/web-controller.yaml to use your GCE project name instead of **foxio-rnd** 30 | 5. `kubectl create -f kubernetes/web-controller.yaml` 31 | 6. Using `kubectl get pods` wait for the 2 pods to change to `Running`. This can take a few minutes. 32 | 7. `kubectl create -f kubernetes/web-service.json` 33 | 34 | ## DB Setup 35 | 1. `kubectl get pods` 36 | 2. `kubectl exec -it [pod id] -c web bash` 37 | 3. run `rake db:create` and `rake db:migrate` 38 | 39 | ## Teardown 40 | 1. `gcloud container clusters delete kubernetes-rails` 41 | 2. Manually delete the Load balancer from the Network -> Network load balancer 42 | 43 | ## TODO 44 | 1. automate the DB setup 45 | 2. setup DB cluster 46 | 3. Setup to run Kubernetes locally 47 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | web: 4 | restart: always 5 | dns: 6 | - 8.8.8.8 7 | build: 8 | context: ./web 9 | environment: 10 | RAILS_ENV: production 11 | WEB_DATABASE_HOST: db 12 | SECRET_KEY_BASE: a964ebdd62805aeff7659781ae0e017e94b9fb8a90a8187dd01f68fefa3791cd1d72ea36f469bc3ad3da1efa36981147afdffe2461afac518ee2a672fb201948 13 | WEB_DATABASE_PASSWORD: postgres 14 | expose: 15 | - "8080" 16 | volumes: 17 | - ./web:/my_project 18 | links: 19 | - db 20 | nginx: 21 | build: ./nginx 22 | links: 23 | - web 24 | # - api 25 | ports: 26 | - "80:80" 27 | expose: 28 | - "80" 29 | volumes: 30 | - "/var/run/docker.sock:/tmp/docker.sock" 31 | volumes_from: 32 | - web 33 | db: 34 | image: postgres:latest 35 | environment: 36 | POSTGRES_USER: "postgres" 37 | POSTGRES_PASSWORD: "postgres" 38 | ports: 39 | - "5432:5432" 40 | -------------------------------------------------------------------------------- /kubernetes-rails.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/kubernetes-rails.png -------------------------------------------------------------------------------- /kubernetes/db-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: db 5 | labels: 6 | name: db 7 | spec: 8 | ports: 9 | - port: 5432 10 | selector: 11 | run: db 12 | -------------------------------------------------------------------------------- /kubernetes/web-controller.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ReplicationController 3 | metadata: 4 | name: www-v1 5 | labels: 6 | app: www 7 | spec: 8 | replicas: 2 9 | selector: 10 | app: www 11 | version: v1 12 | template: 13 | metadata: 14 | labels: 15 | app: www 16 | version: v1 17 | spec: 18 | volumes: 19 | - name: web-assets 20 | emptyDir: {} 21 | - name: web-sock 22 | emptyDir: {} 23 | containers: 24 | - name: web 25 | image: gcr.io/foxio-rnd/rails-image:v1 26 | ports: 27 | - name: web-server 28 | containerPort: 8080 29 | env: 30 | - name: RAILS_ENV 31 | value: production 32 | - name: WEB_DATABASE_HOST 33 | value: db 34 | - name: SECRET_KEY_BASE 35 | value: 4fb2a451674dd7c5641577a0031847d82247bd137fedb0ba91c6d1a6ccbc8d2da370ffa164503f50c2f2c121f46f1f21b89dc946633924e0c464bdb69b368415 36 | volumeMounts: 37 | - mountPath: /assets 38 | name: web-assets 39 | - mountPath: /tmp 40 | name: web-sock 41 | lifecycle: 42 | postStart: 43 | exec: 44 | command: 45 | - /bin/bash 46 | - -c 47 | - /my_project/kubernetes-post-start.sh 48 | - name: nginx 49 | image: gcr.io/foxio-rnd/nginx-image:v1 50 | ports: 51 | - name: http-server 52 | containerPort: 80 53 | - name: https-server 54 | containerPort: 443 55 | volumeMounts: 56 | - mountPath: /my_project/public 57 | name: web-assets 58 | readOnly: true 59 | - mountPath: /tmp 60 | name: web-sock 61 | -------------------------------------------------------------------------------- /kubernetes/web-service.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind":"Service", 3 | "apiVersion":"v1", 4 | "metadata":{ 5 | "name":"www", 6 | "labels":{ 7 | "app":"www" 8 | } 9 | }, 10 | "spec":{ 11 | "ports": [ 12 | { 13 | "name": "http", 14 | "port":80, 15 | "targetPort":"http-server" 16 | }, 17 | { 18 | "name": "https", 19 | "port":443, 20 | "targetPort":"https-server" 21 | } 22 | ], 23 | "selector":{ 24 | "app":"www" 25 | }, 26 | "type": "LoadBalancer" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | # Set nginx base image 2 | FROM nginx 3 | 4 | # Copy custom configuration file from the current directory 5 | COPY nginx.conf /etc/nginx/nginx.conf 6 | -------------------------------------------------------------------------------- /nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | worker_processes 4; 2 | 3 | events { worker_connections 1024; } 4 | 5 | http { 6 | upstream unicorn { 7 | least_conn; 8 | #server web:8080 weight=10 max_fails=3 fail_timeout=30s; 9 | server unix:/tmp/unicorn.sock fail_timeout=0; 10 | } 11 | 12 | server { 13 | listen 80; 14 | 15 | root /my_project/public; 16 | 17 | # serve static (compiled) assets directly if they exist (for rails production) 18 | location ~ ^/(assets|images|javascripts|stylesheets|swfs|system)/ { 19 | include /etc/nginx/mime.types; 20 | try_files $uri @unicorn; 21 | 22 | access_log off; 23 | gzip_static on; # to serve pre-gzipped version 24 | 25 | expires max; 26 | add_header Cache-Control public; 27 | 28 | # Some browsers still send conditional-GET requests if there's a 29 | # Last-Modified header or an ETag header even if they haven't 30 | # reached the expiry date sent in the Expires header. 31 | add_header Last-Modified ""; 32 | add_header ETag ""; 33 | break; 34 | } 35 | 36 | # send non-static file requests to the app server 37 | location / { 38 | try_files $uri @unicorn; 39 | } 40 | 41 | location @unicorn { 42 | #proxy_set_header X-Real-IP $remote_addr; 43 | #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 44 | #proxy_set_header Host $http_host; 45 | #proxy_redirect off; 46 | #proxy_pass http://unicorn; 47 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 48 | proxy_set_header Host $http_host; 49 | proxy_redirect off; 50 | 51 | # If you don't find the filename in the static files 52 | # Then request it from the unicorn server 53 | if (!-f $request_filename) { 54 | proxy_pass http://unicorn; 55 | break; 56 | } 57 | } 58 | 59 | error_page 500 502 503 504 /500.html; 60 | location = /500.html { 61 | root /my_project/public; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /web/.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 the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/* 16 | /tmp/* 17 | !/log/.keep 18 | !/tmp/.keep 19 | 20 | # Ignore Byebug command history file. 21 | .byebug_history 22 | -------------------------------------------------------------------------------- /web/.rvmrc: -------------------------------------------------------------------------------- 1 | rvm --create use ruby-2.3.0@kubernetes-rails 2 | -------------------------------------------------------------------------------- /web/Bowerfile: -------------------------------------------------------------------------------- 1 | # A sample Bowerfile 2 | # Check out https://github.com/42dev/bower-rails#ruby-dsl-configuration for more options 3 | 4 | # asset 'bootstrap' -------------------------------------------------------------------------------- /web/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM foxio/rails 2 | 3 | RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs npm nodejs-legacy 4 | RUN mkdir /my_project 5 | WORKDIR /my_project 6 | 7 | ADD Gemfile /my_project/Gemfile 8 | ADD Gemfile.lock /my_project/Gemfile.lock 9 | RUN bundle install 10 | ADD . /my_project 11 | 12 | RUN rake bower:install 13 | 14 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 15 | 16 | VOLUME ["/tmp"] 17 | 18 | RUN chmod +x /my_project/init.sh 19 | RUN chmod +x /my_project/kubernetes-post-start.sh 20 | 21 | CMD ["sh", "/my_project/init.sh"] 22 | 23 | ENTRYPOINT bundle exec unicorn -c config/unicorn.rb 24 | -------------------------------------------------------------------------------- /web/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | 4 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 5 | gem 'rails', '>= 5.0.0.beta2', '< 5.1' 6 | # Use sqlite3 as the database for Active Record 7 | gem 'sqlite3' 8 | # Use Puma as the app server 9 | gem 'puma' 10 | # Use SCSS for stylesheets 11 | gem 'sass-rails', '~> 5.0' 12 | # Use Uglifier as compressor for JavaScript assets 13 | gem 'uglifier', '>= 1.3.0' 14 | # Use CoffeeScript for .coffee assets and views 15 | gem 'coffee-rails', '~> 4.1.0' 16 | # See https://github.com/rails/execjs#readme for more supported runtimes 17 | # gem 'therubyracer', platforms: :ruby 18 | 19 | # Use jquery as the JavaScript library 20 | gem 'jquery-rails' 21 | # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 22 | gem 'turbolinks' 23 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 24 | gem 'jbuilder', '~> 2.0' 25 | # Action Cable dependencies for the Redis adapter 26 | gem 'redis', '~> 3.0' 27 | # Use ActiveModel has_secure_password 28 | # gem 'bcrypt', '~> 3.1.7' 29 | 30 | # Use Capistrano for deployment 31 | # gem 'capistrano-rails', group: :development 32 | 33 | # Use Unicorn as the app server 34 | gem 'unicorn' 35 | gem 'bower-rails' 36 | gem 'pg' 37 | 38 | group :development, :test do 39 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 40 | gem 'byebug' 41 | end 42 | 43 | group :development do 44 | # Access an IRB console on exception pages or by using <%= console %> in views 45 | gem 'web-console', '~> 3.0' 46 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 47 | gem 'spring' 48 | end 49 | 50 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 51 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 52 | -------------------------------------------------------------------------------- /web/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (5.0.0.beta3) 5 | actionpack (= 5.0.0.beta3) 6 | nio4r (~> 1.2) 7 | websocket-driver (~> 0.6.1) 8 | actionmailer (5.0.0.beta3) 9 | actionpack (= 5.0.0.beta3) 10 | actionview (= 5.0.0.beta3) 11 | activejob (= 5.0.0.beta3) 12 | mail (~> 2.5, >= 2.5.4) 13 | rails-dom-testing (~> 1.0, >= 1.0.5) 14 | actionpack (5.0.0.beta3) 15 | actionview (= 5.0.0.beta3) 16 | activesupport (= 5.0.0.beta3) 17 | rack (~> 2.x) 18 | rack-test (~> 0.6.3) 19 | rails-dom-testing (~> 1.0, >= 1.0.5) 20 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 21 | actionview (5.0.0.beta3) 22 | activesupport (= 5.0.0.beta3) 23 | builder (~> 3.1) 24 | erubis (~> 2.7.0) 25 | rails-dom-testing (~> 1.0, >= 1.0.5) 26 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 27 | activejob (5.0.0.beta3) 28 | activesupport (= 5.0.0.beta3) 29 | globalid (>= 0.3.6) 30 | activemodel (5.0.0.beta3) 31 | activesupport (= 5.0.0.beta3) 32 | activerecord (5.0.0.beta3) 33 | activemodel (= 5.0.0.beta3) 34 | activesupport (= 5.0.0.beta3) 35 | arel (~> 7.0) 36 | activesupport (5.0.0.beta3) 37 | concurrent-ruby (~> 1.0) 38 | i18n (~> 0.7) 39 | minitest (~> 5.1) 40 | tzinfo (~> 1.1) 41 | arel (7.0.0) 42 | bower-rails (0.10.0) 43 | builder (3.2.2) 44 | byebug (8.2.2) 45 | coffee-rails (4.1.1) 46 | coffee-script (>= 2.2.0) 47 | railties (>= 4.0.0, < 5.1.x) 48 | coffee-script (2.4.1) 49 | coffee-script-source 50 | execjs 51 | coffee-script-source (1.10.0) 52 | concurrent-ruby (1.0.1) 53 | debug_inspector (0.0.2) 54 | erubis (2.7.0) 55 | execjs (2.6.0) 56 | globalid (0.3.6) 57 | activesupport (>= 4.1.0) 58 | i18n (0.7.0) 59 | jbuilder (2.4.1) 60 | activesupport (>= 3.0.0, < 5.1) 61 | multi_json (~> 1.2) 62 | jquery-rails (4.1.0) 63 | rails-dom-testing (~> 1.0) 64 | railties (>= 4.2.0) 65 | thor (>= 0.14, < 2.0) 66 | json (1.8.3) 67 | kgio (2.10.0) 68 | loofah (2.0.3) 69 | nokogiri (>= 1.5.9) 70 | mail (2.6.3) 71 | mime-types (>= 1.16, < 3) 72 | method_source (0.8.2) 73 | mime-types (2.99.1) 74 | mini_portile2 (2.0.0) 75 | minitest (5.8.4) 76 | multi_json (1.11.2) 77 | nio4r (1.2.1) 78 | nokogiri (1.6.7.2) 79 | mini_portile2 (~> 2.0.0.rc2) 80 | pg (0.18.4) 81 | puma (3.0.2) 82 | rack (2.0.0.alpha) 83 | json 84 | rack-test (0.6.3) 85 | rack (>= 1.0) 86 | rails (5.0.0.beta3) 87 | actioncable (= 5.0.0.beta3) 88 | actionmailer (= 5.0.0.beta3) 89 | actionpack (= 5.0.0.beta3) 90 | actionview (= 5.0.0.beta3) 91 | activejob (= 5.0.0.beta3) 92 | activemodel (= 5.0.0.beta3) 93 | activerecord (= 5.0.0.beta3) 94 | activesupport (= 5.0.0.beta3) 95 | bundler (>= 1.3.0, < 2.0) 96 | railties (= 5.0.0.beta3) 97 | sprockets-rails (>= 2.0.0) 98 | rails-deprecated_sanitizer (1.0.3) 99 | activesupport (>= 4.2.0.alpha) 100 | rails-dom-testing (1.0.7) 101 | activesupport (>= 4.2.0.beta, < 5.0) 102 | nokogiri (~> 1.6.0) 103 | rails-deprecated_sanitizer (>= 1.0.1) 104 | rails-html-sanitizer (1.0.3) 105 | loofah (~> 2.0) 106 | railties (5.0.0.beta3) 107 | actionpack (= 5.0.0.beta3) 108 | activesupport (= 5.0.0.beta3) 109 | method_source 110 | rake (>= 0.8.7) 111 | thor (>= 0.18.1, < 2.0) 112 | raindrops (0.15.0) 113 | rake (10.5.0) 114 | redis (3.2.2) 115 | sass (3.4.21) 116 | sass-rails (5.0.4) 117 | railties (>= 4.0.0, < 5.0) 118 | sass (~> 3.1) 119 | sprockets (>= 2.8, < 4.0) 120 | sprockets-rails (>= 2.0, < 4.0) 121 | tilt (>= 1.1, < 3) 122 | spring (1.6.4) 123 | sprockets (3.5.2) 124 | concurrent-ruby (~> 1.0) 125 | rack (> 1, < 3) 126 | sprockets-rails (3.0.3) 127 | actionpack (>= 4.0) 128 | activesupport (>= 4.0) 129 | sprockets (>= 3.0.0) 130 | sqlite3 (1.3.11) 131 | thor (0.19.1) 132 | thread_safe (0.3.5) 133 | tilt (2.0.2) 134 | turbolinks (2.5.3) 135 | coffee-rails 136 | tzinfo (1.2.2) 137 | thread_safe (~> 0.1) 138 | uglifier (2.7.2) 139 | execjs (>= 0.3.0) 140 | json (>= 1.8.0) 141 | unicorn (5.0.1) 142 | kgio (~> 2.6) 143 | rack 144 | raindrops (~> 0.7) 145 | web-console (3.1.1) 146 | activemodel (>= 4.2) 147 | debug_inspector 148 | railties (>= 4.2) 149 | websocket-driver (0.6.3) 150 | websocket-extensions (>= 0.1.0) 151 | websocket-extensions (0.1.2) 152 | 153 | PLATFORMS 154 | ruby 155 | 156 | DEPENDENCIES 157 | bower-rails 158 | byebug 159 | coffee-rails (~> 4.1.0) 160 | jbuilder (~> 2.0) 161 | jquery-rails 162 | pg 163 | puma 164 | rails (>= 5.0.0.beta2, < 5.1) 165 | redis (~> 3.0) 166 | sass-rails (~> 5.0) 167 | spring 168 | sqlite3 169 | turbolinks 170 | tzinfo-data 171 | uglifier (>= 1.3.0) 172 | unicorn 173 | web-console (~> 3.0) 174 | 175 | BUNDLED WITH 176 | 1.11.2 177 | -------------------------------------------------------------------------------- /web/README.md: -------------------------------------------------------------------------------- 1 | ## README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | -------------------------------------------------------------------------------- /web/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 File.expand_path('../config/application', __FILE__) 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /web/app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../javascripts .js 3 | //= link_directory ../stylesheets .css 4 | -------------------------------------------------------------------------------- /web/app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/app/assets/images/.keep -------------------------------------------------------------------------------- /web/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, vendor/assets/javascripts, 5 | // or any plugin's 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 jquery 14 | //= require jquery_ujs 15 | //= require turbolinks 16 | //= require_tree . 17 | -------------------------------------------------------------------------------- /web/app/assets/javascripts/cable.coffee: -------------------------------------------------------------------------------- 1 | # Action Cable provides the framework to deal with WebSockets in Rails. 2 | # You can generate new channels where WebSocket features live using the rails generate channel command. 3 | # 4 | # Turn on the cable connection by removing the comments after the require statements (and ensure it's also on in config/routes.rb). 5 | # 6 | #= require action_cable 7 | #= require_self 8 | #= require_tree ./channels 9 | # 10 | # @App ||= {} 11 | # App.cable = ActionCable.createConsumer() 12 | -------------------------------------------------------------------------------- /web/app/assets/javascripts/channels/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/app/assets/javascripts/channels/.keep -------------------------------------------------------------------------------- /web/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, vendor/assets/stylesheets, 6 | * or any plugin's 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 | -------------------------------------------------------------------------------- /web/app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. Action Cable runs in a loop that does not support auto reloading. 2 | module ApplicationCable 3 | class Channel < ActionCable::Channel::Base 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /web/app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. Action Cable runs in a loop that does not support auto reloading. 2 | module ApplicationCable 3 | class Connection < ActionCable::Connection::Base 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /web/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /web/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /web/app/controllers/tasks_controller.rb: -------------------------------------------------------------------------------- 1 | class TasksController < ApplicationController 2 | 3 | def index 4 | end 5 | 6 | end 7 | -------------------------------------------------------------------------------- /web/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /web/app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | end 3 | -------------------------------------------------------------------------------- /web/app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /web/app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /web/app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/app/models/concerns/.keep -------------------------------------------------------------------------------- /web/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Web 5 | <%= csrf_meta_tags %> 6 | <%= action_cable_meta_tag %> 7 | 8 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> 9 | <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> 10 | 11 | 12 | 13 | <%= yield %> 14 | 15 | 16 | -------------------------------------------------------------------------------- /web/app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /web/app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /web/app/views/tasks/index.html.erb: -------------------------------------------------------------------------------- 1 |

Index

2 | -------------------------------------------------------------------------------- /web/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /web/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | APP_PATH = File.expand_path('../../config/application', __FILE__) 8 | require_relative '../config/boot' 9 | require 'rails/commands' 10 | -------------------------------------------------------------------------------- /web/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | require_relative '../config/boot' 8 | require 'rake' 9 | Rake.application.run 10 | -------------------------------------------------------------------------------- /web/bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a starting point to setup your application. 15 | # Add necessary setup steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system('bundle check') or system!('bundle install') 20 | 21 | # puts "\n== Copying sample files ==" 22 | # unless File.exist?('config/database.yml') 23 | # cp 'config/database.yml.sample', 'config/database.yml' 24 | # end 25 | 26 | puts "\n== Preparing database ==" 27 | system! 'bin/rails db:setup' 28 | 29 | puts "\n== Removing old logs and tempfiles ==" 30 | system! 'bin/rails log:clear tmp:clear' 31 | 32 | puts "\n== Restarting application server ==" 33 | system! 'bin/rails restart' 34 | end 35 | -------------------------------------------------------------------------------- /web/bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require 'rubygems' 8 | require 'bundler' 9 | 10 | if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)) 11 | Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) } 12 | gem 'spring', match[1] 13 | require 'spring/binstub' 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /web/bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a way to update your development environment automatically. 15 | # Add necessary update steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system 'bundle check' or system! 'bundle install' 20 | 21 | puts "\n== Updating database ==" 22 | system! 'bin/rails db:migrate' 23 | 24 | puts "\n== Removing old logs and tempfiles ==" 25 | system! 'bin/rails log:clear tmp:clear' 26 | 27 | puts "\n== Restarting application server ==" 28 | system! 'bin/rails restart' 29 | end 30 | -------------------------------------------------------------------------------- /web/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | 5 | # Action Cable requires that all classes are loaded in advance 6 | Rails.application.eager_load! 7 | 8 | run Rails.application 9 | -------------------------------------------------------------------------------- /web/config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 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 Web 10 | class Application < Rails::Application 11 | # Settings in config/environments/* take precedence over those specified here. 12 | # Application configuration should go into files in config/initializers 13 | # -- all .rb files in that directory are automatically loaded. 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /web/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /web/config/cable.yml: -------------------------------------------------------------------------------- 1 | # Action Cable uses Redis by default to administer connections, channels, and sending/receiving messages over the WebSocket. 2 | production: 3 | adapter: redis 4 | url: redis://localhost:6379/1 5 | 6 | development: 7 | adapter: async 8 | 9 | test: 10 | adapter: async 11 | -------------------------------------------------------------------------------- /web/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | # 7 | default: &default 8 | adapter: postgresql 9 | encoding: unicode 10 | database: dev 11 | pool: 5 12 | username: postgres 13 | password: postgres 14 | host: <%= ENV['WEB_DATABASE_HOST'] %> 15 | port: 5432 16 | 17 | development: 18 | <<: *default 19 | database: dev 20 | 21 | # Warning: The database defined as "test" will be erased and 22 | # re-generated from your development database when you run "rake". 23 | # Do not set this db to the same as development or production. 24 | test: 25 | <<: *default 26 | database: db/test.sqlite3 27 | 28 | production: 29 | <<: *default 30 | database: web_production 31 | password: <%= ENV['WEB_DATABASE_PASSWORD'] %> 32 | -------------------------------------------------------------------------------- /web/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /web/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports. 13 | config.consider_all_requests_local = true 14 | 15 | # Enable/disable caching. By default caching is disabled. 16 | if Rails.root.join('tmp/caching-dev.txt').exist? 17 | config.action_controller.perform_caching = true 18 | config.cache_store = :memory_store 19 | config.public_file_server.headers = { 20 | 'Cache-Control' => 'public, max-age=172800' 21 | } 22 | else 23 | config.action_controller.perform_caching = false 24 | config.cache_store = :null_store 25 | end 26 | 27 | # Don't care if the mailer can't send. 28 | config.action_mailer.raise_delivery_errors = false 29 | 30 | # Print deprecation notices to the Rails logger. 31 | config.active_support.deprecation = :log 32 | 33 | # Raise an error on page load if there are pending migrations. 34 | config.active_record.migration_error = :page_load 35 | 36 | # Debug mode disables concatenation and preprocessing of assets. 37 | # This option may cause significant delays in view rendering with a large 38 | # number of complex assets. 39 | config.assets.debug = true 40 | 41 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, 42 | # yet still be able to expire them through the digest params. 43 | config.assets.digest = true 44 | 45 | # Adds additional error checking when serving assets at runtime. 46 | # Checks for improperly declared sprockets dependencies. 47 | # Raises helpful error messages. 48 | config.assets.raise_runtime_errors = true 49 | 50 | # Raises error for missing translations 51 | # config.action_view.raise_on_missing_translations = true 52 | 53 | # Use an evented file watcher to asynchronously detect changes in source code, 54 | # routes, locales, etc. This feature depends on the listen gem. 55 | # config.file_watcher = ActiveSupport::EventedFileUpdateChecker 56 | end 57 | -------------------------------------------------------------------------------- /web/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Disable serving static files from the `/public` folder by default since 18 | # Apache or NGINX already handles this. 19 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 20 | 21 | # Compress JavaScripts and CSS. 22 | config.assets.js_compressor = :uglifier 23 | # config.assets.css_compressor = :sass 24 | 25 | # Do not fallback to assets pipeline if a precompiled asset is missed. 26 | config.assets.compile = false 27 | 28 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, 29 | # yet still be able to expire them through the digest params. 30 | config.assets.digest = true 31 | 32 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 33 | 34 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 35 | # config.action_controller.asset_host = 'http://assets.example.com' 36 | 37 | # Specifies the header that your server uses for sending files. 38 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 39 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 40 | 41 | # Action Cable endpoint configuration 42 | # config.action_cable.url = 'wss://example.com/cable' 43 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 44 | 45 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 46 | # config.force_ssl = true 47 | 48 | # Use the lowest log level to ensure availability of diagnostic information 49 | # when problems arise. 50 | config.log_level = :debug 51 | 52 | # Prepend all log lines with the following tags. 53 | config.log_tags = [ :request_id ] 54 | 55 | # Use a different logger for distributed setups. 56 | # require 'syslog/logger' 57 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 58 | 59 | # Use a different cache store in production. 60 | # config.cache_store = :mem_cache_store 61 | 62 | # Use a real queuing backend for Active Job (and separate queues per environment) 63 | # config.active_job.queue_adapter = :resque 64 | # config.active_job.queue_name_prefix = "web_#{Rails.env}" 65 | 66 | # Ignore bad email addresses and do not raise email delivery errors. 67 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 68 | # config.action_mailer.raise_delivery_errors = false 69 | 70 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 71 | # the I18n.default_locale when a translation cannot be found). 72 | config.i18n.fallbacks = true 73 | 74 | # Send deprecation notices to registered listeners. 75 | config.active_support.deprecation = :notify 76 | 77 | # Use default logging formatter so that PID and timestamp are not suppressed. 78 | config.log_formatter = ::Logger::Formatter.new 79 | 80 | # Do not dump schema after migrations. 81 | config.active_record.dump_schema_after_migration = false 82 | end 83 | -------------------------------------------------------------------------------- /web/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=3600' 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 | # Tell Action Mailer not to deliver emails to the real world. 32 | # The :test delivery method accumulates sent emails in the 33 | # ActionMailer::Base.deliveries array. 34 | config.action_mailer.delivery_method = :test 35 | 36 | # Randomize the order test cases are executed. 37 | config.active_support.test_order = :random 38 | 39 | # Print deprecation notices to the stderr. 40 | config.active_support.deprecation = :stderr 41 | 42 | # Raises error for missing translations 43 | # config.action_view.raise_on_missing_translations = true 44 | end 45 | -------------------------------------------------------------------------------- /web/config/initializers/active_record_belongs_to_required_by_default.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Require `belongs_to` associations by default. This is a new Rails 5.0 4 | # default, so it is introduced as a configuration option to ensure that apps 5 | # made on earlier versions of Rails are not affected when upgrading. 6 | Rails.application.config.active_record.belongs_to_required_by_default = true 7 | -------------------------------------------------------------------------------- /web/config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ApplicationController.renderer.defaults.merge!( 4 | # http_host: 'example.org', 5 | # https: false 6 | # ) 7 | -------------------------------------------------------------------------------- /web/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 | 9 | # Precompile additional assets. 10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 11 | # Rails.application.config.assets.precompile += %w( search.js ) 12 | -------------------------------------------------------------------------------- /web/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 | -------------------------------------------------------------------------------- /web/config/initializers/bower_rails.rb: -------------------------------------------------------------------------------- 1 | BowerRails.configure do |bower_rails| 2 | # Tell bower-rails what path should be considered as root. Defaults to Dir.pwd 3 | # bower_rails.root_path = Dir.pwd 4 | 5 | # Invokes rake bower:install before precompilation. Defaults to false 6 | # bower_rails.install_before_precompile = true 7 | 8 | # Invokes rake bower:resolve before precompilation. Defaults to false 9 | # bower_rails.resolve_before_precompile = true 10 | 11 | # Invokes rake bower:clean before precompilation. Defaults to false 12 | # bower_rails.clean_before_precompile = true 13 | 14 | # Invokes rake bower:install:deployment instead rake bower:install. Defaults to false 15 | # bower_rails.use_bower_install_deployment = true 16 | # 17 | # Invokes rake bower:install and rake bower:install:deployment with -F (force) flag. Defaults to false 18 | # bower_rails.force_install = true 19 | end 20 | -------------------------------------------------------------------------------- /web/config/initializers/callback_terminator.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Do not halt callback chains when a callback returns false. This is a new 4 | # Rails 5.0 default, so it is introduced as a configuration option to ensure 5 | # that apps made with earlier versions of Rails are not affected when upgrading. 6 | ActiveSupport.halt_callback_chains_on_return_false = false 7 | -------------------------------------------------------------------------------- /web/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 | -------------------------------------------------------------------------------- /web/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 | -------------------------------------------------------------------------------- /web/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 | -------------------------------------------------------------------------------- /web/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 | -------------------------------------------------------------------------------- /web/config/initializers/per_form_csrf_tokens.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Enable per-form CSRF tokens. 4 | Rails.application.config.action_controller.per_form_csrf_tokens = true 5 | -------------------------------------------------------------------------------- /web/config/initializers/request_forgery_protection.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Enable origin-checking CSRF mitigation. 4 | Rails.application.config.action_controller.forgery_protection_origin_check = true 5 | -------------------------------------------------------------------------------- /web/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_web_session' 4 | -------------------------------------------------------------------------------- /web/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 | -------------------------------------------------------------------------------- /web/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 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /web/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 }.to_i 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. If you use this option 30 | # you need to make sure to reconnect any threads in the `on_worker_boot` 31 | # block. 32 | # 33 | # preload_app! 34 | 35 | # The code in the `on_worker_boot` will be called if you are using 36 | # clustered mode by specifying a number of `workers`. After each worker 37 | # process is booted this block will be run, if you are using `preload_app!` 38 | # option you will want to use this block to reconnect to any threads 39 | # or connections that may have been created at application boot, Ruby 40 | # cannot share connections between processes. 41 | # 42 | # on_worker_boot do 43 | # ActiveRecord::Base.establish_connection if defined?(ActiveRecord) 44 | # end 45 | -------------------------------------------------------------------------------- /web/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 | 4 | resources :tasks 5 | 6 | # Serve websocket cable requests in-process 7 | # mount ActionCable.server => '/cable' 8 | root to: 'tasks#index' 9 | end 10 | -------------------------------------------------------------------------------- /web/config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rails secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | secret_key_base: 5a0aa29f77bb3687af51358ca997b84d3749148c1824fdfb7f8964ddb4aac4b3fe34112483b4c6376af7ffc8d8d176d3ceaf6656a82e043cdabb80804920caf4 15 | 16 | test: 17 | secret_key_base: fad8e2921597aaf671d411aff4ffd5c80b8b284c589467a938b28d62499cc83a090a905167991e675f9b5f1005d0758e4e55f78cdadb28d414e10f4ae3937546 18 | 19 | # Do not keep production secrets in the repository, 20 | # instead read values from the environment. 21 | production: 22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 23 | -------------------------------------------------------------------------------- /web/config/unicorn.rb: -------------------------------------------------------------------------------- 1 | worker_processes Integer(ENV['WEB_CONCURRENCY'] || 5) 2 | timeout 60 3 | preload_app true 4 | 5 | before_fork do |server, worker| 6 | Signal.trap 'TERM' do 7 | puts 'Unicorn master intercepting TERM and sending myself QUIT instead' 8 | Process.kill 'QUIT', Process.pid 9 | end 10 | end 11 | 12 | after_fork do |server, worker| 13 | Signal.trap 'TERM' do 14 | puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' 15 | end 16 | end 17 | 18 | working_directory "/my_project" 19 | 20 | listen "/tmp/unicorn.sock", :backlog => 64 21 | 22 | stderr_path "/my_project/log/unicorn.stderr.log" 23 | stdout_path "/my_project/log/unicorn.stdout.log" 24 | -------------------------------------------------------------------------------- /web/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 | -------------------------------------------------------------------------------- /web/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | RAILS_ENV=$RAILS_ENV bundle exec rake assets:precompile 4 | -------------------------------------------------------------------------------- /web/kubernetes-post-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | RAILS_ENV=$RAILS_ENV bundle exec rake db:create 4 | RAILS_ENV=$RAILS_ENV bundle exec rake db:migrate 5 | cp -a /my_project/public/. /assets 6 | -------------------------------------------------------------------------------- /web/lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/lib/assets/.keep -------------------------------------------------------------------------------- /web/lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/lib/tasks/.keep -------------------------------------------------------------------------------- /web/log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/log/.keep -------------------------------------------------------------------------------- /web/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 | -------------------------------------------------------------------------------- /web/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 | -------------------------------------------------------------------------------- /web/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 | -------------------------------------------------------------------------------- /web/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/public/favicon.ico -------------------------------------------------------------------------------- /web/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /web/test/controllers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/test/controllers/.keep -------------------------------------------------------------------------------- /web/test/fixtures/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/test/fixtures/.keep -------------------------------------------------------------------------------- /web/test/fixtures/files/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/test/fixtures/files/.keep -------------------------------------------------------------------------------- /web/test/helpers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/test/helpers/.keep -------------------------------------------------------------------------------- /web/test/integration/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/test/integration/.keep -------------------------------------------------------------------------------- /web/test/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/test/mailers/.keep -------------------------------------------------------------------------------- /web/test/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/test/models/.keep -------------------------------------------------------------------------------- /web/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 7 | fixtures :all 8 | 9 | # Add more helper methods to be used by all tests here... 10 | end 11 | -------------------------------------------------------------------------------- /web/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/vendor/assets/javascripts/.keep -------------------------------------------------------------------------------- /web/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxio/kubernetes-rails/9f14d442b7eebfb751d693c486bc2112fe4fdbe9/web/vendor/assets/stylesheets/.keep --------------------------------------------------------------------------------