Skip to content

Commit

Permalink
Merge pull request #7 from rotati/configure-asset-sync
Browse files Browse the repository at this point in the history
configured asset sync
  • Loading branch information
kirykr authored Dec 10, 2019
2 parents 9640011 + e59f1cf commit 1bc4220
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 124 deletions.
8 changes: 8 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,13 @@ OSCAR_M_E_DASHBOARD_DATABASE_NAME=''
OSCAR_M_E_DASHBOARD_DATABASE_USERNAME=''
OSCAR_M_E_DASHBOARD_DATABASE_PASSWORD=''

FOG_DIRECTORY=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
FOG_REGION=

AWS_SES_USER_NAME=
AWS_SES_PASSWORD=

SENDER_EMAIL=[email protected]
BROWSER=/usr/local/bin/firefox-bin -new-tab '%s':/usr/local/bin/google-chrome-stable
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ gem 'apartment', github: 'influitive/apartment', branch: 'development'

group :staging, :production do
gem 'appsignal', '~> 2.3', '>= 2.3.7'
gem 'asset_sync', '~> 2.8', '>= 2.8.1'
gem 'fog-aws', '~> 3.5', '>= 3.5.2'
end

group :development, :test do
Expand Down
34 changes: 34 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ GEM
appsignal (2.9.13-java)
ffi
rack
asset_sync (2.8.1)
activemodel (>= 4.1.0)
fog-core
mime-types (>= 2.99)
unf
autoprefixer-rails (9.6.1.1)
execjs
bcrypt (3.1.13)
Expand Down Expand Up @@ -164,6 +169,7 @@ GEM
eventmachine (1.2.7-java)
eventmachine (1.2.7-x64-mingw32)
eventmachine (1.2.7-x86-mingw32)
excon (0.70.0)
execjs (2.7.0)
factory_bot (5.0.2)
activesupport (>= 4.2.0)
Expand All @@ -175,8 +181,25 @@ GEM
ffi (1.11.1-java)
ffi (1.11.1-x64-mingw32)
ffi (1.11.1-x86-mingw32)
fog-aws (3.5.2)
fog-core (~> 2.1)
fog-json (~> 1.1)
fog-xml (~> 0.1)
ipaddress (~> 0.8)
fog-core (2.1.2)
builder
excon (~> 0.58)
formatador (~> 0.2)
mime-types
fog-json (1.2.0)
fog-core
multi_json (~> 1.10)
fog-xml (0.1.3)
fog-core
nokogiri (>= 1.5.11, < 2.0.0)
font-awesome-rails (4.7.0.5)
railties (>= 3.2, < 6.1)
formatador (0.2.5)
globalid (0.4.2)
activesupport (>= 4.2.0)
haml (5.1.2)
Expand All @@ -202,6 +225,7 @@ GEM
image_processing (1.9.3)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.13, < 3)
ipaddress (0.8.3)
jbuilder (2.9.1)
activesupport (>= 4.2.0)
jquery-datatables-rails (3.4.0)
Expand Down Expand Up @@ -242,6 +266,9 @@ GEM
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mime-types (3.3)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
mimemagic (0.3.3)
mini_magick (4.9.5)
mini_mime (1.0.2)
Expand All @@ -251,6 +278,7 @@ GEM
msgpack (1.3.1-java)
msgpack (1.3.1-x64-mingw32)
msgpack (1.3.1-x86-mingw32)
multi_json (1.14.1)
net-scp (2.0.0)
net-ssh (>= 2.6.5, < 6.0.0)
net-ssh (5.2.0)
Expand Down Expand Up @@ -412,6 +440,10 @@ GEM
tzinfo (>= 1.0.0)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf (0.1.4-java)
unf_ext (0.0.7.6)
warden (1.2.8)
rack (>= 2.0.6)
web-console (4.0.1)
Expand All @@ -438,6 +470,7 @@ PLATFORMS
DEPENDENCIES
apartment!
appsignal (~> 2.3, >= 2.3.7)
asset_sync (~> 2.8, >= 2.8.1)
bootsnap (>= 1.4.2)
bootstrap-datepicker-rails (~> 1.8, >= 1.8.0.1)
bootstrap-sass (~> 3.3.5)
Expand All @@ -455,6 +488,7 @@ DEPENDENCIES
draper (~> 3.1)
factory_bot_rails (~> 5.0, >= 5.0.2)
ffaker (~> 2.1.0)
fog-aws (~> 3.5, >= 3.5.2)
font-awesome-rails (~> 4.7, >= 4.7.0.5)
haml (~> 5.1, >= 5.1.2)
haml-rails (~> 2.0, >= 2.0.1)
Expand Down
63 changes: 2 additions & 61 deletions config/deploy/production.rb
Original file line number Diff line number Diff line change
@@ -1,61 +1,2 @@
# server-based syntax
# ======================
# Defines a single server with a list of roles and multiple properties.
# You can define all roles on a single server, or split them:

