File tree 12 files changed +150
-14
lines changed
12 files changed +150
-14
lines changed Original file line number Diff line number Diff line change
1
+ # Stage 1: Build frontend assets
2
+ FROM node:19.8.1-alpine as frontend-build
3
+
4
+ ENV NODE_ENV production
5
+ COPY .babelrc rollup.config.mjs gulpfile.mjs package.json yarn.lock ./
6
+ COPY via/static ./via/static
7
+
8
+ RUN yarn install --frozen-lockfile
9
+ RUN yarn build
10
+
11
+ # Stage 2: Build the rest of the app using build output from Stage 1.
12
+
1
13
# Unlike most Hypothesis projects this Docker image is based on Debian,
2
14
# so it can use glibc's DNS resolver which supports TCP retries. It can be
3
15
# reverted back to Alpine when Musl v1.2.4 is released.
@@ -24,6 +36,9 @@ COPY requirements/requirements.txt ./
24
36
RUN pip install --no-cache-dir -U pip \
25
37
&& pip install --no-cache-dir -r requirements.txt
26
38
39
+ # Copy frontend assets.
40
+ COPY --from=frontend-build /build build
41
+
27
42
COPY ./conf/supervisord.conf ./conf/supervisord.conf
28
43
COPY ./conf/nginx/nginx.conf /etc/nginx/nginx.conf
29
44
COPY ./conf/nginx/includes /etc/nginx/includes
Original file line number Diff line number Diff line change 2
2
# This file is autogenerated by pip-compile with Python 3.8
3
3
# by the following command:
4
4
#
5
- # pip-compile requirements/dev.in
5
+ # pip-compile --allow-unsafe requirements/dev.in
6
6
#
7
+ appnope==0.1.3
8
+ # via ipython
7
9
asttokens==2.2.1
8
10
# via stack-data
9
11
attrs==20.3.0
@@ -72,6 +74,8 @@ google-auth-oauthlib==1.0.0
72
74
# via -r requirements/requirements.txt
73
75
gunicorn==20.1.0
74
76
# via -r requirements/requirements.txt
77
+ h-assets==1.0.5
78
+ # via -r requirements/requirements.txt
75
79
h-pyramid-sentry==1.2.4
76
80
# via -r requirements/requirements.txt
77
81
h-vialib==1.1.0
@@ -196,6 +200,7 @@ pyparsing==3.0.7
196
200
pyramid==2.0
197
201
# via
198
202
# -r requirements/requirements.txt
203
+ # h-assets
199
204
# h-pyramid-sentry
200
205
# pyramid-exclog
201
206
# pyramid-ipython
@@ -321,5 +326,17 @@ zope-interface==5.2.0
321
326
# wired
322
327
323
328
# The following packages are considered to be unsafe in a requirements file:
324
- # pip
325
- # setuptools
329
+ pip==23.1.2
330
+ # via pip-tools
331
+ setuptools==67.7.2
332
+ # via
333
+ # -r requirements/requirements.txt
334
+ # gunicorn
335
+ # jsonschema
336
+ # pastedeploy
337
+ # pip-tools
338
+ # plaster
339
+ # pyramid
340
+ # supervisor
341
+ # zope-deprecation
342
+ # zope-interface
Original file line number Diff line number Diff line change 2
2
# This file is autogenerated by pip-compile with Python 3.8
3
3
# by the following command:
4
4
#
5
- # pip-compile requirements/functests.in
5
+ # pip-compile --allow-unsafe requirements/functests.in
6
6
#
7
7
attrs==20.3.0
8
8
# via
@@ -51,6 +51,8 @@ google-auth-oauthlib==1.0.0
51
51
# via -r requirements/requirements.txt
52
52
gunicorn==20.1.0
53
53
# via -r requirements/requirements.txt
54
+ h-assets==1.0.5
55
+ # via -r requirements/requirements.txt
54
56
h-matchers==1.2.15
55
57
# via -r requirements/functests.in
56
58
h-pyramid-sentry==1.2.4
@@ -153,6 +155,7 @@ pyparsing==3.0.7
153
155
pyramid==2.0
154
156
# via
155
157
# -r requirements/requirements.txt
158
+ # h-assets
156
159
# h-pyramid-sentry
157
160
# pyramid-exclog
158
161
# pyramid-jinja2
@@ -256,5 +259,16 @@ zope-interface==5.2.0
256
259
# wired
257
260
258
261
# The following packages are considered to be unsafe in a requirements file:
259
- # pip
260
- # setuptools
262
+ pip==23.1.2
263
+ # via pip-tools
264
+ setuptools==67.7.2
265
+ # via
266
+ # -r requirements/requirements.txt
267
+ # gunicorn
268
+ # jsonschema
269
+ # pastedeploy
270
+ # pip-tools
271
+ # plaster
272
+ # pyramid
273
+ # zope-deprecation
274
+ # zope-interface
Original file line number Diff line number Diff line change 2
2
# This file is autogenerated by pip-compile with Python 3.8
3
3
# by the following command:
4
4
#
5
- # pip-compile requirements/lint.in
5
+ # pip-compile --allow-unsafe requirements/lint.in
6
6
#
7
7
astroid==2.15.2
8
8
# via pylint
@@ -85,6 +85,10 @@ gunicorn==20.1.0
85
85
# via
86
86
# -r requirements/requirements.txt
87
87
# -r requirements/tests.txt
88
+ h-assets==1.0.5
89
+ # via
90
+ # -r requirements/requirements.txt
91
+ # -r requirements/tests.txt
88
92
h-matchers==1.2.15
89
93
# via -r requirements/tests.txt
90
94
h-pyramid-sentry==1.2.4
@@ -234,6 +238,7 @@ pyramid==2.0
234
238
# via
235
239
# -r requirements/requirements.txt
236
240
# -r requirements/tests.txt
241
+ # h-assets
237
242
# h-pyramid-sentry
238
243
# pyramid-exclog
239
244
# pyramid-jinja2
@@ -389,5 +394,19 @@ zope-interface==5.2.0
389
394
# wired
390
395
391
396
# The following packages are considered to be unsafe in a requirements file:
392
- # pip
393
- # setuptools
397
+ pip==23.1.2
398
+ # via
399
+ # -r requirements/tests.txt
400
+ # pip-tools
401
+ setuptools==67.7.2
402
+ # via
403
+ # -r requirements/requirements.txt
404
+ # -r requirements/tests.txt
405
+ # gunicorn
406
+ # jsonschema
407
+ # pastedeploy
408
+ # pip-tools
409
+ # plaster
410
+ # pyramid
411
+ # zope-deprecation
412
+ # zope-interface
Original file line number Diff line number Diff line change 1
1
gunicorn
2
2
checkmatelib
3
+ h-assets
3
4
h-pyramid-sentry
4
5
h-vialib
5
6
importlib_resources
Original file line number Diff line number Diff line change 2
2
# This file is autogenerated by pip-compile with Python 3.8
3
3
# by the following command:
4
4
#
5
- # pip-compile requirements/requirements.in
5
+ # pip-compile --allow-unsafe requirements/requirements.in
6
6
#
7
7
attrs == 20.3.0
8
8
# via jsonschema
@@ -28,6 +28,8 @@ google-auth-oauthlib==1.0.0
28
28
# via -r requirements/requirements.in
29
29
gunicorn == 20.1.0
30
30
# via -r requirements/requirements.in
31
+ h-assets == 1.0.5
32
+ # via -r requirements/requirements.in
31
33
h-pyramid-sentry == 1.2.4
32
34
# via -r requirements/requirements.in
33
35
h-vialib == 1.1.0
@@ -82,6 +84,7 @@ pyparsing==3.0.7
82
84
pyramid == 2.0
83
85
# via
84
86
# -r requirements/requirements.in
87
+ # h-assets
85
88
# h-pyramid-sentry
86
89
# pyramid-exclog
87
90
# pyramid-jinja2
@@ -148,4 +151,12 @@ zope-interface==5.2.0
148
151
# wired
149
152
150
153
# The following packages are considered to be unsafe in a requirements file:
151
- # setuptools
154
+ setuptools == 67.7.2
155
+ # via
156
+ # gunicorn
157
+ # jsonschema
158
+ # pastedeploy
159
+ # plaster
160
+ # pyramid
161
+ # zope-deprecation
162
+ # zope-interface
Original file line number Diff line number Diff line change 2
2
# This file is autogenerated by pip-compile with Python 3.8
3
3
# by the following command:
4
4
#
5
- # pip-compile requirements/tests.in
5
+ # pip-compile --allow-unsafe requirements/tests.in
6
6
#
7
7
attrs==20.3.0
8
8
# via
@@ -57,6 +57,8 @@ google-auth-oauthlib==1.0.0
57
57
# via -r requirements/requirements.txt
58
58
gunicorn==20.1.0
59
59
# via -r requirements/requirements.txt
60
+ h-assets==1.0.5
61
+ # via -r requirements/requirements.txt
60
62
h-matchers==1.2.15
61
63
# via -r requirements/tests.in
62
64
h-pyramid-sentry==1.2.4
@@ -159,6 +161,7 @@ pyparsing==3.0.7
159
161
pyramid==2.0
160
162
# via
161
163
# -r requirements/requirements.txt
164
+ # h-assets
162
165
# h-pyramid-sentry
163
166
# pyramid-exclog
164
167
# pyramid-jinja2
@@ -267,5 +270,16 @@ zope-interface==5.2.0
267
270
# wired
268
271
269
272
# The following packages are considered to be unsafe in a requirements file:
270
- # pip
271
- # setuptools
273
+ pip==23.1.2
274
+ # via pip-tools
275
+ setuptools==67.7.2
276
+ # via
277
+ # -r requirements/requirements.txt
278
+ # gunicorn
279
+ # jsonschema
280
+ # pastedeploy
281
+ # pip-tools
282
+ # plaster
283
+ # pyramid
284
+ # zope-deprecation
285
+ # zope-interface
Original file line number Diff line number Diff line change
1
+ from via .assets import includeme
2
+
3
+
4
+ def test_includeme (pyramid_config ):
5
+ includeme (pyramid_config )
6
+
7
+ assets_env = pyramid_config .registry ["assets_env" ]
8
+ assert assets_env .assets_base_url == "/assets"
Original file line number Diff line number Diff line change 30
30
}
31
31
32
32
33
+ def configure_jinja2_assets (config ):
34
+ jinja2_env = config .get_jinja2_environment ()
35
+ jinja2_env .globals ["asset_url" ] = config .registry ["assets_env" ].url
36
+ jinja2_env .globals ["asset_urls" ] = config .registry ["assets_env" ].urls
37
+
38
+
33
39
def load_settings (settings ):
34
40
"""Load application settings from a dict or environment variables.
35
41
@@ -65,6 +71,7 @@ def create_app(_=None, **settings):
65
71
config .include ("pyramid_services" )
66
72
config .include ("h_pyramid_sentry" )
67
73
74
+ config .include ("via.assets" )
68
75
config .include ("via.views" )
69
76
config .include ("via.services" )
70
77
@@ -84,6 +91,8 @@ def create_app(_=None, **settings):
84
91
# Add this as near to the end of your config as possible:
85
92
config .include ("pyramid_sanity" )
86
93
94
+ config .action (None , configure_jinja2_assets , args = (config ,))
95
+
87
96
app = WhiteNoise (
88
97
config .make_wsgi_app (),
89
98
index_file = True ,
Original file line number Diff line number Diff line change
1
+ [bundles]
2
+
3
+ video_player_js =
4
+ scripts/video_player.bundle.js
Original file line number Diff line number Diff line change
1
+ """View for serving static assets under `/assets`."""
2
+
3
+ import importlib_resources
4
+ from h_assets import Environment , assets_view
5
+
6
+
7
+ def includeme (config ):
8
+ # Auto reload asset manifest when it changes in development.
9
+ auto_reload = config .registry .settings ["dev" ]
10
+ via_files = importlib_resources .files ("via" )
11
+
12
+ assets_env = Environment (
13
+ assets_base_url = "/assets" ,
14
+ bundle_config_path = via_files / "assets.ini" ,
15
+ manifest_path = via_files / "../build/manifest.json" ,
16
+ auto_reload = auto_reload ,
17
+ )
18
+
19
+ # Store asset environment in registry for use in registering `asset_urls`
20
+ # Jinja2 helper in `app.py`.
21
+ config .registry ["assets_env" ] = assets_env
22
+
23
+ config .add_view (route_name = "assets" , view = assets_view (assets_env ))
Original file line number Diff line number Diff line change 5
5
def add_routes (config ): # pragma: no cover
6
6
"""Add routes to pyramid config."""
7
7
8
+ config .add_route ("assets" , "/assets/*subpath" )
8
9
config .add_route ("index" , "/" , factory = QueryURLResource )
9
10
config .add_route ("get_status" , "/_status" )
10
11
config .add_route ("view_pdf" , "/pdf" , factory = QueryURLResource )
You can’t perform that action at this time.
0 commit comments