Skip to content

Commit 9ed4225

Browse files
committed
added local-production env
1 parent 2c03aee commit 9ed4225

16 files changed

+194
-13
lines changed

.dev_to/compose.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ x-app: &app
88
image: optimize-dev-to:1.0.0
99
environment: &env
1010
NODE_ENV: ${NODE_ENV:-development}
11-
RAILS_ENV: ${RAILS_ENV:-development}
11+
RAILS_ENV: ${RAILS_ENV:-local_production}
1212
tmpfs:
1313
- /tmp
1414
- /app/tmp/pids
@@ -35,6 +35,7 @@ x-backend: &backend
3535
ALGOLIASEARCH_SEARCH_ONLY_KEY: ${ALGOLIASEARCH_SEARCH_ONLY_KEY}
3636
NEW_RELIC_KEY: ${NEW_RELIC_KEY}
3737
SCOUT_KEY: ${SCOUT_KEY}
38+
RAILS_ENV: local_production
3839
REDIS_URL: redis://redis:6379/
3940
DATABASE_URL: postgres://postgres:postgres@postgres:5432
4041
WEBPACKER_DEV_SERVER_HOST: webpacker

Gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ gem 'newrelic_rpm'
108108
gem 'scout_apm'
109109
gem 'rack-mini-profiler'
110110

111-
group :development do
111+
group :development, :local_production do
112112
gem "better_errors", "~> 2.5"
113113
gem "binding_of_caller", "~> 0.8"
114114
gem "brakeman", "~> 4.4", require: false
@@ -122,7 +122,7 @@ group :development do
122122
gem "web-console", "~> 3.7"
123123
end
124124

125-
group :development, :test do
125+
group :development, :local_production, :test do
126126
gem "capybara", "~> 3.13"
127127
gem "derailed", "~> 0.1"
128128
gem "erb_lint", "~> 0.0", require: false

app/helpers/application_helper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def icon_url(name)
8383
end
8484

8585
def cloudinary(url, width = nil, _quality = 80, _format = "jpg")
86-
return url if Rails.env.development? && (url.blank? || url.exclude?("http"))
86+
return url if (Rails.env.development? || Rails.env.local_production?) && (url.blank? || url.exclude?("http"))
8787

8888
service_path = "https://res.cloudinary.com/practicaldev/image/fetch"
8989

@@ -101,7 +101,7 @@ def cloudinary(url, width = nil, _quality = 80, _format = "jpg")
101101
def cloud_cover_url(url)
102102
return if url.blank?
103103
return asset_path("triple-unicorn") if Rails.env.test?
104-
return url if Rails.env.development?
104+
return url if Rails.env.development? || Rails.env.local_production?
105105

106106
width = 1000
107107
height = 420

app/observers/article_observer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class ArticleObserver < ApplicationObserver
22
def after_save(article)
3-
return if Rails.env.development?
3+
return if Rails.env.development? || Rails.env.local_production?
44

55
if article.published && article.published_at > 30.seconds.ago
66
SlackBot.delay.ping "New Article Published: #{article.title}\nhttps://dev.to#{article.path}",

app/observers/comment_observer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class CommentObserver < ApplicationObserver
22
def after_save(comment)
3-
return if Rails.env.development?
3+
return if Rails.env.development? || Rails.env.local_production?
44

55
warned_user_ping(comment)
66
rescue StandardError

app/observers/organization_observer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class OrganizationObserver < ActiveRecord::Observer
22
def after_create(organization)
3-
return if Rails.env.development?
3+
return if Rails.env.development? || Rails.env.local_production?
44

