diff --git a/Development.md b/Development.md index 168ed9d2b2212d0680052852b01674a6e0cb38e2..c4889a17debe1aceb1a2c5758aceb662804b48f1 100644 --- a/Development.md +++ b/Development.md @@ -106,6 +106,10 @@ DATABASES = { 3. Führe `yarn build` aus um das CSS zu kompilieren 4. Um das CSS beim Entwickeln automatisch neu zu kompilieren gibt es `yarn watch` +#### CSS Watch im Container + +1. Um die Styles zu kompilieren und eine watch zu starten benutze `docker compose --profile build up -d local-static` + ### Components Wiederverwendbare Elemente können als Komponenten integriert werden. Dafür gibt es jeweils 2 "components"-Ordner. Die HTML-Komponenten befinden sich in `plainui/jinja2/plainui/components`. Sollten zusätzliche Styles benötigt werden, können diese in `plainui/styles/components` hinzugefügt werden, welche anschließend in `rc3.scss` integriert werden. Wichtig ist, ein **eigenes File pro Komponente** anzulegen. Für Jinja eignen sich dazu [Macros](https://jinja.palletsprojects.com/en/2.10.x/templates/#import) oder [Includes](https://jinja.palletsprojects.com/en/2.10.x/templates/#include). Zusätzlich ist die Komponente in der Übersicht hinzuzufügen - lokal erreichbar unter <http://localhost:8000/component_gallery>. diff --git a/Dockerfile b/Dockerfile index 40a1cb314bbdc892f596ad9a329d28f8284a4025..b09fed9f166ac3fa252333439a32c0140b2210a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,6 @@ ARG REGISTRY="" FROM ${REGISTRY}python:3.13-bookworm AS base -ARG DEVELOPMENT=False - ENV DEBIAN_FRONTEND=noninteractive ENV PDM_CHECK_UPDATE=false @@ -86,7 +84,6 @@ COPY deployment/docker/nginx.conf /etc/nginx/templates/default.conf.template ######################################### [webworker-base] #################### FROM base AS webworker-base -ARG DEVELOPMENT ENV APP_HOME=${APP_HOME:-/app_home} @@ -98,14 +95,7 @@ ENV LC_ALL=C.UTF-8 ENV DJANGO_SETTINGS_MODULE=hub.settings.default ENV DOCKER_UID=1000 -RUN --mount=target=/var/lib/apt/lists/,type=cache,sharing=locked \ - --mount=target=/var/cache/apt/archives/,type=cache,sharing=locked \ - if [ "$DEVELOPMENT" = "True" ]; then\ - apt-get install \ - yarnpkg &&\ - /usr/bin/yarnpkg global bin corepack enable;\ - fi &&\ - useradd -u $DOCKER_UID -ms /bin/bash -d /app_home appuser +RUN useradd -u $DOCKER_UID -ms /bin/bash -d /app_home appuser COPY deployment/docker/app.sh /usr/local/bin/app COPY deployment/docker/check_django.sh /usr/local/bin/hub_healthcheck @@ -174,11 +164,14 @@ RUN install -o appuser -g appuser -m 774 /dev/null /data/django.log # Copy additional dev dependencies COPY --from=build-dev /install/.venv /install/.venv +# Copy plainui styles +COPY --from=node-build /app/plainui/static/hub.css* /app/plainui/static/ ENV PATH="/install/.venv/bin:$PATH" USER appuser COPY --from=build-static --chown=appuser /app /app WORKDIR /app RUN export DJANGO_SETTINGS_MODULE='hub.settings.build' && \ - app build && \ + python3 /app/manage.py collectstatic --noinput && \ + python3 /app/manage.py compilemessages && \ unset DJANGO_SETTINGS_MODULE diff --git a/docker-compose.yml b/docker-compose.yml index a291c5e50aba5b7f81151e552dcb68bea352bf5e..731f8eb9f56833d640694e56fc6723e82af1ebc4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,8 +4,6 @@ services: build: context: . target: "${BUILD_TARGET:-dev}" - args: - DEVELOPMENT: "True" volumes: - ./src:/app - hubrun:/run/hub/ @@ -36,6 +34,18 @@ services: profiles: - test + local-static: + image: node-builder:latest + build: + context: . + target: node-build + volumes: + # Mount only the static files, as we need the node_modules to be installed from build + - ./src/plainui/styles:/app/plainui/styles + - ./src/plainui/static:/app/plainui/static + profiles: + - build + nginx: image: hubnginx:latest build: