From 7a4b56914c25201e829707b81d3703d42d8b86bc Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 2 Aug 2023 22:31:13 +0200 Subject: [PATCH 1/4] Switch to sassc for CSS building Because https://github.com/Kronuz/pyScss/pull/426 is not yet in a release, also just look at the diffstat! --- Dockerfile | 1 + Makefile | 4 +-- build-requirements.txt | 1 - snikket_web/scss/app.scss | 73 +++------------------------------------ 4 files changed, 8 insertions(+), 71 deletions(-) diff --git a/Dockerfile b/Dockerfile index b8b0aab..6803d5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ RUN set -eu; \ apt-get install -y --no-install-recommends \ python3 python3-pip python3-setuptools python3-wheel \ libpython3-dev \ + sassc \ make build-essential; COPY requirements.txt /opt/snikket-web-portal/requirements.txt diff --git a/Makefile b/Makefile index a28b868..cc308a6 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ translation_basepath = snikket_web/translations pot_file = $(translation_basepath)/messages.pot PYTHON3 ?= python3 -SCSSC ?= $(PYTHON3) -m scss --load-path snikket_web/scss/ +SCSSC ?= sassc --load-path snikket_web/scss/ all: build_css compile_translations @@ -14,7 +14,7 @@ build_css: $(generated_css_files) $(generated_css_files): snikket_web/static/css/%.css: snikket_web/scss/%.scss $(scss_files) $(scss_includes) mkdir -p snikket_web/static/css/ - $(SCSSC) -o "$@" "$<" + $(SCSSC) "$<" "$@" clean: rm -f $(generated_css_files) diff --git a/build-requirements.txt b/build-requirements.txt index fb94ff6..57e4d41 100644 --- a/build-requirements.txt +++ b/build-requirements.txt @@ -1,4 +1,3 @@ -pyscss~=1.3 mypy python-dotenv~=0.15 types-toml diff --git a/snikket_web/scss/app.scss b/snikket_web/scss/app.scss index a22386e..a00b521 100644 --- a/snikket_web/scss/app.scss +++ b/snikket_web/scss/app.scss @@ -275,22 +275,22 @@ div.form.layout-expanded { } @each $type in $text-entry-inputs { - input[type=$type] { + input[type=#{$type}] { width: 100%; border: none; border-bottom: $w-s4 solid $primary-500; margin-bottom: -$w-s4; } - input[type=$type].has-error { + input[type=#{$type}].has-error { border-right: $w-s4 solid $alert-500; } - input[type=$type]:hover { + input[type=#{$type}]:hover { border-bottom-color: $primary-700; } - input[type=$type]:focus { + input[type=#{$type}]:focus { border-bottom-color: $primary-800; } } @@ -646,69 +646,6 @@ input[type="submit"], button, .button { -/* button, .button { - margin: 0 $w-s2; -} - -button.lv-primary, .button.lv-primary { - background-color: $gray-500; - color: $gray-900; - border-radius: $w-s4; - border: $w-s4 solid $gray-400; - - @each $type, $values in $colours { - &.c-#{$type} { - border-color: nth($values, 4); - background-color: nth($values, 5); - color: nth($values, 9); - } - - &.c-#{$type}:hover { - background-color: nth($values, 4); - } - } -} - -button.lv-secondary, .button.lv-secondary { - background-color: $gray-700; - color: $gray-100; - border-radius: $w-s4; - - @each $type, $values in $colours { - &.c-#{$type} { - background-color: nth($values, 7); - color: nth($values, 1); - } - } -} - -button.lv-tertiary, .button.lv-tertiary { - background-color: inherit; - color: $gray-300; - border-radius: $w-s4; - text-decoration: underline; - - @each $type, $values in $colours { - &.c-#{$type} { - color: nth($values, 3); - } - } -} -*/ - -/* - button.lv-secondary.c-#{$type}, .button.lv-secondary.c-#{$type} { - background-color: nth($values, 7); - color: nth($values, 1); - } - - button.lv-tertiary.c-#{$type}, .button.lv-tertiary.c-#{$type} { - color: nth($values, 3); - text-decoration: underline; - background-color: transparent; - } -}*/ - /* boxes */ .box { @@ -1121,7 +1058,7 @@ pre.guru-meditation { } @each $type in $text-entry-inputs { - input[type=$type] { + input[type=#{$type}] { background-color: black; } From d3a6be7bec2489b598374abda5d82cf3663082d8 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 17 Jun 2023 20:17:43 +0200 Subject: [PATCH 2/4] Switch base image to Debian 12 --- Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6803d5e..2d6e5b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bullseye-slim AS build +FROM debian:bookworm-slim AS build RUN set -eu; \ export DEBIAN_FRONTEND=noninteractive ; \ @@ -18,12 +18,12 @@ COPY babel.cfg /opt/snikket-web-portal/babel.cfg WORKDIR /opt/snikket-web-portal RUN set -eu; \ - pip3 install -r requirements.txt; \ - pip3 install -r build-requirements.txt; \ + pip3 install --break-system-packages -r requirements.txt; \ + pip3 install --break-system-packages -r build-requirements.txt; \ make; -FROM debian:bullseye-slim +FROM debian:bookworm-slim ARG BUILD_SERIES=dev ARG BUILD_ID=0 @@ -42,11 +42,11 @@ 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; \ + python3 python3-pip python3-setuptools python3-wheel build-essential libpython3-dev netcat-traditional; \ + pip3 install --break-system-packages -r requirements.txt; \ apt-get remove -y --autoremove build-essential libpython3-dev; \ apt-get clean ; rm -rf /var/lib/apt/lists; \ - pip3 install hypercorn; \ + pip3 install --break-system-packages 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} From 9672cd6870f5fa19dec7f14fb9e0d9c289fe6911 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 27 Sep 2023 21:28:27 +0200 Subject: [PATCH 3/4] Install as many packages as possible from Debian The only missing piece appears to be environ-config. This **fails to start** with ``` ImportError: cannot import name '_app_ctx_stack' from 'quart' (/usr/lib/python3/dist-packages/quart/__init__.py) ``` --- Dockerfile | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2d6e5b7..4b2bc13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,23 +4,16 @@ RUN set -eu; \ export DEBIAN_FRONTEND=noninteractive ; \ apt-get update ; \ apt-get install -y --no-install-recommends \ - python3 python3-pip python3-setuptools python3-wheel \ - libpython3-dev \ - sassc \ - make build-essential; + python3 python3-mypy python3-dotenv python3-toml python3-babel python3-distutils \ + sassc make; -COPY requirements.txt /opt/snikket-web-portal/requirements.txt -COPY build-requirements.txt /opt/snikket-web-portal/build-requirements.txt COPY Makefile /opt/snikket-web-portal/Makefile COPY snikket_web/ /opt/snikket-web-portal/snikket_web COPY babel.cfg /opt/snikket-web-portal/babel.cfg WORKDIR /opt/snikket-web-portal -RUN set -eu; \ - pip3 install --break-system-packages -r requirements.txt; \ - pip3 install --break-system-packages -r build-requirements.txt; \ - make; +RUN make FROM debian:bookworm-slim @@ -34,19 +27,19 @@ 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 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-traditional; \ - pip3 install --break-system-packages -r requirements.txt; \ - apt-get remove -y --autoremove build-essential libpython3-dev; \ + netcat-traditional python3 python3-setuptools python3-pip \ + python3-aiohttp python3-email-validator python3-flask-babel \ + python3-flaskext.wtf python3-hsluv python3-hypercorn \ + python3-quart python3-typing-extensions python3-wtforms ; \ + pip3 install --break-system-packages environ-config ; \ + apt-get remove -y --purge python3-pip python3-setuptools; \ apt-get clean ; rm -rf /var/lib/apt/lists; \ - pip3 install --break-system-packages 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} From ad9af20f123e3b53e8f4f88b9a2c60fd57e047a5 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 4 Oct 2023 23:26:17 +0200 Subject: [PATCH 4/4] Workaround for Flask context change --- snikket_web/prosodyclient.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/snikket_web/prosodyclient.py b/snikket_web/prosodyclient.py index 07d9da1..90edc39 100644 --- a/snikket_web/prosodyclient.py +++ b/snikket_web/prosodyclient.py @@ -16,11 +16,13 @@ import aiohttp import xml.etree.ElementTree as ET from quart import ( - current_app, _app_ctx_stack, session as http_session, abort, redirect, + current_app, session as http_session, abort, redirect, url_for, ) import quart +from flask import g as _app_ctx_stack + import werkzeug.exceptions from . import xmpputil @@ -166,7 +168,7 @@ class HTTPSessionManager: }) async def teardown(self, exc: typing.Optional[BaseException]) -> None: - app_ctx = _app_ctx_stack.top + app_ctx = _app_ctx_stack try: session = getattr(app_ctx, self._app_context_attribute) except AttributeError: @@ -183,7 +185,7 @@ class HTTPSessionManager: await session.__aexit__(exc_type, exc, traceback) async def __aenter__(self) -> aiohttp.ClientSession: - app_ctx = _app_ctx_stack.top + app_ctx = _app_ctx_stack try: return getattr(app_ctx, self._app_context_attribute) except AttributeError: