feat: add deploy pipeline and switch Dockerfile to COPY-based build
Some checks failed
continuous-integration/drone/push Build is failing

Add deploy_server Drone pipeline that builds and pushes the Docker image
to Gitea Container Registry, then deploys to VPS via SSH. Switch
Dockerfile from git clone to COPY-based build for CI compatibility and
better layer caching. Change exposed port to 3001.
This commit is contained in:
2026-02-24 17:52:48 +01:00
parent 93a0928928
commit e732305d99
3 changed files with 60 additions and 16 deletions

View File

@@ -62,7 +62,7 @@ npm run test -w @calchat/server # Run Jest unit tests
| | ical.js | iCalendar parsing/generation |
| Testing | Jest / ts-jest | Server unit tests |
| Deployment | Docker | Server containerization (multi-stage build) |
| | Drone CI | CI/CD pipelines (build, test, format check) |
| | Drone CI | CI/CD pipelines (build, test, format check, deploy) |
| Planned | iCalendar | Event export/import |
## Architecture
@@ -544,13 +544,11 @@ docker compose up -d # Start Radicale CalDAV server
### Server Docker Image
```bash
# Build (clones from Gitea, no local context needed):
# Build (requires local build context):
docker build -f apps/server/docker/Dockerfile -t calchat-server .
# Build from a specific branch:
docker build -f apps/server/docker/Dockerfile --build-arg BRANCH=feature-x -t calchat-server .
docker run -p 3000:3000 --env-file apps/server/.env calchat-server
docker run -p 3001:3001 --env-file apps/server/.env calchat-server
```
Multi-stage build: clones the repo from Gitea (`git clone --depth 1`) in the build stage using a `BRANCH` build arg (default: `main`), compiles shared + server, then copies only `dist/` and production dependencies to the runtime stage. No local source context required — the image can be built on any machine with Docker.
Multi-stage COPY-based build: copies `package.json` files first for layer caching, then source code. Compiles shared + server, then copies only `dist/` and production dependencies to the runtime stage. Exposes port 3001. In CI, the `plugins/docker` Drone plugin builds and pushes the image automatically.
### Environment Variables
Server requires `.env` file in `apps/server/`:
@@ -700,10 +698,11 @@ This uses the `preview` profile from `eas.json` which builds an APK with:
## CI/CD (Drone)
The project uses Drone CI (`.drone.yml`) with two pipelines:
The project uses Drone CI (`.drone.yml`) with three pipelines:
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.
## Testing