-
Notifications
You must be signed in to change notification settings - Fork 537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Production Mode via DEBUG or docker-compose.ci.yml #22613
Conversation
83bfb50
to
0d1e884
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned on slack, we need a way for assets to load using DEBUG=False
. SERVE_STATIC
variable is a good start but not enough: At the moment, with this patch, if I've got DEBUG=False
set, then the URLs we are going to be referencing are going to be the ones with the hash that are in site-static/
, but serve()
only knows how to serve the source stuff from static/
, not the built ones.
With DEBUG=False
and SERVE_STATIC=True
http://olympia.test/static/img/favicon.3cec07462a3d.ico fails for me for instance (and all js/css/images as well obviously).
We need some way of handling that scenario (where the developer wants a configuration closer to production - with "real" compiled assets, while still being able to develop locally, either to build some feature/fix some bug that requires real assets, or to reproduce an issue with production).
0d1e884
to
c69328f
Compare
e08aef7
to
b121b2a
Compare
060bbee
to
9303ba5
Compare
@diox it is ready for review and QA. Note, you either need a stage account for fxa or you need to force use_fake_fxa to return true for the 2nd and 4th case where we use |
2931e21
to
36019a2
Compare
3995433
to
c6b2997
Compare
c6b2997
to
e84fc20
Compare
@@ -87,8 +92,7 @@ services: | |||
image: nginx | |||
volumes: | |||
- ./docker/nginx/addons.conf:/etc/nginx/conf.d/addons.conf | |||
- ./static:/srv/static | |||
- ./site-static:/srv/site-static | |||
- ./static:/srv/site-static |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is confusing me - Why not keep /srv/static
(and keeping the old alias
directive intact in addons.conf
) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we mount either "./static" or "/data/olympia/site-static" depending on which set of compose files you use.
As far as nginx is concerned it serves from one location but the source of the files changes.
cd94f0e
to
aec2cbf
Compare
aec2cbf
to
a12799c
Compare
Co-authored-by: Mathieu Pillard <[email protected]>
Relates to: mozilla/addons#14972
Description
This PR achieves 2 goals.
The specific changes include:
Context
Why not just mount ./static and be done with it? A few problems
Why not just use runserver or serve for all assest
We use uwsgi to run django even in development because this more closely mirrors how our app runs in prod. We also cannot always rely on static_serve because in DEBUG=False (production mode) this will either not work, or even if we force it, it will be missing files.
The simpler solution is to
In production mode, 1 will have all the files and so it's fine that 2 will always fail.
In development mode, 1 will have most of the files from ./static which is fast and any files that are missing will be served from serve_static.
Testing
You should run several different iterations of addons-server and verify each is able to serve the expected static assets. This can be verified by running:
Each scenario is toggling whether we target development or production dependencies, and whether to run in DEBUG mode or not. These are independent features and can be toggled accordingly.
Additionally you can set DEBUG directly in make commands by adding it as an argument, but the value is by default set to true and when
docker-compose.ci.yml
is included in the project the value is hard coded to "DEBUG=" regardless of the value set in the host environment or arguments.Checklist
#ISSUENUM
at the top of your PR to an existing open issue in the mozilla/addons repository.