mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
update-deployment has been replaced by upgrade-zulip for local server instances, since it won't be running off a git repository, and update-prod-static won't be needed since we plan on shipping minified javascript. When we deploy this, the deployment will fail, and then we'll need to update the git checkout from which post-receive runs on git.zulip.net. (imported from commit 86aaedbab09c60ae86ac1d0ae492d0d1bc45569f)
48 lines
1.7 KiB
Python
Executable File
48 lines
1.7 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
# Updates static files for production.
|
|
|
|
from __future__ import absolute_import
|
|
|
|
import os
|
|
import subprocess
|
|
import optparse
|
|
import sys
|
|
|
|
# We need settings so we can figure out where the prod-static directory is.
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings'
|
|
from django.conf import settings
|
|
|
|
parser = optparse.OptionParser()
|
|
parser.add_option('--prev-deploy', nargs=1, metavar='DIR',
|
|
help='A previous deploy from which to reuse files if possible')
|
|
(options, args) = parser.parse_args()
|
|
prev_deploy = options.prev_deploy
|
|
|
|
os.chdir(settings.DEPLOY_ROOT)
|
|
|
|
# Redirect child processes' output to a log file (most recent run only).
|
|
fp = open('update-prod-static.log', 'w')
|
|
|
|
# Compile Handlebars templates and minify JavaScripts.
|
|
subprocess.check_call(['python', 'tools/minify-js']
|
|
+ (['--prev-deploy', prev_deploy] if prev_deploy else []),
|
|
stdout=fp, stderr=fp)
|
|
|
|
# Collect the files that we're going to serve.
|
|
subprocess.check_call(['python', './manage.py', 'collectstatic', '--noinput'],
|
|
stdout=fp, stderr=fp)
|
|
|
|
# Move the source maps out of the serve/ directory and into their
|
|
# proper place.
|
|
subprocess.check_call(['rm', '-rf', 'prod-static/source-map'],
|
|
stdout=fp, stderr=fp)
|
|
subprocess.check_call(['mkdir', '-p', 'prod-static'], # Needed if DEPLOYED
|
|
stdout=fp, stderr=fp)
|
|
subprocess.check_call(['mv', os.path.join(settings.STATIC_ROOT, 'source-map'),
|
|
'prod-static/source-map'],
|
|
stdout=fp, stderr=fp)
|
|
|
|
fp.close()
|