Files
ThreadNet-Web/.gitlab-ci.yml
T

214 lines
7.8 KiB
YAML

# GitLab-CI fuer den ThreadNet-Web-Fork (Lab-GitLab: git.lab).
# Ersetzt die frueheren GitHub/Gitea-Actions-Workflows - Hintergrund: docs/axion1337-fork.md.
#
# Erkenntnisse aus den Gitea-CI-Versuchen (2026-07-30), hier eingeflossen:
# - kein scripts/layered.sh: wuerde den gepinnten matrix-js-sdk-Stand aus pnpm-lock.yaml
# mit Upstream-develop ueberschreiben (und braucht jq) -> frozen-lockfile-Install
# - webpack braucht ~4 GB Heap -> NODE_OPTIONS
# - Desktop-Build laeuft im dockerbuild-Image (rust:bullseye + node, glibc-2.31-Ziel)
stages:
- build
- package
# --- Windows-Runner-VM-Steuerung (Issue #5) ---------------------------------
# Die Windows-Build-VM (dockur/windows-Fork, siehe git.lab/axion1337.chat/vendor/windows,
# Runbook: docs/axion-runner.md dort) laeuft on-demand auf Overmind. Diese beiden Jobs
# starten/stoppen sie vom Linux-Runner aus ueber den Docker-Socket - der
# desktop_windows-Job wartet danach einfach in der Queue, bis der Runner online ist.
start_windows_vm:
stage: build
image: docker:27-cli
rules:
- if: $CI_COMMIT_TAG =~ /^v/
when: manual
allow_failure: true
- if: $CI_COMMIT_BRANCH == "main"
when: manual
allow_failure: true
script:
- docker start windows-runner
stop_windows_vm:
stage: package
image: docker:27-cli
rules:
- if: $CI_COMMIT_TAG =~ /^v/
when: manual
allow_failure: true
- if: $CI_COMMIT_BRANCH == "main"
when: manual
allow_failure: true
script:
- docker stop windows-runner
web:
stage: build
image: node:24-bullseye
rules:
# Release-Tags bauen immer (docker_web/desktop_* brauchen web als needs)
- if: $CI_COMMIT_TAG =~ /^v/
# Pushes nur, wenn build-relevante Pfade betroffen sind - Doku-Commits kosten nichts
- if: $CI_COMMIT_BRANCH
changes:
- apps/**/*
- packages/**/*
- patches/**/*
- scripts/**/*
- pnpm-lock.yaml
- pnpm-workspace.yaml
- .gitlab-ci.yml
variables:
NODE_OPTIONS: "--max-old-space-size=6144"
CI_PACKAGE: "true"
before_script:
- corepack enable
script:
- pnpm install --frozen-lockfile
- cp apps/web/element.io/develop/config.json apps/web/config.json
- VERSION=$(scripts/get-version-from-git.sh) pnpm --dir apps/web build
artifacts:
paths:
- apps/web/webapp
expire_in: 1 day
# Baut das kanonische Web-Image (apps/web/Dockerfile, Kontext = Monorepo-Root) und pusht
# es in die rohana-Registry, aus der Flux/k8s zieht. Deploy bleibt ein manueller Tag-Bump
# im gitops-Repo. Bewusster Doppel-Build (webpack laeuft im web-Job UND im Dockerfile) -
# kanonisch/reproduzierbar vor schnell; Optimierung als Folgearbeit in Issue #2.
docker_web:
stage: package
image: docker:27-cli
needs:
- job: web
artifacts: false
rules:
# Nur bei Release-Tags (v*) - "releasen" ist ein bewusster Akt:
# Tag pushen -> Image entsteht -> Tag-Bump im gitops-Repo deployt es
- if: $CI_COMMIT_TAG =~ /^v/
variables:
IMAGE: rohana.axion1337.de/sorb/threadnet-web
DOCKER_BUILDKIT: "1"
script:
- echo "$REGISTRY_PASSWORD" | docker login rohana.axion1337.de -u "$REGISTRY_USER" --password-stdin
- docker build -f apps/web/Dockerfile -t "$IMAGE:$CI_COMMIT_TAG" -t "$IMAGE:latest-ci" .
- docker push "$IMAGE:$CI_COMMIT_TAG"
- docker push "$IMAGE:latest-ci"
# Einmalig/selten: Build-Image fuer den Desktop-Build (rust:bullseye + node + tcl/sqlcipher,
# aus apps/desktop/dockerbuild). Manuell ausloesen, wenn sich .node-version oder das
# Dockerfile aendert.
desktop_image:
stage: package
image: docker:27-cli
rules:
- if: $CI_COMMIT_BRANCH == "main"
when: manual
allow_failure: true
variables:
# Lab-Registry statt rohana (OVERMIND-01): Konsument ist nur die Lab-CI selbst
IMAGE: $CI_REGISTRY_IMAGE/desktop-build
script:
- echo "$CI_JOB_TOKEN" | docker login "$CI_REGISTRY" -u gitlab-ci-token --password-stdin
- docker build -f apps/desktop/dockerbuild/Dockerfile -t "$IMAGE:bullseye" apps/desktop
- docker push "$IMAGE:bullseye"
# Electron-Linux-Build (amd64, static sqlcipher) - repliziert den am 2026-07-29 manuell
# verifizierten Build-Weg. Automatisch bei Release-Tags, auf main manuell triggerbar.
desktop_linux:
stage: package
image: rohana.axion1337.de/sorb/element-desktop-build:bullseye
needs:
- job: web
artifacts: true
rules:
- if: $CI_COMMIT_TAG =~ /^v/
- if: $CI_COMMIT_BRANCH == "main"
when: manual
allow_failure: true
variables:
MAX_GLIBC: "2.31"
USE_HARD_LINKS: "false"
SQLCIPHER_BUNDLED: "1"
script:
- pnpm install --frozen-lockfile --filter element-desktop
- cp -r apps/web/webapp apps/desktop/webapp
# Produktions-Client-Config (getrackt seit diesem Commit, vorher nur im manuellen Build)
- cp apps/desktop/axion1337/config.json apps/desktop/webapp/config.json
- cd apps/desktop
- pnpm run asar-webapp
- pnpm run build:native
# pnpm/npm setzen beim Install kein Executable-Bit auf 7za - bekannter Fix,
# gleicher Schritt wie in der Upstream-CI ("Fix permissions")
- chmod +x ../../node_modules/7zip-bin/linux/*/7za || true
- pnpm run build --publish never -l tar.gz -l deb
artifacts:
paths:
- apps/desktop/dist/*.deb
- apps/desktop/dist/*.tar.gz
expire_in: 1 week
# Windows-Desktop-Build (x64, unsigniert - Signing siehe Issue #5). Laeuft NUR auf dem
# Windows-Runner (tags), manuell: vorher start_windows_vm ausloesen. Uebersetzt aus dem
# Upstream-Workflow build_desktop_windows.yaml (x64-Pfad; arm-only-Schritte entfallen).
desktop_windows:
stage: package
tags:
- windows
needs:
- job: web
artifacts: true
rules:
- if: $CI_COMMIT_TAG =~ /^v/
when: manual
allow_failure: true
- if: $CI_COMMIT_BRANCH == "main"
when: manual
allow_failure: true
variables:
SQLCIPHER_BUNDLED: "1"
script:
- pnpm install --frozen-lockfile --filter element-desktop
- Copy-Item -Recurse apps/web/webapp apps/desktop/webapp
- Copy-Item apps/desktop/axion1337/config.json apps/desktop/webapp/config.json -Force
- cd apps/desktop
- pnpm run asar-webapp
- '& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -SkipAutomaticLocation'
- pnpm run build:native --target x86_64-pc-windows-msvc
- pnpm run build --publish never -w nsis
artifacts:
paths:
- apps/desktop/dist/*.exe
expire_in: 1 week
# Idempotente Werkzeug-Provisionierung im Windows-Gast (laeuft als SYSTEM ueber den
# Runner selbst - kein noVNC/RDP noetig). Hintergrund: choco akzeptiert --version nicht
# bei Mehrfach-Paketen, der urspruengliche Runbook-Einzeiler hat still nichts installiert.
# Startet am Ende den Runner-Dienst verzoegert neu, damit der neue PATH fuer
# Folge-Jobs greift (der Job selbst wird davon nicht mehr unterbrochen).
windows_provision:
stage: build
tags:
- windows
rules:
- if: $CI_COMMIT_BRANCH == "main"
when: manual
allow_failure: true
variables:
# Kein Checkout - der braeuchte git, das dieser Job erst installiert (Henne-Ei)
GIT_STRATEGY: none
script:
- choco install -y git
- choco install -y nasm
- choco install -y magicsplat-tcl-tk
- choco install -y nodejs --version=24.15.0
- refreshenv; corepack enable
- '& "C:\Program Files\Git\cmd\git.exe" --version'
- '& "C:\Program Files\nodejs\node.exe" --version'
# Windows-260-Zeichen-Pfadlimit: die Visual-Baseline-Pfade des Monorepos sprengen
# MAX_PATH - beide Schalter noetig (git-seitig + OS-Policy)
- '& "C:\Program Files\Git\cmd\git.exe" config --system core.longpaths true'
- Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name LongPathsEnabled -Value 1 -Type DWord
- Start-Process powershell -ArgumentList '-Command','Start-Sleep 10; Restart-Service gitlab-runner -Force'