Last active
July 24, 2018 11:41
-
-
Save ervinb/f93274b56ae7eab198224cba5a1fe7eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#---------------------------------------------- | |
## add this snippet to ./config/application.rb | |
#---------------------------------------------- | |
if ENV["SEMAPHORE_CACHE_DIR"] | |
config.assets.configure do |env| | |
env.cache = ActiveSupport::Cache::FileStore.new("#{ENV["SEMAPHORE_CACHE_DIR"]}/assets-cache") | |
end | |
end | |
#--------------------------------------- | |
## add to the setup | |
## bash ./scripts/restore-asset-cache.sh | |
#--------------------------------------- | |
#!/usr/bin/env bash | |
set -eo pipefail | |
assets_cache_archive="$SEMAPHORE_CACHE_DIR/assets-cache.tar.gz" | |
if [ -e $assets_cache_archive ]; then | |
echo "Restoring assets cache..." | |
tar -xf $assets_cache_archive -C $SEMAPHORE_CACHE_DIR | |
echo "Assets cache restored." | |
fi | |
#-------------------------------- | |
## put in an after job | |
## bash ./scripts/cache-assets.sh | |
#-------------------------------- | |
#!/usr/bin/env bash | |
assets_dir="assets-cache" | |
assets_path="$SEMAPHORE_CACHE_DIR/$assets_dir" | |
assets_archive="$SEMAPHORE_CACHE_DIR/${assets_dir}.tar.gz" | |
if [ -d $assets_path ]; then | |
echo "Removing old archive..." | |
rm -f $assets_archive | |
echo "Creating new archive ..." | |
tar -czf $assets_archive -C $SEMAPHORE_CACHE_DIR $assets_dir | |
echo "Removing uncompressed assets..." | |
rm -rf $assets_path | |
echo "Done." | |
else | |
echo "No asset cache found. Skipping compressing." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is a typo in the
application.rb
change: