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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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}",
Lines changed: 109 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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(

0 commit comments

Comments
 (0)