Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Persistent Rails assets #15

Merged
merged 1 commit into from

2 participants

Fotios Lindiakos Hiro Asari
Fotios Lindiakos

This will allow us to permanently store assets in the $OPENSHIFT_DATA_DIRECTORY. The turbo-sprockets-rails3 gem intelligently compiles only changed assets.

The initial push will still take the normal amount of time, but subsequent pushes are much faster (obviously this is dependent on how many assets have changed).

Here is a simple experiment with the stock Rails app. Even with a small number of assets, the time was cut in half.

> rake assets:clean
> time rake assets:precompile

real    0m39.296s
user    0m10.213s
sys     0m1.498s

> time rake assets:precompile
real    0m19.169s
user    0m4.634s
sys     0m1.081s
Fotios Lindiakos Persistent Rails assets 6d06a0b
Fotios Lindiakos thefotios referenced this pull request in openshift/origin-server
Closed

Storing assets in the build/pre_build scripts #235

Hiro Asari BanzaiMan merged commit e41937c into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 25, 2013
  1. Persistent Rails assets

    Fotios Lindiakos authored
This page is out of date. Refresh to see the latest.
Showing with 22 additions and 0 deletions.
  1. +16 −0 .openshift/action_hooks/pre_build
  2. +2 −0  Gemfile
  3. +4 −0 Gemfile.lock
16 .openshift/action_hooks/pre_build
View
@@ -4,3 +4,19 @@
# before the build step. This script gets executed directly, so it
# could be python, php, ruby, etc.
+STORED_ASSETS="${OPENSHIFT_DATA_DIR}/assets"
+LIVE_ASSETS="${OPENSHIFT_REPO_DIR}/public/assets"
+
+# Ensure our stored assets directory exists
+if [ ! -d "${STORED_ASSETS}" ]; then
+ echo " Creating permanent assets directory"
+ mkdir "${STORED_ASSETS}"
+fi
+
+# Create symlink to stored assets unless we're uploading our own assets
+if [ -d "${LIVE_ASSETS}" ]; then
+ echo " WARNING: Assets included in git repository, not using stored assets"
+else
+ echo " Restoring stored assets"
+ ln -s "${STORED_ASSETS}" "${LIVE_ASSETS}"
+fi
2  Gemfile
View
@@ -19,6 +19,8 @@ group :assets do
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
+
+ gem 'turbo-sprockets-rails3'
end
gem 'jquery-rails'
4 Gemfile.lock
View
@@ -97,6 +97,9 @@ GEM
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
+ turbo-sprockets-rails3 (0.3.6)
+ railties (> 3.2.8, < 4.0.0)
+ sprockets (>= 2.0.0)
tzinfo (0.3.35)
uglifier (1.3.0)
execjs (>= 0.3.0)
@@ -114,4 +117,5 @@ DEPENDENCIES
sass-rails (~> 3.2.3)
sqlite3
thor (= 0.14.6)
+ turbo-sprockets-rails3
uglifier (>= 1.0.3)
Something went wrong with that request. Please try again.