mirror of https://github.com/zulip/zulip.git
51 lines
1.5 KiB
Bash
Executable File
51 lines
1.5 KiB
Bash
Executable File
#!/bin/bash -e
|
|
|
|
# Update static files in production.
|
|
|
|
cd "$(dirname "$0")"/..
|
|
|
|
if ! which sponge >/dev/null; then
|
|
echo 'Install the moreutils package.' >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Redirect output to a log file (most recent run only)
|
|
exec >update-prod-static.log
|
|
|
|
# Compile Handlebars templates
|
|
./tools/node node_modules/.bin/handlebars zephyr/static/templates/*.handlebars \
|
|
--output ./zephyr/static/templates/compiled.js \
|
|
--known if,unless,each,with
|
|
|
|
# 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.
|
|
rm -rf prod-static/source-map
|
|
mkdir -p prod-static/source-map
|
|
./manage.py collectstatic --noinput
|
|
|
|
# Copy the files we want to expose
|
|
rm -rf prod-static/serve-new
|
|
mkdir -p prod-static/serve-new
|
|
cp -r prod-static/collected/{favicon.ico,robots.txt,html,images,third,min,audio} prod-static/serve-new/
|
|
|
|
# Prepend the third-party code notice to JavaScript and CSS files.
|
|
for f in prod-static/serve-new/min/*.{js,css}; do
|
|
cat zephyr/static/header.txt $f | sponge $f
|
|
done
|
|
|
|
# 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
|
|
rm -rf prod-static/serve-new
|
|
|
|
# Leave the 'collected' directory around or PipelineCachedStorage
|
|
# will fail.
|