Граф коммитов

17 Коммитов

Автор SHA1 Сообщение Дата
Ed Morley 42f240dbf8 Bug 1349405 - Delete .heroku/yarn/ during post_compile
Since it avoids including 4500 unused files (28MB) in the slug, now that
we're using the yarn support added to newer versions of the nodejs
buildpack.
2017-03-28 13:55:50 +01:00
Ed Morley 51c386ee21 Bug 1343928 - Switch from npm to yarn
Since it's faster, deterministic and doesn't given obscure errors when
using `--no-bin-links` (which is required for both npm and yarn on
Windows hosts), and as such unblocks the work in bug 1343624.

Many of the commands are the same as with npm. See:
https://yarnpkg.com/en/docs/usage
2017-03-13 15:27:46 +00:00
Ed Morley 21abe6ed75 Bug 1343624 - Add `npm run build` as an alias of `grunt build`
Routing commands via npm/yarn is preferred, since it avoids
having to do global installs of grunt-cli, which simplifies contributor
setup, and means less effort when we switch to Yarn (since it requires
manual PATH setup for globally installed packages).
2017-03-13 15:27:46 +00:00
Ed Morley 0a0a0b78f0 Bug 1299443 - Fix revision.txt on Heroku when SERVE_MINIFIED_UI is unset
Previously `<site-root>/revision.txt` would 404 if `SERVE_MINIFIED_UI`
was unset on Heroku, which would then cause the next deploy to fail.

It's now made available in both the `ui/` and `dist/` directories, so
it can be found regardless of the value of `SERVE_MINIFIED_UI`.
2016-09-06 19:25:08 +01:00
Ed Morley 5b48f4b49b Bug 1258700 - Update to WhiteNoise 3.0
There are some backwards incompatible changes:
http://whitenoise.evans.io/en/latest/changelog.html
https://github.com/evansd/whitenoise/compare/v2.0.6...v3.0

Specifically:
* The CLI compression utility must now be called via
`python -m whitenoise.compress` rather than `python -m whitenoise.gzip`.
* The `whitenoise.django.GzipManifestStaticFilesStorage` storage backend
has moved to `whitenoise.storage.CompressedManifestStaticFilesStorage`.
* The internal `add_files()` method has been split into two and the part
which we need to subclass is now named `update_files_dictionary()`. See:
07f9c0bece
2016-03-30 13:00:23 +02:00
Ed Morley aff281fa78 Bug 1246208 - Heroku: Remove manual collectstatic workaround
The Python buildpack has now rewritten the automatic collectstatic
feature, such that it no longer does an unnecessary (and time-consuming)
dry-run every time. As such, we can switch back to the buildpack's
automatic collectstatic:
https://github.com/heroku/heroku-buildpack-python/blob/master/bin/steps/collectstatic

Prior to this landing, I'll update us to the latest version of the
buildpack (using the `heroku buildpacks:set -i X ...` command) and
remove the `DISABLE_COLLECTSTATIC` environment variable.

[ci skip]
2016-02-08 10:21:12 +00:00
Ed Morley 6080a6cf95 Bug 1242471 - Heroku: Remove now obsolete node PATH workaround
Since the original issue has since been fixed.
2016-01-26 12:45:44 +00:00
Ed Morley 32222f4fe2 Bug 1242471 - Heroku: Remove nodejs files at the end of the compile step
Since once the `grunt build` has run they are no longer required, and
only serve to bloat the slug size, increase attack surface & overwrite
the Python .profile.d script's environment variables.
2016-01-26 12:45:44 +00:00
Ed Morley 49f4929236 Bug 1210367 - Heroku: Run collectstatic manually to speed up deploy
The Python buildpack's automatic collectstatic is slower, since it does
a `--dry-run` first. To avoid the time penalty of this, we disable it by
setting `DISABLE_COLLECTSTATIC` in the Heroku environment, and run
collectstatic manually in `bin/post_compile`. See:
https://github.com/heroku/heroku-buildpack-python/issues/252
2015-10-10 22:44:49 +01:00
Ed Morley 0c79292d68 Bug 1201523 - Run grunt build during the Heroku deploy
This commit relies on the nodejs buildpack being added to the list of
buildpacks for the app, and prior to the Python buildpack. See:
https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app

