#!/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 # 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} prod-static/serve-new/ # 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.