From 1aec0f95a41c5cdb523eb80a04043394a6f9ae4b Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 25 Apr 2020 13:02:20 +0200 Subject: [PATCH] Add configurable asset caching for Docker on Windows environments --- config/initializers/assets.rb | 10 +++++++++- docker-compose.yml | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index e321065f..75540cd5 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,5 +1,13 @@ # Be sure to restart your server when you modify this file. +Rails.application.config.assets.configure do |env| + env.cache = Sprockets::Cache::FileStore.new( + ENV.fetch("SPROCKETS_CACHE", "#{env.root}/tmp/cache/assets"), + Rails.application.config.assets.cache_limit, + env.logger + ) +end + # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' @@ -9,4 +17,4 @@ Rails.application.config.assets.version = '1.0' # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. Rails.application.config.assets.precompile += %w( moderation.js ) -Rails.application.config.assets.precompile += %w( i18n.js ) +Rails.application.config.assets.precompile += %w( i18n.js ) \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 42c43d33..659d7afe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,9 +10,11 @@ services: links: - postgres - redis + environment: + - SPROCKETS_CACHE=/cache volumes: - ./:/app - - cache:/app/tmp/cache + - cache:/cache ports: - 3000:3000