The nodejs buildpack will automatically install the packages listed in
`dependencies` in package.json, so that we have the requirements for
the grunt build. We don't actually need node or all of the files in
node_modules after we've run the grunt build, so in the future could try
and remove them to reduce the resultant slug size (though it only
increased from 55MB to 70MB, so it's not urgent).

The dist directory has been added to `.slugignore` to prevent the
in-repo directory from being uploaded, since we'll be generating a new
one as part of the deploy. Once `dist/` is deleted from master, that
entry can be removed.
2015-09-30 18:34:56 +01:00
Ed Morley 525866a553 Bug 1201517 - Export a revision.txt containing the Git SHA on Heroku too
The Git SHA is available in the SOURCE_VERSION environment variable:
https://devcenter.heroku.com/articles/buildpack-api#bin-compile-summary

Also update the What's Deployed links to include Heroku in the
comparison alongside stage/prod.
2015-09-08 17:22:24 +01:00
Ed Morley f6a673a493 Bug 1160561 - Define IS_HEROKU in the dyno profile rather than Heroku env
`IS_HEROKU` isn't something that will differ between stage/prod, and is
not going to change any time soon. So let's just get post_compile to
add it to the dyno profile script, so it's one less variable to have to
remember to set via the Heroku CLI/dashboard.

Quoting from:
http://blog.doismellburning.co.uk/2014/10/06/twelve-factor-config-misunderstandings-and-advice/

"12factor says your applications should read their config from the
environment; it has very little to say about how you populate the
environment ? use whatever works for you".
2015-08-28 10:25:12 +01:00
Ed Morley fce5c7e3c0 Bug 1176412 - Override the hostname reported by New Relic on Heroku
On Heroku, the hostname is just a bunch of hex characters, which the New
Relic dashboard displays as "Dynamic Hostname". The New Relic Python
agent (as of v2.52.0.40) supports overriding this, by setting the
environment variable `NEW_RELIC_PROCESS_HOST_DISPLAY_NAME`:
https://docs.newrelic.com/docs/agents/python-agent/installation-configuration/python-agent-configuration#process_host-display_name

We use the value of `DYNO`, since this is set for us in each dyno's
environment, and is of form "web.2", "worker_pushlog.1" etc. Rather than
prefixing every line in the Procfile, we instead append the export to
the profile script created by the Python buildpack, so it's populated at
runtime on every dyno. See:
https://devcenter.heroku.com/articles/profiled

To do this we make use of the Python buildpack's `set-env` function:
ce3bdb37ba/bin/utils (L29-L32)

Similar to what the buildpack does for its own env defines:
ce3bdb37ba/bin/compile (L190-L198)
2015-08-28 10:25:11 +01:00
Ed Morley 5892c72eb2 Bug 1197796 - Make WhiteNoise serve the static assets gzipped
On Heroku, there is no load balancer or Varnish-like cache in front of
gunicorn, so we must handle gzipping responses in the app.

In order for WhiteNoise to serve gzipped static content, assets must be
gzipped on disk in advance (doing so on-demand in Python would not be
as performant). WhiteNoise will then serve the `.gz` version of files in
preference to the original, if the client indicated it supported gzip.

For assets covered by Django's collectstatic, gzipping the assets only
requires using WhiteNoise's GzipManifestStaticFilesStorage backend,
which wraps Django's ManifestStaticFilesStorage to create hashed+gzipped
versions of static assets:
http://whitenoise.evans.io/en/latest/django.html#add-gzip-and-caching-support

The collectstatic generated files will then contain the file hash in
their filename, so WhiteNoise can also serve them with a large max-age
to avoid further requests if the file contents have not changed.

For the UI files under `dist/`, we cannot rely on the Django storage
backend, since the directory isn't covered by STATICFILES_DIRS (it is
instead made known to WhiteNoise via `WHITENOISE_ROOT`). As such, files
under `dist/` are gzipped via an additional step during deployment. See:
http://whitenoise.evans.io/en/latest/base.html#gzip-support

Files whose extension is on the blacklist, or that are not >5% smaller
when compressed, are skipped during compression.
2015-08-26 22:10:05 +01:00
Ed Morley 58813b0c51 Bug 1169916 - Stop using Cython to build the log parser
Since it only speeds up parsing by a few percent of total runtime, and
is therefore not worth the added complexity for deployment and local
hack-test-debug cycles when working on the log parser.

The .gitignore and update.py entries will be removed in a later commit,
once the stage/prod src directories have been cleaned up.
2015-06-30 14:51:57 +01:00
Jonathan French 19b71bc4b4 Bug 1164881 - Add MPL2.0 headers to recent treeherder repo files 2015-05-14 11:45:26 -04:00
Mauro Doglio 597282fe58 Bug 1145606 - Setup treeherder to deploy on heroku
I added a Procfile listing all the different python services treeherder needs.
Heroku provides deployment-specific settings via environment variables, so I had to modify the settings file to listen to them where that wasn't the case. I created an enviroment variable IS_HEROKU which allows to have a heroku-only configuration where needed.
The db service is provided by Amazon RDS, which requires a ssl connection. To enable ssl in the MySQLdb python client I had to modify Datasource (and bump up the version used).
The cache service is provided by the memcachier heroku addon. Heroku recommends to use pylibmc, so I set it up according to the docs here https://devcenter.heroku.com/articles/memcachier#python.
The amqp service is provided by the CloudAMQP addon.
I added a post_compile script that runs every time we deploy. We should run every build step we require in there, like static asset minification, collection, etc.
To share the oauth credentials among the various services I used an environment variable. I also added an option to export_project_credentials so that the credentials can be printed to stdout. This should come handy when we will need to update the environment-stored credentials with the ones in the db.
2015-05-14 13:54:41 +01:00