From 62719ef9c3af3d722d379d25b918e02facfda06d Mon Sep 17 00:00:00 2001 From: rorapp Date: Thu, 16 Oct 2025 01:50:43 +0200 Subject: [PATCH] deployment improvments --- .dockerignore | 8 ++++ Dockerfile | 57 +++++++++++++++++++++++++ README.md | 83 +++++++++++++++++++++---------------- default.conf | 7 ++++ docker-compose.registry.yml | 16 +++++++ docker-compose.traefik.yml | 25 +++++++++++ docker-compose.yml | 16 +++++++ entrypoint.sh | 10 +++++ id.env | 2 + scripts/publish-image.sh | 6 +-- 10 files changed, 192 insertions(+), 38 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 default.conf create mode 100644 docker-compose.registry.yml create mode 100644 docker-compose.traefik.yml create mode 100644 docker-compose.yml create mode 100755 entrypoint.sh create mode 100644 id.env diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..25b483e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +.git +.gitignore +docker-compose.yml +docker-compose.registry.yml +docker-compose.traefik.yml +id.env +scripts/publish-image.sh +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ca3519b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,57 @@ +# Use latest official Ubuntu image +FROM ubuntu:latest + +# Set timezone +ENV TZ=Europe/Berlin + +# Configure timezone data during build +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# Avoid interactive prompts during apt install +ARG DEBIAN_FRONTEND=noninteractive + +# Install Apache, PHP and required extensions +RUN apt-get update && apt-get install -y \ + apache2 \ + apache2-utils \ + ca-certificates \ + php \ + libapache2-mod-php \ + php-curl \ + php-dom \ + php-gd \ + php-intl \ + php-json \ + php-mbstring \ + php-xml \ + php-zip && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +# Ensure shared group ownership for collaborative editing +RUN groupadd -g 1111 kirbygroup && usermod -aG kirbygroup www-data + +# Provide Apache vhost configuration and entrypoint +COPY default.conf /etc/apache2/sites-available/000-default.conf +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +# Remove default Apache placeholder page +RUN rm -rf /var/www/html/* + +# Copy project into the image +COPY --chown=www-data:kirbygroup . /var/www/html + +# Enable required Apache modules +RUN a2enmod headers rewrite + +# Ensure collaborative permissions at runtime +RUN chmod -R g+rw /var/www/html && find /var/www/html -type d -exec chmod g+xs {} \; + +# Expose web port +EXPOSE 80 + +# Allow UID remapping before Apache starts +ENTRYPOINT ["/entrypoint.sh"] + +# Start Apache in foreground +CMD ["/usr/sbin/apache2ctl", "-DFOREGROUND"] diff --git a/README.md b/README.md index 04ba08e..949f76c 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,56 @@ - +# Lichterei Web – Kirby Projekt -**Kirby: the CMS that adapts to any project, loved by developers and editors alike.** -The Starterkit is a full-blown Kirby installation with a lot of example content, blueprints, templates and more. -It is ideal for new users to explore many of Kirby's options and get to know the Panel. +Dieses Repository bündelt die Kirby-Installation sowie die Docker-Infrastruktur, damit du das Projekt lokal ausprobieren und im Server-Setup mit Traefik deployen kannst. -You can learn more about Kirby at [getkirby.com](https://getkirby.com). +## Voraussetzungen +- Docker Engine ≥ 20.10 und `docker compose` +- Optional: Composer, falls du Abhängigkeiten aktualisieren möchtest +- Passe vor dem ersten Start den Wert `USERID` in `id.env` an deinen lokalen Benutzer an – so vermeidest du Rechteprobleme beim Schreiben ins gemountete Volume. - +## Lokale Ausführung +1. `USERID` in `id.env` prüfen/anpassen (`id -u` liefert deinen Wert). +2. Container starten: + ```bash + docker compose up --build + ``` +3. Die Seite ist anschließend unter http://localhost:8080 erreichbar, das Kirby Panel unter http://localhost:8080/panel. -### Try Kirby for free +Mit `docker compose down` stoppst du die Umgebung wieder. Inhalte bleiben erhalten, da der Projektordner als Volume eingebunden ist. -You can try Kirby and the Starterkit on your local machine or on a test server as long as you need to make sure it is the right tool for your next project. … and when you’re convinced, [buy your license](https://getkirby.com/buy). +## Deployment mit Traefik +1. Domain, Router- und Zertifikatsnamen in `docker-compose.traefik.yml` anpassen. +2. Sicherstellen, dass das externe Netzwerk `proxy` existiert (`docker network create proxy`). +3. Deployment starten: + ```bash + docker compose \ + -f docker-compose.yml \ + -f docker-compose.traefik.yml \ + up -d + ``` + Passe bei Bedarf den Volume-Eintrag in `docker-compose.yml` an (z. B. benanntes Volume oder separater Persistenzpfad). +4. Für den Registry-Workflow steht `scripts/publish-image.sh` bereit. Das Skript baut das Image aus dem aktuellen Stand und pusht es zum konfigurierten Registry-Host. -The Starterkit is a demo of basic Kirby features. It's not recommended to be used "as is" in production. Please, follow our documentation closely for more features and guides on how to build secure, high-quality websites with Kirby. +## Nutzung eines Registry-Images +- Setze vor dem Start die Umgebungsvariable `KIRBY_IMAGE` auf das exakte Image samt Tag oder Digest, z. B.: + ```bash + export KIRBY_IMAGE=gitea.mindboost.team/interkollektives/lichterei-web:0.0.1 + ``` + Mit `docker image ls gitea.mindboost.team/interkollektives/lichterei-web` siehst du, welche Tags lokal vorhanden sind. Fehlt der gewünschte Tag, kannst du ihn vergeben: `docker tag gitea.mindboost.team/...:`. +- Container aus Registry starten: + ```bash + docker compose -f docker-compose.registry.yml up -d + ``` + `--build` wird hier nicht benötigt, da keine lokale Build-Definition verwendet wird. +- Falls du das Image aktualisierst, entferne das benannte Volume vorher (`docker compose down -v`), damit die neuen Dateien aus dem Image erneut in `/var/www/html` kopiert werden. +- Kombination mit Traefik ist ebenfalls möglich: + ```bash + docker compose -f docker-compose.registry.yml -f docker-compose.traefik.yml up -d + ``` -While Kirby as the CMS software itself requires you to purchase a license, we consider the files primarily connected to this Starterkit (assets, templates, snippets...) free to use under the MIT license. Feel free to start building your own project with them. +## Contribution Guidelines +- Forken oder Branch erstellen, bevor du Änderungen beginnst. +- Lokal mit `docker compose up` arbeiten oder – falls du ohne Container entwickeln willst – `composer install` ausführen. +- Bitte prüfe, ob deine Änderungen im Frontend sichtbar funktionieren und keine PHP-Fehler im Log landen. +- Pull Request eröffnen und kurz beschreiben, was angepasst wurde und wie getestet wurde. -### Get going - -Read our guide on [how to get started with Kirby](https://getkirby.com/docs/guide/quickstart). - -You can download the latest version of the Starterkit from https://download.getkirby.com/. -If you are familiar with Git, you can clone Kirby's Starterkit repository from Github. - - git clone https://github.com/getkirby/starterkit.git - -## What's Kirby? - -- **[getkirby.com](https://getkirby.com)** – Get to know the CMS. -- **[Try it](https://getkirby.com/try)** – Take a test ride with our online demo. Or download one of our kits to get started. -- **[Documentation](https://getkirby.com/docs/guide)** – Read the official guide, reference and cookbook recipes. -- **[Issues](https://github.com/getkirby/kirby/issues)** – Report bugs and other problems. -- **[Feedback](https://feedback.getkirby.com)** – You have an idea for Kirby? Share it. -- **[Forum](https://forum.getkirby.com)** – Whenever you get stuck, don't hesitate to reach out for questions and support. -- **[Discord](https://chat.getkirby.com)** – Hang out and meet the community. -- **[YouTube](https://youtube.com/kirbyCasts)** - Watch the latest video tutorials visually with Bastian. -- **[Mastodon](https://mastodon.social/@getkirby)** – Spread the word. -- **[Bluesky](https://bsky.app/profile/getkirby.com)** – Tell a friend. ---- - -© 2009 Bastian Allgeier -[getkirby.com](https://getkirby.com) · [License agreement](https://getkirby.com/license) +Vielen Dank fürs Mitmachen! Bei Fragen melde dich einfach per Issue oder direkt im Team-Chat. diff --git a/default.conf b/default.conf new file mode 100644 index 0000000..9817606 --- /dev/null +++ b/default.conf @@ -0,0 +1,7 @@ + + ServerName interkollektives.de + DocumentRoot "/var/www/html" + + AllowOverride All + + diff --git a/docker-compose.registry.yml b/docker-compose.registry.yml new file mode 100644 index 0000000..3de476e --- /dev/null +++ b/docker-compose.registry.yml @@ -0,0 +1,16 @@ +services: + kirbycms: + image: ${KIRBY_IMAGE:?Set KIRBY_IMAGE, e.g. gitea.mindboost.team/interkollektives/lichterei-web:0.0.1} + pull_policy: always + container_name: kirbycms + env_file: + - id.env + volumes: + - kirby_data:/var/www/html + ports: + - "8080:80" + restart: unless-stopped + +volumes: + kirby_data: + driver: local diff --git a/docker-compose.traefik.yml b/docker-compose.traefik.yml new file mode 100644 index 0000000..45cc3ba --- /dev/null +++ b/docker-compose.traefik.yml @@ -0,0 +1,25 @@ +version: "3.8" + +services: + kirbycms: + ports: [] + labels: + - "traefik.enable=true" + - "traefik.docker.network=proxy" + - "traefik.http.routers.lichtcms.service=lichtcms" + - "traefik.http.routers.lichtcms.tls.certresolver=http_resolver" + - "traefik.http.routers.lichtcms.tls.domains[0].main=licht.interkollektiv.es" + - "traefik.http.routers.lichtcms.rule=Host(`licht.interkollektiv.es`)" + - "traefik.http.routers.lichtcms.entrypoints=websecure" + - "traefik.http.routers.lichtcms.tls=true" + - "traefik.http.services.lichtcms.loadbalancer.server.port=80" + - "traefik.http.routers.lichtcms-http.rule=Host(`licht.interkollektiv.es`)" + - "traefik.http.routers.lichtcms-http.entrypoints=web" + - "traefik.http.routers.lichtcms-http.middlewares=traefik-https-redirect" + - "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https" + networks: + - proxy + +networks: + proxy: + external: true diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..cd9df41 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: "3.8" + +services: + kirbycms: + build: + context: . + dockerfile: Dockerfile + image: kirbycms:latest + container_name: kirbycms + env_file: + - id.env + volumes: + - ./:/var/www/html:rw + ports: + - "8080:80" + restart: unless-stopped diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..f66eed3 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -euo pipefail + +USER_ID="${USERID:-}" +if [[ -n "${USER_ID}" && "${USER_ID}" != "$(id -u www-data)" ]]; then + usermod --uid "${USER_ID}" www-data +fi + +exec "$@" diff --git a/id.env b/id.env new file mode 100644 index 0000000..840b83a --- /dev/null +++ b/id.env @@ -0,0 +1,2 @@ +# Match the container's www-data user to your local user ID +USERID=1111 diff --git a/scripts/publish-image.sh b/scripts/publish-image.sh index e23cb19..28ddd8b 100755 --- a/scripts/publish-image.sh +++ b/scripts/publish-image.sh @@ -7,10 +7,10 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" if PROJECT_ROOT="$(git -C "${SCRIPT_DIR}" rev-parse --show-toplevel 2>/dev/null)"; then : else - PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)" + PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" fi -DOCKER_CONTEXT="$(cd "${PROJECT_ROOT}/.." && pwd)" -DOCKERFILE_PATH="${DOCKER_CONTEXT}/Dockerfile" +DOCKER_CONTEXT="${PROJECT_ROOT}" +DOCKERFILE_PATH="${PROJECT_ROOT}/Dockerfile" REGISTRY_HOST="gitea.mindboost.team" IMAGE_NAME="interkollektives/lichterei-web"