diff --git a/config/deploy.rb b/config/deploy.rb index 35e19f5..8009818 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -8,7 +8,7 @@ set :assets_dir, %w(public/assets public/system) # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp } -set :deploy_to, '/home/jesse/web/thirteen-tien-len' +set :deploy_to, "/home/jesse/web/thirteen-tien-len_#{fetch(:stage)}" # set :scm, :git # set :format, :pretty diff --git a/config/deploy/nginx_conf.erb b/config/deploy/nginx_conf.erb index 682f213..cb1d3d1 100644 --- a/config/deploy/nginx_conf.erb +++ b/config/deploy/nginx_conf.erb @@ -1,5 +1,5 @@ upstream <%= fetch(:nginx_upstream) %> { - server unix:///home/jesse/web/thirteen-tien-len/shared/tmp/sockets/puma.sock fail_timeout=0; + server unix:///home/jesse/web/thirteen-tien-len_<%= fetch(:stage) %>/shared/tmp/sockets/puma.sock fail_timeout=0; } server { diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb index a3e50ce..fac0470 100644 --- a/config/deploy/staging.rb +++ b/config/deploy/staging.rb @@ -1,13 +1,15 @@ set :stage, :staging +set :nginx_server_name, 'staging.tienlen.ga' # optional, defaults to :application + # Simple Role Syntax # ================== # Supports bulk-adding hosts to roles, the primary # server in each group is considered to be the first # unless any hosts have the primary property set. -role :app, %w{deploy@example.com} -role :web, %w{deploy@example.com} -role :db, %w{deploy@example.com} +role :app, %w{jesse@staging.tienlen.ga} +role :web, %w{jesse@staging.tienlen.ga} +role :db, %w{jesse@staging.tienlen.ga} # Extended Server Syntax # ====================== @@ -15,17 +17,18 @@ role :db, %w{deploy@example.com} # definition into the server list. The second argument # something that quacks like a hash can be used to set # extended properties on the server. -server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value +server 'staging.tienlen.ga', user: 'jesse', roles: %w{web app db}, my_property: :my_value # you can set custom ssh options # it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options # you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start) # set it globally -# set :ssh_options, { + set :ssh_options, { # keys: %w(/home/rlisowski/.ssh/id_rsa), # forward_agent: false, # auth_methods: %w(password) -# } + port: 27997 + } # and/or per server # server 'example.com', # user: 'user_name', @@ -38,5 +41,5 @@ server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value # # password: 'please use keys' # } # setting per server overrides global ssh_options - # fetch(:default_env).merge!(rails_env: :staging) + diff --git a/config/environments/staging.rb b/config/environments/staging.rb new file mode 100644 index 0000000..4ae8153 --- /dev/null +++ b/config/environments/staging.rb @@ -0,0 +1,98 @@ +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 + + # 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 + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = 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 + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # `config.assets.precompile` and `config.assets.version` have moved + # to config/initializers/assets.rb + + # 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 + + # Force all access to the app over SSL, use Strict-Transport-Security, + # and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # 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 + + config.action_mailer.smtp_settings = { + address: 'smtp.gmail.com', + port: 587, + domain: Rails.application.secrets.domain_name, + authentication: 'plain', + enable_starttls_auto: true, + user_name: Rails.application.secrets.email_provider_username, + password: Rails.application.secrets.email_provider_password + } + # ActionMailer Config + config.action_mailer.default_url_options = { host: Rails.application.secrets.domain_name } + config.action_mailer.delivery_method = :smtp + config.action_mailer.perform_deliveries = true + config.action_mailer.raise_delivery_errors = false + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # 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 +end diff --git a/config/secrets.yml b/config/secrets.yml index dff3e59..e49e585 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -23,6 +23,15 @@ test: domain_name: example.com secret_key_base: b293e2494b3116d86fa96a2a68a5a758c0c0c0d78799e7e948f8beea5c6907c7f4fbe299fa4645bdda6b9a61ba8a73af85a97df09167e2976c1eea55116fb4b6 +staging: + admin_name: <%= ENV["ADMIN_NAME"] %> + admin_email: <%= ENV["ADMIN_EMAIL"] %> + admin_password: <%= ENV["ADMIN_PASSWORD"] %> + email_provider_username: <%= ENV["GMAIL_USERNAME"] %> + email_provider_password: <%= ENV["GMAIL_PASSWORD"] %> + domain_name: <%= ENV["DOMAIN_NAME"] %> + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> + # Do not keep production secrets in the repository, # instead read values from the environment. production: