2013-01-30 23:11:34 +01:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
|
|
|
# Update static files in production.
|
|
|
|
|
|
|
|
cd "$(dirname "$0")"/..
|
|
|
|
|
|
|
|
# Redirect output to a log file (most recent run only)
|
|
|
|
exec >update-prod-static.log
|
|
|
|
|
2013-02-16 11:17:23 +01:00
|
|
|
# Compile Handlebars templates
|
|
|
|
./tools/node node_modules/.bin/handlebars zephyr/static/templates/*.handlebars \
|
|
|
|
--output ./zephyr/static/templates/compiled.js \
|
|
|
|
--known if,unless,each,with
|
|
|
|
|
2013-02-25 23:53:16 +01:00
|
|
|
# Collect both original and minified files.
|
|
|
|
#
|
|
|
|
# We don't delete the old files, because doing so makes the
|
|
|
|
# running app with PipelineCachedStorage unhappy. So if you
|
|
|
|
# remove a static file, you need to manually remove it from
|
|
|
|
# prod-static/collected on the app servers.
|
2013-03-27 18:40:17 +01:00
|
|
|
rm -rf prod-static/source-map
|
|
|
|
mkdir -p prod-static/source-map
|
2013-01-30 23:11:34 +01:00
|
|
|
./manage.py collectstatic --noinput
|
|
|
|
|
|
|
|
# Copy the files we want to expose
|
|
|
|
rm -rf prod-static/serve-new
|
2013-02-25 02:59:59 +01:00
|
|
|
mkdir -p prod-static/serve-new
|
2013-05-04 00:22:28 +02:00
|
|
|
cp -r prod-static/collected/{favicon.ico,robots.txt,html,images,third,min,audio} prod-static/serve-new/
|
2013-01-30 23:11:34 +01:00
|
|
|
|
|
|
|
# Sync the new directory to the one nginx actually serves.
|
|
|
|
# Hopefully this doesn't race too badly for clients loading
|
|
|
|
# right as a deploy happens.
|
|
|
|
mkdir -p prod-static/serve
|
|
|
|
rsync -ar --delete prod-static/serve-new/* prod-static/serve/
|
|
|
|
|
|
|
|
# Clean up
|
2013-02-24 19:28:43 +01:00
|
|
|
rm -rf prod-static/serve-new
|
|
|
|
|
|
|
|
# Leave the 'collected' directory around or PipelineCachedStorage
|
|
|
|
# will fail.
|