From 78b45b61fb416b43c227d5ec9c4de31504b60a85 Mon Sep 17 00:00:00 2001 From: Kevin Mehall Date: Fri, 1 Nov 2013 15:54:41 -0400 Subject: [PATCH] Minify JS in the localserver upgrade tarball. This moves the list of removed files from .gitattributes to tools/build-local-server-tarball because static/ and tools/ are necessary for update-prod-static, and it seemed best to keep the entire list in one place. (imported from commit 2a447cbde29e90d776da43bb333650a40d4d363c) --- .gitattributes | 7 ------ puppet/zulip/manifests/local_server.pp | 4 +++ scripts/upgrade-zulip | 6 ----- tools/build-local-server-tarball | 34 +++++++++++++++++++++++++- zproject/settings.py | 5 +++- 5 files changed, 41 insertions(+), 15 deletions(-) delete mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index b2ab193c38..0000000000 --- a/.gitattributes +++ /dev/null @@ -1,7 +0,0 @@ -/tools export-ignore -/bots export-ignore -/zilencer export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore -/templates/.gitignore export-ignore -/puppet/zulip-internal export-ignore diff --git a/puppet/zulip/manifests/local_server.pp b/puppet/zulip/manifests/local_server.pp index 5021514a85..4ecabb5921 100644 --- a/puppet/zulip/manifests/local_server.pp +++ b/puppet/zulip/manifests/local_server.pp @@ -33,6 +33,10 @@ class zulip::local_server { ensure => 'link', target => '/home/zulip/zulip', } + file { '/home/zulip/prod-static': + ensure => 'link', + target => '/home/zulip/deployments/current/prod-static/serve', + } # This is just an empty file. It's used by the app to test if it's running # on a local server. diff --git a/scripts/upgrade-zulip b/scripts/upgrade-zulip index d69194397b..0a77112b89 100755 --- a/scripts/upgrade-zulip +++ b/scripts/upgrade-zulip @@ -52,12 +52,6 @@ subprocess.check_call(["mv", os.path.join(extract_path, "zulip-server"), deploy_ subprocess.check_call(["rmdir", extract_path]) os.chdir(deploy_path) -# Update static files -# TODO: Remove this and replace it with shipping already minified js. -logging.info("Updating static files") -subprocess.check_call(["./tools/update-prod-static", "--prev-deploy", - os.path.join(DEPLOYMENTS_DIR, 'current')]) - logging.info("Restarting server...") subprocess.check_call(["./scripts/restart-server"]) diff --git a/tools/build-local-server-tarball b/tools/build-local-server-tarball index 2782125300..4273cf647f 100755 --- a/tools/build-local-server-tarball +++ b/tools/build-local-server-tarball @@ -1,3 +1,35 @@ #!/bin/sh -ex -git archive -o /tmp/zulip-server.tar.gz --prefix=zulip-server/ HEAD +GITID=$(git rev-parse HEAD) + +TMPDIR=$(mktemp -d) +DIR=$TMPDIR/zulip-server/ +TARBALL=$TMPDIR/zulip-server.tar.gz + +git checkout-index -f -a --prefix $DIR + +cd $DIR + +# update-prod-static generates the prod-static directory. +# See COLLECTSTATIC in settings.py +./tools/update-prod-static + +xargs rm -r < version_id +mv update-prod-static.log .. + +cd .. +tar -czf $TARBALL zulip-server + +rm -r zulip-server +echo "Generated $TARBALL" diff --git a/zproject/settings.py b/zproject/settings.py index cba2cf6c82..fc000a35c3 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -287,7 +287,10 @@ STATIC_URL = '/static/' # here so that urls.py can read it. PIPELINE = not DEBUG -if DEBUG: +# Use prod settings if exporting static files in build-local-server-tarball +COLLECTSTATIC = 'manage.py' in sys.argv[0] and sys.argv[1] == 'collectstatic' + +if DEBUG and not COLLECTSTATIC: STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage' STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.AppDirectoriesFinder',