From 6463100fbdcd641f3389be6c8b84365ee366b300 Mon Sep 17 00:00:00 2001 From: Linus Waldowsky Date: Wed, 25 Feb 2026 17:58:03 +0100 Subject: [PATCH] feat: restore CI pipelines and add k3s deployment Re-enable build/test/format pipelines, rename deploy_server to deploy_latest, add upload_tag (tag-triggered k3s deploy) and upload_commit (promote-triggered k3s deploy). Update CLAUDE.md. --- .drone.yml | 175 +++++++++++++++++++++++++++++++++++++++++------------ CLAUDE.md | 11 +++- 2 files changed, 145 insertions(+), 41 deletions(-) diff --git a/.drone.yml b/.drone.yml index 96a1b49..2d53a85 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,41 +1,59 @@ -# kind: pipeline -# type: docker -# name: server_build_and_test -# -# steps: -# - name: build_server -# image: node -# commands: -# - npm ci -w @calchat/shared -# - npm ci -w @calchat/server -# - npm run build -w @calchat/server -# -# - name: jest_server -# image: node -# commands: -# - npm run test -w @calchat/server -# -# --- -# -# kind: pipeline -# type: docker -# name: check_for_formatting -# -# steps: -# - name: format_check -# image: node -# commands: -# - npm ci -# - npm run check_format -# -# --- -# kind: pipeline type: docker -name: deploy_server +name: server_build_and_test + +trigger: + branch: + - main + event: + - push steps: - - name: upload_to_registry + - name: build_server + image: node + commands: + - npm ci -w @calchat/shared + - npm ci -w @calchat/server + - npm run build -w @calchat/server + + - name: jest_server + image: node + commands: + - npm run test -w @calchat/server + +--- + +kind: pipeline +type: docker +name: check_for_formatting + +trigger: + branch: + - main + event: + - push + +steps: + - name: format_check + image: node + commands: + - npm ci + - npm run check_format + +--- + +kind: pipeline +type: docker +name: deploy_latest + +trigger: + branch: + - main + event: + - push + +steps: + - name: upload_latest image: plugins/docker settings: registry: gitea.gilmour109.de @@ -43,13 +61,12 @@ steps: dockerfile: apps/server/docker/Dockerfile tags: - latest - - main username: from_secret: gitea_username password: from_secret: gitea_password - - name: ssh + - name: deploy_to_vps image: appleboy/drone-ssh settings: host: @@ -67,6 +84,86 @@ steps: - docker pull gitea.gilmour109.de/gilmour109/calchat-server:latest - docker compose -f /root/calchat-mongo/docker-compose.yml up -d -# depends_on: -# - server_build_and_test -# - check_for_formatting +depends_on: + - server_build_and_test + - check_for_formatting + +--- + +kind: pipeline +type: docker +name: upload_tag + +trigger: + event: + - tag + +steps: + - name: upload_tag + image: plugins/docker + settings: + registry: gitea.gilmour109.de + repo: gitea.gilmour109.de/gilmour109/calchat-server + dockerfile: apps/server/docker/Dockerfile + tags: + - ${DRONE_TAG} + username: + from_secret: gitea_username + password: + from_secret: gitea_password + + - name: deploy_to_k3s + image: appleboy/drone-ssh + settings: + host: + - 192.168.178.201 + username: debian + password: + from_secret: k3s_ssh_password + envs: + - drone_tag + port: 22 + command_timeout: 2m + script: + - export NAME=$DRONE_TAG + - envsubst < /home/debian/manifest.yml | sudo kubectl apply -f - + +--- + +kind: pipeline +type: docker +name: upload_commit + +trigger: + event: + - promote + +steps: + - name: upload_commit + image: plugins/docker + settings: + registry: gitea.gilmour109.de + repo: gitea.gilmour109.de/gilmour109/calchat-server + dockerfile: apps/server/docker/Dockerfile + tags: + - ${DRONE_COMMIT_SHA:0:8} + username: + from_secret: gitea_username + password: + from_secret: gitea_password + + - name: deploy_to_k3s + image: appleboy/drone-ssh + settings: + host: + - 192.168.178.201 + username: debian + password: + from_secret: k3s_ssh_password + envs: + - drone_commit_sha + port: 22 + command_timeout: 2m + script: + - export NAME=$(echo $DRONE_COMMIT_SHA | cut -c1-8) + - envsubst < /home/debian/manifest.yml | sudo kubectl apply -f - diff --git a/CLAUDE.md b/CLAUDE.md index 1f53de4..7479a50 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -698,11 +698,18 @@ This uses the `preview` profile from `eas.json` which builds an APK with: ## CI/CD (Drone) -The project uses Drone CI (`.drone.yml`) with three pipelines: +The project uses Drone CI (`.drone.yml`) with five pipelines: +**On push to main:** 1. **`server_build_and_test`**: Builds the server (`npm ci` + `npm run build`) and runs Jest tests (`npm run test`) 2. **`check_for_formatting`**: Checks Prettier formatting across all workspaces (`npm run check_format`) -3. **`deploy_server`**: Builds Docker image, pushes to Gitea Container Registry (`gitea.gilmour109.de/Gilmour109/calchat-server`), then SSHs into VPS (`10.0.0.1`) to pull and restart via `docker compose`. Depends on both pipelines above passing first. +3. **`deploy_latest`**: Builds Docker image, pushes to Gitea Container Registry (`gitea.gilmour109.de/gilmour109/calchat-server:latest`), then SSHs into VPS (`10.0.0.1`) to pull and restart via `docker compose`. Depends on both pipelines above passing first. + +**On tag:** +4. **`upload_tag`**: Builds Docker image tagged with the git tag (`${DRONE_TAG}`), pushes to registry, then deploys to k3s cluster (`192.168.178.201`) via SSH using `envsubst` with a Kubernetes manifest template. + +**On promote:** +5. **`upload_commit`**: Builds Docker image tagged with short commit SHA (first 8 chars), pushes to registry, then deploys to k3s cluster (`192.168.178.201`) via SSH using `envsubst` with a Kubernetes manifest template. ## Testing