# server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value
# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value
# server "db.example.com", user: "deploy", roles: %w{db}



# role-based syntax
# ==================

# Defines a role with one or multiple servers. The primary server in each
# group is considered to be the first unless any hosts have the primary
# property set. Specify the username and a domain or IP for the server.
# Don't use `:all`, it's a meta role.

# role :app, %w{[email protected]}, my_property: :my_value
# role :web, %w{[email protected] [email protected]}, other_property: :other_value
# role :db, %w{[email protected]}



# Configuration
# =============
# You can set any configuration variable like in config/deploy.rb
# These variables are then only loaded and set in this stage.
# For available Capistrano configuration variables see the documentation page.
# http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup.



# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a
# limited set of options, consult the Net::SSH documentation.
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
#
# Global options
# --------------
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
#
# The server-based syntax can be used to override options:
# ------------------------------------
# server "example.com",
# user: "user_name",
# roles: %w{web app},
# ssh_options: {
# user: "user_name", # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: "please use keys"
# }
set :stage, :production
server '18.136.64.117', user: 'deployer', roles: %w{app web db}
63 changes: 2 additions & 61 deletions config/deploy/staging.rb
Original file line number Diff line number Diff line change
@@ -1,61 +1,2 @@
# server-based syntax
# ======================
# Defines a single server with a list of roles and multiple properties.
# You can define all roles on a single server, or split them:

# server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value
# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value
# server "db.example.com", user: "deploy", roles: %w{db}



# role-based syntax
# ==================

# Defines a role with one or multiple servers. The primary server in each
# group is considered to be the first unless any hosts have the primary
# property set. Specify the username and a domain or IP for the server.
# Don't use `:all`, it's a meta role.

# role :app, %w{[email protected]}, my_property: :my_value
# role :web, %w{[email protected] [email protected]}, other_property: :other_value
# role :db, %w{[email protected]}



# Configuration
# =============
# You can set any configuration variable like in config/deploy.rb
# These variables are then only loaded and set in this stage.
# For available Capistrano configuration variables see the documentation page.
# http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup.



# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a
# limited set of options, consult the Net::SSH documentation.
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
#
# Global options
# --------------
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
#
# The server-based syntax can be used to override options:
# ------------------------------------
# server "example.com",
# user: "user_name",
# roles: %w{web app},
# ssh_options: {
# user: "user_name", # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: "please use keys"
# }
set :stage, :staging
server '18.136.64.117', user: 'deployer', roles: %w{app web db}
4 changes: 2 additions & 2 deletions config/environments/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
# config.active_job.queue_name_prefix = "oscar_m_e_dashboard_production"

config.action_mailer.perform_caching = false
config.action_mailer.asset_host = "https://oscarhq.com"
config.action_mailer.default_url_options = { host: 'https://oscarhq.com' }
config.action_mailer.asset_host = "http://oscarhq-staging.com"
config.action_mailer.default_url_options = { host: 'http://oscarhq-staging.com' }
config.assets.digest = true
config.assets.enabled = true
config.assets.initialize_on_precompile = true
Expand Down
14 changes: 14 additions & 0 deletions config/initializers/asset_sync.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if defined?(AssetSync)
if Rails.env.production? || Rails.env.staging?
AssetSync.configure do |config|
config.fog_provider = 'AWS'
config.fog_directory = ENV['FOG_DIRECTORY']
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
config.existing_remote_files = 'delete'
config.fog_region = ENV['FOG_REGION']
config.gzip_compression = true
config.custom_headers = { '.*' => { cache_control: 'max-age=315576000', expires: 1.year.from_now.httpdate } }
end
end
end

0 comments on commit 1bc4220

Please sign in to comment.