You've already forked snikket-web-portal
Compare commits
1 Commits
fix/unheal
...
feature/va
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20abe4b903 |
19
Dockerfile
19
Dockerfile
@@ -6,7 +6,8 @@ RUN set -eu; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
python3 python3-pip python3-setuptools python3-wheel \
|
||||
libpython3-dev \
|
||||
make build-essential;
|
||||
make build-essential \
|
||||
netcat;
|
||||
|
||||
COPY requirements.txt /opt/snikket-web-portal/requirements.txt
|
||||
COPY build-requirements.txt /opt/snikket-web-portal/build-requirements.txt
|
||||
@@ -16,8 +17,7 @@ COPY babel.cfg /opt/snikket-web-portal/babel.cfg
|
||||
|
||||
WORKDIR /opt/snikket-web-portal
|
||||
|
||||
RUN set -eu; \
|
||||
pip3 install -r requirements.txt; \
|
||||
RUN pip3 install -r requirements.txt; \
|
||||
pip3 install -r build-requirements.txt; \
|
||||
make;
|
||||
|
||||
@@ -33,22 +33,21 @@ ENV SNIKKET_WEB_PYENV=/etc/snikket-web-portal/env.py
|
||||
|
||||
ENV SNIKKET_WEB_PROSODY_ENDPOINT=http://127.0.0.1:5280/
|
||||
|
||||
COPY requirements.txt /opt/snikket-web-portal/requirements.txt
|
||||
|
||||
WORKDIR /opt/snikket-web-portal
|
||||
HEALTHCHECK CMD nc -zv ${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_INTERFACE:-127.0.0.1} ${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT:-5765}
|
||||
|
||||
RUN set -eu; \
|
||||
export DEBIAN_FRONTEND=noninteractive ; \
|
||||
apt-get update ; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
python3 python3-pip python3-setuptools python3-wheel build-essential libpython3-dev netcat; \
|
||||
pip3 install -r requirements.txt; \
|
||||
apt-get remove -y --autoremove build-essential libpython3-dev; \
|
||||
python3 python3-pip python3-setuptools python3-wheel; \
|
||||
apt-get clean ; rm -rf /var/lib/apt/lists; \
|
||||
pip3 install hypercorn; \
|
||||
rm -rf /root/.cache;
|
||||
|
||||
HEALTHCHECK CMD nc -zv ${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_INTERFACE:-127.0.0.1} ${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT:-5765}
|
||||
WORKDIR /opt/snikket-web-portal
|
||||
|
||||
COPY requirements.txt /opt/snikket-web-portal/requirements.txt
|
||||
RUN pip3 install -r requirements.txt; rm -rf /root/.cache;
|
||||
|
||||
COPY --from=build /opt/snikket-web-portal/snikket_web/ /opt/snikket-web-portal/snikket_web
|
||||
COPY babel.cfg /opt/snikket-web-portal/babel.cfg
|
||||
|
||||
@@ -8,6 +8,7 @@ import quart.flask_patch # noqa:F401
|
||||
from quart import (
|
||||
current_app,
|
||||
request,
|
||||
g,
|
||||
)
|
||||
|
||||
import flask_babel
|
||||
@@ -34,6 +35,9 @@ BYTE_UNIT_SCALE_MAP = [
|
||||
|
||||
@babel.localeselector # type:ignore
|
||||
def selected_locale() -> str:
|
||||
# Needs mypy ignore because this is a free-for-all object and has no
|
||||
# publicly known attributes.
|
||||
g.language_header_accessed = True # type: ignore
|
||||
selected = request.accept_languages.best_match(
|
||||
current_app.config['LANGUAGES']
|
||||
) or current_app.config['LANGUAGES'][0]
|
||||
@@ -68,6 +72,12 @@ def format_bytes(n: float) -> str:
|
||||
return "{} {}".format(n, unit)
|
||||
|
||||
|
||||
def add_vary_language_header(resp: quart.Response) -> quart.Response:
|
||||
if getattr(g, "language_header_accessed", False):
|
||||
resp.vary.add("Accept-Language")
|
||||
return resp
|
||||
|
||||
|
||||
def init_templating(app: quart.Quart) -> None:
|
||||
app.template_filter("repr")(repr)
|
||||
app.template_filter("format_datetime")(flask_babel.format_datetime)
|
||||
@@ -78,6 +88,7 @@ def init_templating(app: quart.Quart) -> None:
|
||||
app.template_filter("format_bytes")(format_bytes)
|
||||
app.template_filter("flatten")(flatten)
|
||||
app.template_filter("circle_name")(circle_name)
|
||||
app.after_request(add_vary_language_header)
|
||||
|
||||
|
||||
def generate_error_id() -> str:
|
||||
|
||||
Reference in New Issue
Block a user