Skip to content

Commit

Permalink
Deploy configs
Browse files Browse the repository at this point in the history
  • Loading branch information
andersoncardoso committed Oct 7, 2016
1 parent 0dff01f commit 6909032
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -38,6 +38,7 @@ gem 'sidekiq' # background jobs
gem 'http_accept_language' # get locale from http headers
gem 'carrierwave' # file uploads abstraction
gem 'carrierwave_backgrounder' # delegate uploads to background jobs
gem 'fog-aws' # store images on s3
gem 'mini_magick' # image processing for uploaders
gem 'remotipart' # enable ajax file uploads on remote forms
gem 'kaminari' # paginator
Expand Down Expand Up @@ -88,6 +89,7 @@ end

group :production, :staging do
gem 'mailgun_rails' # mailgun integration for actionmailer
gem 'rails_12factor' # used for deploying in heroku
end

group :profile do
Expand Down
24 changes: 24 additions & 0 deletions Gemfile.lock
Expand Up @@ -114,6 +114,7 @@ GEM
erubis (2.7.0)
event_bus (1.0.0)
eventmachine (1.0.3)
excon (0.53.0)
execjs (2.2.2)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
Expand All @@ -125,6 +126,21 @@ GEM
ffi (1.9.6)
figaro (1.0.0)
thor (~> 0.14)
fog-aws (0.12.0)
fog-core (~> 1.38)
fog-json (~> 1.0)
fog-xml (~> 0.1)
ipaddress (~> 0.8)
fog-core (1.43.0)
builder
excon (~> 0.49)
formatador (~> 0.2)
fog-json (1.0.2)
fog-core (~> 1.0)
multi_json (~> 1.10)
fog-xml (0.1.2)
fog-core
nokogiri (~> 1.5, >= 1.5.11)
font-awesome-sass (4.2.1)
sass (~> 3.2)
foreman (0.75.0)
Expand Down Expand Up @@ -155,6 +171,7 @@ GEM
slop (>= 3.5.0)
term-ansicolor
terminal-table
ipaddress (0.8.3)
jquery-fileupload-rails (0.4.1)
actionpack (>= 3.1)
railties (>= 3.1)
Expand Down Expand Up @@ -256,6 +273,11 @@ GEM
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.8)
sprockets-rails (~> 2.0)
rails_12factor (0.0.3)
rails_serve_static_assets
rails_stdout_logging
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
railties (4.1.8)
actionpack (= 4.1.8)
activesupport (= 4.1.8)
Expand Down Expand Up @@ -402,6 +424,7 @@ DEPENDENCIES
event_bus
factory_girl_rails
figaro
fog-aws
font-awesome-sass
foreman
guard-rspec
Expand All @@ -428,6 +451,7 @@ DEPENDENCIES
public_activity
puma
rails (~> 4.1.1)
rails_12factor
rdiscount
remotipart
responders
Expand Down
3 changes: 0 additions & 3 deletions app/uploaders/avatar_uploader.rb
Expand Up @@ -4,9 +4,6 @@ class AvatarUploader < CarrierWave::Uploader::Base
include ::CarrierWave::Backgrounder::Delay
include CarrierWave::MiniMagick

# Choose what kind of storage to use for this uploader:
storage :file

# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
Expand Down
2 changes: 0 additions & 2 deletions app/uploaders/import_uploader.rb
Expand Up @@ -4,8 +4,6 @@ class ImportUploader < CarrierWave::Uploader::Base
include ::CarrierWave::Backgrounder::Delay
include CarrierWave::MiniMagick

storage :file

def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
Expand Down
2 changes: 0 additions & 2 deletions app/uploaders/picture_uploader.rb
Expand Up @@ -4,8 +4,6 @@ class PictureUploader < CarrierWave::Uploader::Base
include ::CarrierWave::Backgrounder::Delay
include CarrierWave::MiniMagick

storage :file

def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
Expand Down
24 changes: 24 additions & 0 deletions config/application.rb
Expand Up @@ -14,6 +14,30 @@
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)


class ActiveRecordOverrideRailtie < Rails::Railtie
initializer "active_record.initialize_database.override" do |app|

ActiveSupport.on_load(:active_record) do
if url = ENV['DATABASE_URL']
ActiveRecord::Base.connection_pool.disconnect!
parsed_url = URI.parse(url)
config = {
adapter: 'postgis',
host: parsed_url.host,
encoding: 'unicode',
database: parsed_url.path.split("/")[-1],
port: parsed_url.port,
username: parsed_url.user,
password: parsed_url.password
}
establish_connection(config)
end
end
end
end


module Meppit
class Application < Rails::Application
# Set Time.zone default and make Active Record auto-convert to this zone.
Expand Down
20 changes: 16 additions & 4 deletions config/initializers/carrierwave.rb
@@ -1,5 +1,17 @@
CarrierWave.configure do |config|
config.storage = :file
config.enable_processing = false
if Rails.env.test? || Rails.env.development?
CarrierWave.configure do |config|
config.storage = :file
config.enable_processing = false
end
else
CarrierWave.configure do |config|
config.fog_provider = 'fog/aws'
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => ENV["S3_KEY"],
:aws_secret_access_key => ENV["S3_SECRET"],
}
config.asset_host = "https://s3.amazonaws.com/#{ENV["S3_BUCKET"]}"
config.fog_directory = ENV["S3_BUCKET"]
end
end

15 changes: 15 additions & 0 deletions config/initializers/sidekiq.rb
@@ -1,3 +1,18 @@
ENV["REDIS_URL"] ||= "redis://localhost:6379"

# Sidekiq.configure_server do |config|
# config.redis = { url: ENV["REDIS_URL"] }

# database_url = ENV['DATABASE_URL']
# if database_url
# ENV['DATABASE_URL'] = "#{database_url}?pool=10"
# ActiveRecord::Base.establish_connection
# end

# end


Sidekiq.configure_client do |config|
config.redis = { url: ENV["REDIS_URL"] }
config.logger.level = Logger::WARN
end
2 changes: 1 addition & 1 deletion config/puma.rb
Expand Up @@ -4,7 +4,7 @@
preload_app!

rackup DefaultRackup
# port ENV['PORT'] || 3000
port ENV['PORT'] || 3000
bind 'unix://tmp/sockets/puma.sock'
environment ENV['RACK_ENV'] || 'development'

Expand Down

0 comments on commit 6909032

Please sign in to comment.