diff --git a/Dockerfile b/Dockerfile index aef5043..1ff32c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ FROM phusion/passenger-ruby22:latest RUN apt-get update \ - && apt-get upgrade -y --force-yes \ && apt-get install -y ruby2.3 ruby2.3-dev \ && ruby-switch --set ruby2.3 @@ -22,6 +21,7 @@ ADD docker/db_migrate.sh /etc/my_init.d/db_migrate.sh RUN chmod +x /etc/my_init.d/db_migrate.sh # Set Default RAILS_ENV +ENV RAILS_ENV docker ENV PASSENGER_APP_ENV docker # Setup directory and install gems @@ -29,7 +29,7 @@ RUN mkdir -p /home/app/parsley/ COPY Gemfile /home/app/parsley/ COPY Gemfile.lock /home/app/parsley/ RUN gem install bundler -RUN cd /home/app/parsley/ && bundle install --deployment +RUN cd /home/app/parsley/ && bundle install --jobs 4 # Copy the app into the image COPY . /home/app/parsley/ diff --git a/config/environments/docker.rb b/config/environments/docker.rb index 9d8e4de..2f71bf1 100644 --- a/config/environments/docker.rb +++ b/config/environments/docker.rb @@ -1,79 +1,54 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # Code is not reloaded between requests. - config.cache_classes = true + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false - # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both threaded web servers - # and those relying on copy on write to perform better. - # Rake tasks automatically ignore this option for performance. - config.eager_load = true + # Do not eager load code on boot. + config.eager_load = false - # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false - config.action_controller.perform_caching = true + # Show full error reports. + config.consider_all_requests_local = true - # Enable Rack::Cache to put a simple HTTP cache in front of your application - # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like - # NGINX, varnish or squid. - # config.action_dispatch.rack_cache = true + # Enable/disable caching. By default caching is disabled. + if Rails.root.join('tmp/caching-dev.txt').exist? + config.action_controller.perform_caching = true - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. - config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => 'public, max-age=172800' + } + else + config.action_controller.perform_caching = false - # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier - # config.assets.css_compressor = :sass + config.cache_store = :null_store + end - # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = false + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true + config.action_mailer.perform_caching = false - # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log - # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache - config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug + # Suppress logger output for asset requests. + config.assets.quiet = true - # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) - - # Use a different cache store in production. - # config.cache_store = :mem_cache_store - - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' - - # Ignore bad email addresses and do not raise email delivery errors. - # Set this to true and configure the email server for immediate delivery to raise delivery errors. - # config.action_mailer.raise_delivery_errors = false - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation cannot be found). - config.i18n.fallbacks = true - - # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify - - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new - - # Do not dump schema after migrations. - config.active_record.dump_schema_after_migration = false + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + # config.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff --git a/db/schema.rb b/db/schema.rb index 7ee0c37..9ae8359 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -12,11 +12,14 @@ ActiveRecord::Schema.define(version: 20160707011314) do + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + create_table "ingredient_units", force: :cascade do |t| t.integer "ingredient_id", null: false t.string "name", null: false t.decimal "gram_weight", precision: 10, scale: 2, null: false - t.index ["ingredient_id"], name: "index_ingredient_units_on_ingredient_id" + t.index ["ingredient_id"], name: "index_ingredient_units_on_ingredient_id", using: :btree end create_table "ingredients", force: :cascade do |t| @@ -74,7 +77,7 @@ ActiveRecord::Schema.define(version: 20160707011314) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.text "preparation" - t.index ["recipe_id"], name: "index_recipe_ingredients_on_recipe_id" + t.index ["recipe_id"], name: "index_recipe_ingredients_on_recipe_id", using: :btree end create_table "recipe_steps", force: :cascade do |t| @@ -83,7 +86,7 @@ ActiveRecord::Schema.define(version: 20160707011314) do t.text "step" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.index ["recipe_id"], name: "index_recipe_steps_on_recipe_id" + t.index ["recipe_id"], name: "index_recipe_steps_on_recipe_id", using: :btree end create_table "recipes", force: :cascade do |t| @@ -106,7 +109,7 @@ ActiveRecord::Schema.define(version: 20160707011314) do t.decimal "gram_weight", precision: 7, scale: 1 t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.index ["usda_food_id"], name: "index_usda_food_weights_on_usda_food_id" + t.index ["usda_food_id"], name: "index_usda_food_weights_on_usda_food_id", using: :btree end create_table "usda_foods", force: :cascade do |t| @@ -147,8 +150,8 @@ ActiveRecord::Schema.define(version: 20160707011314) do t.decimal "vit_d", precision: 10, scale: 1 t.decimal "vit_k", precision: 10, scale: 1 t.decimal "cholesterol", precision: 10, scale: 3 - t.index ["long_description"], name: "index_usda_foods_on_long_description" - t.index ["ndbn"], name: "index_usda_foods_on_ndbn" + t.index ["long_description"], name: "index_usda_foods_on_long_description", using: :btree + t.index ["ndbn"], name: "index_usda_foods_on_ndbn", using: :btree end create_table "users", force: :cascade do |t| diff --git a/docker-compose-rlyeh.yml b/docker-compose-rlyeh.yml index e2bcdf8..bd63c1e 100644 --- a/docker-compose-rlyeh.yml +++ b/docker-compose-rlyeh.yml @@ -1,9 +1,12 @@ -web: - image: danelbert/parsley:production - ports: - - "7000:80" - environment: - - PASSENGER_APP_ENV=production - env_file: /etc/default/parsley - volumes: - - /var/log/parsley/:/home/app/parsley/log \ No newline at end of file +version: '2' + +services: + web: + image: danelbert/parsley:production + ports: + - "7000:80" + environment: + - PASSENGER_APP_ENV=production + env_file: /etc/default/parsley + volumes: + - /var/log/parsley/:/home/app/parsley/log \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index a257613..af0348a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,8 @@ services: build: . ports: - "3000:80" + volumes: + - .:/home/app/parsley/ links: - postgres volumes: diff --git a/docker/nginx_server.conf b/docker/nginx_server.conf index 8570cca..d8c86f3 100644 --- a/docker/nginx_server.conf +++ b/docker/nginx_server.conf @@ -5,7 +5,7 @@ server { passenger_enabled on; passenger_user app; - passenger_ruby /usr/bin/ruby2.2; + passenger_ruby /usr/bin/ruby; location ~ ^/(assets)/ { gzip_static on;