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.
This commit is contained in:
175
.drone.yml
175
.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
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: deploy_server
|
name: server_build_and_test
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- main
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
|
||||||
steps:
|
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
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
registry: gitea.gilmour109.de
|
registry: gitea.gilmour109.de
|
||||||
@@ -43,13 +61,12 @@ steps:
|
|||||||
dockerfile: apps/server/docker/Dockerfile
|
dockerfile: apps/server/docker/Dockerfile
|
||||||
tags:
|
tags:
|
||||||
- latest
|
- latest
|
||||||
- main
|
|
||||||
username:
|
username:
|
||||||
from_secret: gitea_username
|
from_secret: gitea_username
|
||||||
password:
|
password:
|
||||||
from_secret: gitea_password
|
from_secret: gitea_password
|
||||||
|
|
||||||
- name: ssh
|
- name: deploy_to_vps
|
||||||
image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
settings:
|
settings:
|
||||||
host:
|
host:
|
||||||
@@ -67,6 +84,86 @@ steps:
|
|||||||
- docker pull gitea.gilmour109.de/gilmour109/calchat-server:latest
|
- docker pull gitea.gilmour109.de/gilmour109/calchat-server:latest
|
||||||
- docker compose -f /root/calchat-mongo/docker-compose.yml up -d
|
- docker compose -f /root/calchat-mongo/docker-compose.yml up -d
|
||||||
|
|
||||||
# depends_on:
|
depends_on:
|
||||||
# - server_build_and_test
|
- server_build_and_test
|
||||||
# - check_for_formatting
|
- 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 -
|
||||||
|
|||||||
11
CLAUDE.md
11
CLAUDE.md
@@ -698,11 +698,18 @@ This uses the `preview` profile from `eas.json` which builds an APK with:
|
|||||||
|
|
||||||
## CI/CD (Drone)
|
## 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`)
|
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`)
|
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
|
## Testing
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user