You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OBS-385: Introduce ESBuild for CSS and Images (#6864)
* OBS-385: use ESBuild to bundle crashstats_base as first test case
* OBS-385: remove unwanted npm scripts
* OBS-385: create anonymous volumes for node_modules
fix lint
* OBS-385: add `webapp/static` anonymous volume
OBS-385: fix tests
* OBS-385: ignore collectstatic css and other things
* OBS-385: update ESBuild entrypoints
* OBS-385: use staticfiles backend storage instead of pipeline
* OBS-385: handle media assets with ESBuild
* OBS-385: build CSS and images using ESBuild
* OBS-385: update HTML files to use ESBuild CSS and images
* OBS-385: revert work-around for status.css
* OBS-385: revert staticfiles storage to fix js files not served in production
* OBS-385: update collectstatic "ignore" specificity to allow admin css
* OBS-385: use npm script in test.sh for consolidation
* OBS-397: add ESBuild "watch" mode
* OBS-385: remove STATIC_ROOT declaration from local_dev.env
* OBS-385: restore bundle quality check, removing PIPELINE_CSS
* OBS-385: update webapp documentation
Copy file name to clipboardExpand all lines: docs/service/webapp.rst
+63-92
Original file line number
Diff line number
Diff line change
@@ -8,25 +8,79 @@ Code is in ``webapp/``.
8
8
9
9
Run script is ``/app/bin/run_service_webapp.sh``.
10
10
11
+
Running in a local dev environment
12
+
==================================
13
+
14
+
This documentation assumes you've gone through the setup steps described in the Development chapter :ref:`setup-quickstart`, in particular:
15
+
16
+
.. code-block:: shell
17
+
18
+
$ just build
19
+
$ just setup
20
+
21
+
To run the webapp...
22
+
23
+
.. code-block:: shell
24
+
25
+
$ docker compose up webapp
26
+
27
+
...or if you don't like typing:
28
+
29
+
.. code-block:: shell
30
+
31
+
$ just run
11
32
12
-
Configuration
33
+
To ease debugging, you can run a shell in the container:
34
+
35
+
.. code-block:: shell
36
+
$ docker compose run --service-ports webapp shell
37
+
38
+
Then you can start and stop the webapp, adjust files, and debug.
39
+
The webapp runs ESBuild's watch mode and Django's StatReloader to reload static file changes automatically.
40
+
This avoids needing to stop, rebuild, and restart the container/server on every change.
41
+
42
+
Static Assets
13
43
=============
14
44
15
-
FIXME
45
+
At the time of this writing, JS files are collected and processed by collectstatic and django-pipeline. All other static assets (CSS, images, fonts, etc) are collected and processed by ESBuild.
46
+
Migration of JS to ESBuild is currently in progress, with the intent to retire django-pipeline when complete. The collectstatic package will continue to be used in support of the internal Django admin pages.
16
47
48
+
Static asset builds are triggered by NPM scripts in ``webapp/package.json``. The assets are built into ``/app/webapp/static`` also known as ``STATIC_ROOT``.
17
49
18
-
Running in a local dev environment
19
-
==================================
50
+
Production-style Assets
51
+
=======================
20
52
21
-
To run the webapp, do::
53
+
When you run ``docker compose up webapp`` in the local development environment,
54
+
it starts the web app using Django's ``runserver`` command. ``DEBUG=True`` is
55
+
set in the ``docker/config/local_dev.env`` file, so static assets are
56
+
automatically served from within the individual Django apps rather than serving
57
+
the minified and concatenated static assets you'd get in a production-like
58
+
environment.
22
59
23
-
$ docker compose up webapp
60
+
If you want to run the web app in a more "prod-like manner", you want to run the
61
+
webapp using ``gunicorn`` and with ``DEBUG=False``. Here's how you do that.
24
62
25
-
To ease debugging, you can run a shell in the container::
63
+
First start a ``bash`` shell with service ports::
26
64
27
65
$ docker compose run --service-ports webapp shell
28
66
29
-
Then you can start and stop the webapp, adjust files, and debug.
67
+
Compile the static assets (if needed)::
68
+
69
+
app@socorro:/app$ npm run build --prefix webapp
70
+
71
+
Then run the webapp with ``gunicorn`` and ``DEBUG=False``::
0 commit comments