55
SlackBot.delay.ping(
66
"New Org Created: #{organization.name}\nhttps://dev.to/#{organization.username}",
+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# rubocop:disable Metrics/BlockLength
2+
#
3+
def yarn_integrity_enabled?
4+
ENV.fetch("YARN_INTEGRITY_ENABLED", "true") == "true"
5+
end
6+
7+
Rails.application.configure do
8+
# Verifies that versions and hashed value of the package contents in the project's package.json
9+
config.webpacker.check_yarn_integrity = yarn_integrity_enabled?
10+
11+
# Settings specified here will take precedence over those in config/application.rb.
12+
13+
# In the development environment your application's code is reloaded on
14+
# every request. This slows down response time but is perfect for development
15+
# since you don't have to restart the web server when you make code changes.
16+
config.cache_classes = true
17+
18+
# Do not eager load code on boot.
19+
config.eager_load = true
20+
21+
# Show full error reports and disable caching.
22+
config.consider_all_requests_local = true
23+
24+
# Enable/disable caching. By default caching is disabled.
25+
if Rails.root.join("tmp/caching-dev.txt").exist?
26+
config.action_controller.perform_caching = true
27+
28+
config.cache_store = :memory_store
29+
config.public_file_server.headers = {
30+
"Cache-Control" => "public, max-age=172800"
31+
}
32+
else
33+
config.action_controller.perform_caching = false
34+
35+
config.cache_store = :null_store
36+
end
37+
38+
config.assets_debug = false
39+
config.assets_compile = false
40+
41+
config.web_console.development_only = false
42+
43+
# Don't care if the mailer can't send.
44+
config.action_mailer.raise_delivery_errors = false
45+
46+
# Print deprecation notices to the Rails logger.
47+
config.active_support.deprecation = :log
48+
49+
# Raise an error on page load if there are pending migrations.
50+
config.active_record.migration_error = :page_load
51+
52+
# Debug mode disables concatenation and preprocessing of assets.
53+
# This option may cause significant delays in view rendering with a large
54+
# number of complex assets.
55+
config.assets.debug = false
56+
57+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
58+
# yet still be able to expire them through the digest params.
59+
config.assets.digest = false
60+
61+
# Supress logger output for asset requests.
62+
config.assets.quiet = true
63+
64+
# Adds additional error checking when serving assets at runtime.
65+
# Checks for improperly declared sprockets dependencies.
66+
# Raises helpful error messages.
67+
config.assets.raise_runtime_errors = true
68+
69+
config.action_mailer.perform_caching = false
70+
71+
config.app_domain = "localhost:3000"
72+
73+
config.action_mailer.default_url_options = { host: "localhost:3000" }
74+
config.action_mailer.delivery_method = :smtp
75+
config.action_mailer.perform_deliveries = true
76+
config.action_mailer.default_url_options = { host: config.app_domain }
77+
config.action_mailer.smtp_settings = {
78+
address: "smtp.gmail.com",
79+
port: "587",
80+
enable_starttls_auto: true,
81+
user_name: '<%= ENV["DEVELOPMENT_EMAIL_USERNAME"] %>',
82+
password: '<%= ENV["DEVELOPMENT_EMAIL_PASSWORD"] %>',
83+
authentication: :plain,
84+
domain: "localhost:3000"
85+
}
86+
87+
config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews"
88+
89+
# Raises error for missing translations
90+
# config.action_view.raise_on_missing_translations = true
91+
92+
config.public_file_server.enabled = true
93+
94+
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
95+
96+
# Install the Timber.io logger
97+
send_logs_to_timber = ENV["SEND_LOGS_TO_TIMBER"] || "false" # <---- set to false to stop sending dev logs to Timber.io
98+
log_device = send_logs_to_timber == "true" ? Timber::LogDevices::HTTP.new(ENV["TIMBER"]) : STDOUT
99+
logger = Timber::Logger.new(log_device)
100+
logger.level = config.log_level
101+
config.logger = ActiveSupport::TaggedLogging.new(logger)
102+
103+
config.after_initialize do
104+
Bullet.enable = true
105+
Bullet.console = true
106+
end
107+
end
108+
109+
# rubocop:enable Metrics/BlockLength

config/initializers/airbrake.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# environments.
4242
# NOTE: This option *does not* work if you don't set the 'environment' option.
4343
# https://github.com/airbrake/airbrake-ruby#ignore_environments
44-
c.ignore_environments = %w[test development]
44+
c.ignore_environments = %w[test development local_production]
4545

4646
# A list of parameters that should be filtered out of what is sent to
4747
# Airbrake. By default, all "password" attributes will have their contents

config/initializers/carrierwave.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require "carrierwave/storage/fog"
44

55
CarrierWave.configure do |config|
6-
if Rails.env.development? || Rails.env.test?
6+
if Rails.env.development? || Rails.env.test? || Rails.env.local_production?
77
config.storage = :file
88
else
99
# config.fog_provider = 'fog-aws'

config/initializers/honeycomb.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
key = ApplicationConfig["HONEYCOMB_API_KEY"]
44
dataset = "dev.to-#{Rails.env}"
55

6-
$libhoney = if Rails.env.development? || Rails.env.test?
6+
$libhoney = if Rails.env.development? || Rails.env.test? || Rails.env.local_production?
77
Libhoney::NullClient.new
88
else
99
Libhoney::Client.new(

config/initializers/reverse_markdown.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Because files are eagerloaded in production, this fix is only
55
# applicable in development (and test, when needed)
66

7-
if Rails.env.development? || Rails.env.test?
7+
if Rails.env.development? || Rails.env.test? || Rails.env.local_production?
88
Rails.application.config.to_prepare do
99
Dir.glob(Rails.root.join("app/lib/reverse_markdown/converters/*.rb")).sort.each do |filename|
1010
require_dependency filename

config/newrelic.yml

+3
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ staging:
6464

6565
production:
6666
<<: *default_settings
67+
68+
local_production:
69+
<<: *default_settings

config/scout_apm.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This configuration file is used for Scout APM.
2+
# Environment variables can also be used to configure Scout. See our help docs at https://scoutapm.com/docs/ruby/configuration#environment-variables for more information.
3+
common: &defaults
4+
5+
# key: Your Organization key for Scout APM. Found on the settings screen.
6+
# - Default: none
7+
key: <%= ENV['SCOUT_KEY'] %>
8+
9+
# log_level: Verboseness of logs.
10+
# - Default: 'info'
11+
# - Valid Options: debug, info, warn, error
12+
# log_level: debug
13+
14+
# use_prepend: Use the newer `prepend` instrumentation method. In some cases, gems
15+
# that use `alias_method` can conflict with gems that use `prepend`.
16+
# To avoid the conflict, change this setting to match the method
17+
# that the other gems use.
18+
# If you have another APM gem installed, such as DataDog or NewRelic,
19+
# you will likely want to set `use_prepend` to true.
20+
#
21+
# See https://scoutapm.com/docs/ruby/configuration#library-instrumentation-method
22+
# for more information.
23+
# - Default: false
24+
# - Valid Options: true, false
25+
# use_prepend: true
26+
27+
# name: Application name in APM Web UI
28+
# - Default: the application names comes from the Rails or Sinatra class name
29+
# name:
30+
31+
# monitor: Enable Scout APM or not
32+
# - Default: none
33+
# - Valid Options: true, false
34+
monitor: <%= ENV['SCOUT_MONITOR'] == 'true' %>
35+
36+
production:
37+
<<: *defaults
38+
39+
development:
40+
<<: *defaults
41+
monitor: true
42+
43+
test:
44+
<<: *defaults
45+
monitor: false
46+
47+
staging:
48+
<<: *defaults
49+
50+
local_production:
51+
<<: *defaults
52+
monitor: true

config/secrets.yml

+2
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ test:
2222
production:
2323
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
2424

25+
local_production:
26+
secret_key_base: a60edc976c913b19fd9fc8118936fbe1df2b07f4eecc5ad32f975e33cd4ea36b150c1ce933b681b90874a46568041629003dcbfc07238f7dca91741bcd1ec870

config/webpacker.yml

+14
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,17 @@ production:
5454

5555
# Cache manifest.json for performance
5656
cache_manifest: true
57+
58+
local_production:
59+
<<: *default
60+
61+
# Production depends on precompilation of packs prior to booting for performance.
62+
compile: false
63+
64+
# Cache manifest.json for performance
65+
cache_manifest: true
66+
dev_server:
67+
host: localhost
68+
port: 3035
69+
hmr: false
70+
https: false

dip.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: '7.1'
33
# Define default environment variables to pass
44
# to Docker Compose
55
environment:
6-
RAILS_ENV: development
6+
RAILS_ENV: <%= ENV.fetch('RAILS_ENV', 'development') %>
77

88
compose:
99
files:

0 commit comments

Comments
 (0)