Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 18 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,53 +48,36 @@ FOSShowcaseiOSApp is a cross-platform [SwiftUI](https://developer.apple.com/xcod

## Deploying

The public web service (Vapor backend + Ignite web app, behind nginx) runs as a
Docker Compose stack on an **isolated Tart Linux VM** (`fos-showcase`, `10.1.3.10`)
on the `fos-openclaw` host, on the UniFi "Public Servers" VLAN-3 DMZ. The repo is
the source of truth and the VM is disposable. Full architecture, network rules, and
the rebuild procedure are in [`docs/runbook-pi-to-vm.md`](docs/runbook-pi-to-vm.md).
The public web service (Vapor backend + Leaf web app, behind nginx) runs as a
Docker Compose stack on a small private Linux VM. The repo is the source of
truth and the VM is disposable: rebuilding from the repo is the recovery path.

Where the VM is, how it is reached, how it was built, and the network rules
around it are **not in this repository**. They live in the private ops repo
(`openclaw-config`: `docs/fos-showcase/runbook-pi-to-vm.md` and
`deploy/fos-showcase/`).

### Routine deploy (code / config change)

Run from a machine that has the canonical secrets at `~/.foscs/fosshowcase/{.env,ssl/}`:
Run from a machine that has the canonical secrets at `~/.foscs/fosshowcase/`
(`.env`, `ssl/`, and `deploy.env` naming the VM):

```bash
git commit ... # commit your change first
./deploy/deploy.sh
```

`deploy/deploy.sh` ProxyJumps through the `fos-openclaw` host (the VM's DMZ VLAN is
reachable only via the host), then:

1. rsyncs the repo to `/opt/fosshowcase` on the VM,
2. delivers `.env` + `ssl/` (mode 600), and
3. runs `docker compose up -d --build` and prints `docker compose ps`.
`deploy/deploy.sh` rsyncs the repo to the VM, delivers `.env` + `ssl/`
(mode 600), builds the three images one at a time (the VM is small), and runs
`docker compose up -d`.

Notes:

- A deploy **rebuilds both Swift apps** (~20–40 min) — the Dockerfiles `COPY` the
whole repo, so any change invalidates the shared build cache.
- Secrets and TLS certs are **not** in git; they live at `~/.foscs/fosshowcase/` and
are pushed at deploy time. `deploy/env.example` documents the required variables.
- Override targets via env: `VM_HOST`, `JUMP_HOST` (set `JUMP_HOST=""` to deploy
directly when already on the internal network), `SRC_SECRETS`.

### Full VM rebuild (disposable VM)

If the VM is lost, rebuild from the runbook:

1. `deploy/provision-vm.sh` — create the Tart VM on VLAN 3 (`VLAN_IFACE=vlan1`),
2. in-guest provisioning (static IP, Docker, NTP, `deploy/nic-offload-off.service`, SSH hardening),
3. install the host LaunchAgent (`deploy/com.foscs.tart-fos-showcase.plist`) so the VM
auto-starts on reboot, then
4. `deploy/deploy.sh`.

Network and database authorization (UDM port-forward + firewall, Postgres `pg_hba`)
is permanent and managed in the `openclaw-config` repo — it does not need redoing
per deploy.

The VM keeps **no backups by design** — rebuilding from the repo *is* the recovery path,
and the `fos-openclaw` host is covered by Time Machine. See runbook Section 7.
- A deploy **rebuilds both Swift apps** (the Dockerfiles `COPY` the whole repo,
so any change invalidates the build cache); expect 30+ minutes.
- Secrets, TLS certs and the VM address are **not** in git. `deploy/env.example`
documents the required application variables; `deploy.env` holds `VM_HOST`
and optionally `JUMP_HOST` / `VM_PATH`.

## Maintainers

Expand Down
38 changes: 0 additions & 38 deletions deploy/com.foscs.postgres-stale-lock.plist

This file was deleted.

33 changes: 0 additions & 33 deletions deploy/com.foscs.tart-fos-showcase-checkpoint.plist

This file was deleted.

24 changes: 0 additions & 24 deletions deploy/com.foscs.tart-fos-showcase.plist

This file was deleted.

27 changes: 19 additions & 8 deletions deploy/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@
set -euo pipefail

# Deliver secrets/certs/repo to the fos-showcase VM and (re)deploy the stack.
# The VM is on the isolated "Public Servers" VLAN (zone Web Servers), reachable
# only via the fos-openclaw host — so we ProxyJump through it. Set JUMP_HOST=""
# to connect directly (e.g. from a machine already in the Internal zone).
#
# Where the VM is, and how to reach it, is private network detail and is NOT
# in this public repo. It comes from $SRC_SECRETS/deploy.env (mode 600), next
# to the .env and ssl/ this script already delivers:
#
# VM_HOST=user@vm-address # required
# JUMP_HOST=user@bastion-address # optional; empty = connect directly
# VM_PATH=/opt/fosshowcase # optional
#
# The runbook (VM build, network rules, recovery) lives in the private ops repo.

SRC_SECRETS="${SRC_SECRETS:-$HOME/.foscs/fosshowcase}" # canonical .env + ssl/ + deploy.env
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"

VM_HOST="${VM_HOST:-admin@10.1.3.10}"
[ -f "$SRC_SECRETS/deploy.env" ] || { echo "Missing $SRC_SECRETS/deploy.env (VM_HOST, optional JUMP_HOST/VM_PATH)"; exit 1; }
# shellcheck disable=SC1091
. "$SRC_SECRETS/deploy.env"
: "${VM_HOST:?deploy.env must set VM_HOST}"
VM_PATH="${VM_PATH:-/opt/fosshowcase}"
SRC_SECRETS="${SRC_SECRETS:-$HOME/.foscs/fosshowcase}" # canonical .env + ssl/ source
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
JUMP_HOST="${JUMP_HOST:-david@10.1.2.158}" # fos-openclaw; set "" to disable ProxyJump
JUMP_HOST="${JUMP_HOST:-}"
SSH_OPTS=(-o StrictHostKeyChecking=accept-new)
[ -n "$JUMP_HOST" ] && SSH_OPTS+=(-J "$JUMP_HOST")
SSH_CMD="ssh -o StrictHostKeyChecking=accept-new${JUMP_HOST:+ -J $JUMP_HOST}"
Expand All @@ -37,7 +48,7 @@ rsync -az -e "$SSH_CMD" "$SRC_SECRETS/.env" "$VM_HOST:$VM_PATH/.env"
rsync -az -e "$SSH_CMD" "$SRC_SECRETS/ssl/" "$VM_HOST:$VM_PATH/ssl/"
ssh "${SSH_OPTS[@]}" "$VM_HOST" "chmod 600 $VM_PATH/.env && chmod 600 $VM_PATH/ssl/*.key"

# Build the images ONE AT A TIME. The VM has 2 vCPUs / 3.9 GB; `up --build`
# Build the images ONE AT A TIME. The VM is small (2 vCPUs / 4 GB); `up --build`
# compiles both Swift apps in parallel and each release build spawns ~1.6 GB
# swift-frontend processes, so the kernel OOM-killer took the build (and sshd)
# out on 2026-11-01. Sequential builds fit; the swap of running containers is
Expand Down
2 changes: 1 addition & 1 deletion deploy/env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# lines, like these.

LOG_LEVEL=info
DATABASE_HOST=10.1.2.158
DATABASE_HOST=<postgres-host>

# openclaw_webhook role password (= OPENCLAW_WEBHOOK_PASSWORD in ~/.openclaw/.env)
POSTGRES_WEBHOOK_PASSWORD=__set_me__
Expand Down
20 changes: 0 additions & 20 deletions deploy/nic-offload-off.service

This file was deleted.

43 changes: 0 additions & 43 deletions deploy/postgres-clear-stale-lock.sh

This file was deleted.

43 changes: 0 additions & 43 deletions deploy/provision-vm.sh

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ services:
dockerfile: Dockerfile-server
environment:
<<: *shared_environment
DATABASE_HOST: ${DATABASE_HOST:-10.1.2.158}
DATABASE_HOST: ${DATABASE_HOST:?set in .env}
DATABASE_PORT: 5432
DATABASE_NAME: foscs
DATABASE_USER: openclaw_webhook
Expand Down
Loading
Loading