Add Jeannie OpsProof deployment

This commit is contained in:
juvenal.diaz 2026-12-04 13:44:13 -06:00
parent 1d8a5f0e00
commit d35c2ddea0
6 changed files with 209 additions and 2 deletions

View File

@ -28,6 +28,17 @@ authority.
The application will run on Debian, outside Kubernetes. It must remain usable
when the cluster is the component being diagnosed.
The Debian installation is owned by the Jeannie pipeline:
```bash
./jeannie deploy-opsproof
```
The command downloads a checksum-pinned Go 1.27 toolchain into the OpsProof
data directory, checks out an exact Laravel Go starter commit, runs its frontend
checks and build, runs its Go tests, builds the binary, installs a hardened
systemd unit, and verifies `/up`. It does not replace Debian's system Go.
## Security boundary
OpsProof is not a shell console.

View File

@ -52,9 +52,10 @@ var allowedCommands = map[string]bool{
"apps": true, "website-translation-model": true,
"website-ollama-listen": true, "ollama-setup": true,
"deploy-gitea": true, "deploy-api": true, "deploy-heimdall": true,
"deploy-searxng": true,
"deploy-searxng": true,
"deploy-privatebin": true, "deploy-miniflux": true,
"deploy-dex": true, "deploy-matrix": true, "deploy-ai-stack": true,
"deploy-opsproof": true,
"deploy-dex": true, "deploy-matrix": true, "deploy-ai-stack": true,
"deploy-office": true,
"deploy-ai-tools": true, "deploy-omniroute": true, "deploy-hermes": true,
"rpi-services": true, "host-bootstrap": true, "bootstrap-gitea-repo": true, "repo-sync": true, "backup-gitea": true, "hermes-connect": true,

View File

@ -272,6 +272,10 @@ needed.
`deploy-miniflux`
: Deploy the external Miniflux and PostgreSQL Compose stack on Debian.
`deploy-opsproof`
: Build the pinned Laravel Go application with an isolated Go toolchain and
install the OpsProof systemd service on Debian.
`rpi-services`
: Deploy Pi-hole, Unbound, and Uptime Kuma on the Raspberry Pi.
@ -635,6 +639,18 @@ is missing. Default is to fail and ask for host bootstrap.
`LAB_PRIVATEBIN_HTTP_PORT`, `LAB_MINIFLUX_HTTP_PORT`
: Override the local service ports, which default to `8889` and `8890`.
`LAB_OPSPROOF_INSTALL_DIR`, `LAB_OPSPROOF_HTTP_PORT`, `LAB_OPSPROOF_BIND_IP`
: Override the OpsProof data root, HTTP port, and listen address. Defaults are
`/data/homelab-opsproof`, `8891`, and `127.0.0.1`.
`LAB_OPSPROOF_GO_VERSION`, `LAB_OPSPROOF_GO_SHA256`
: Pin the isolated Go toolchain used only to build OpsProof. The archive is
checksum-verified and does not replace Debian's system Go.
`LAB_OPSPROOF_STARTER_COMMIT`, `LAB_OPSPROOF_STARTER_REPO`
: Pin the Laravel Go starter source used for the OpsProof build. The commit must
be a full Git SHA.
`LAB_RPI_INSTALL_DOCKER=true`
: Allow `rpi-services` to install Docker through `get.docker.com` on the
Raspberry Pi when Docker is missing. Default is to fail.

View File

@ -82,6 +82,7 @@ Build And Bootstrap
deploy-searxng Deploy Debian-hosted SearXNG and Valkey.
deploy-privatebin Deploy Debian-hosted encrypted paste service.
deploy-miniflux Deploy Debian-hosted private RSS reader.
deploy-opsproof Build and deploy the Debian-hosted OpsProof UI.
deploy-dex Deploy the Debian-hosted Dex SSO stack.
monitoring {plan|migrate|apply|refresh|exporters|status|validate} Manage Debian monitoring; preserve cluster discovery and Dex.
deploy-office Deploy Nextcloud + ONLYOFFICE online office.
@ -711,6 +712,10 @@ case "${1:-}" in
record_change_journal "deploy-miniflux" "$@"
deploy_miniflux
;;
deploy-opsproof)
record_change_journal "deploy-opsproof" "$@"
deploy_opsproof
;;
deploy-dex)
record_change_journal "deploy-dex" "$@"
deploy_dex

View File

@ -5666,6 +5666,162 @@ deploy_miniflux() {
echo "Miniflux is healthy at ${public_url%/}/. Initial credentials remain in ${install_dir}/.env."
}
deploy_opsproof() {
local install_dir="${LAB_OPSPROOF_INSTALL_DIR:-/data/homelab-opsproof}"
local http_port="${LAB_OPSPROOF_HTTP_PORT:-8891}"
local bind_ip="${LAB_OPSPROOF_BIND_IP:-127.0.0.1}"
local go_version="${LAB_OPSPROOF_GO_VERSION:-1.27.4}"
local go_sha256="${LAB_OPSPROOF_GO_SHA256:-7226736c2339719cda28fbf3a54d71aa63bcefe376e98cef00034268dab24840}"
local starter_commit="${LAB_OPSPROOF_STARTER_COMMIT:-6dd8bd22b9d335e55b190aa16f3271e73c97cd25}"
local starter_repo="${LAB_OPSPROOF_STARTER_REPO:-https://github.com/laravel/go.git}"
local service_user="${LAB_OPSPROOF_SERVICE_USER:-$(id -un)}"
local toolchain_dir="${install_dir}/toolchains/go${go_version}"
local release_dir="${install_dir}/releases/${starter_commit}"
local build_dir=""
local archive=""
local app_key=""
local elapsed=0
local node_major=""
local required
require_debian_server "deploy-opsproof"
if ! [[ "${http_port}" =~ ^[0-9]+$ ]] || ((http_port < 1 || http_port > 65535)); then
echo "LAB_OPSPROOF_HTTP_PORT must be a valid TCP port." >&2
return 1
fi
if ! [[ "${bind_ip}" =~ ^[0-9a-fA-F:.]+$ ]]; then
echo "LAB_OPSPROOF_BIND_IP must be an IP address." >&2
return 1
fi
if ! [[ "${go_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ && "${go_sha256}" =~ ^[[:xdigit:]]{64}$ ]]; then
echo "OpsProof Go version or checksum is invalid." >&2
return 1
fi
if ! [[ "${starter_commit}" =~ ^[[:xdigit:]]{40}$ ]]; then
echo "LAB_OPSPROOF_STARTER_COMMIT must be a full Git commit SHA." >&2
return 1
fi
if ! [[ "${service_user}" =~ ^[a-z_][a-z0-9_-]*[$]?$ ]]; then
echo "LAB_OPSPROOF_SERVICE_USER is invalid." >&2
return 1
fi
for required in curl git npm openssl sha256sum systemctl tar; do
if ! command -v "${required}" >/dev/null 2>&1; then
echo "OpsProof deployment requires ${required} on Debian." >&2
return 1
fi
done
if ! node_major="$(node --version 2>/dev/null | sed -E 's/^v([0-9]+).*/\1/')" ||
! [[ "${node_major}" =~ ^[0-9]+$ ]] || ((node_major < 22)); then
echo "OpsProof requires Node.js 22 or newer on Debian." >&2
return 1
fi
sudo install -d -o "${service_user}" -g "${service_user}" -m 0750 \
"${install_dir}" "${install_dir}/releases" "${install_dir}/toolchains"
if [[ ! -x "${toolchain_dir}/bin/go" ]]; then
archive="$(mktemp "${install_dir}/go${go_version}.XXXXXX.tar.gz")"
curl -fsSL --retry 3 --output "${archive}" \
"https://go.dev/dl/go${go_version}.linux-amd64.tar.gz"
printf '%s %s\n' "${go_sha256}" "${archive}" | sha256sum --check --status || {
rm -f "${archive}"
echo "Downloaded Go ${go_version} archive failed checksum validation." >&2
return 1
}
build_dir="$(mktemp -d "${install_dir}/go-toolchain.XXXXXX")"
tar -xzf "${archive}" -C "${build_dir}"
mv "${build_dir}/go" "${toolchain_dir}"
rm -rf "${build_dir}" "${archive}"
build_dir=""
fi
build_dir="$(mktemp -d "${install_dir}/release.XXXXXX")"
git clone --quiet --filter=blob:none --no-checkout "${starter_repo}" "${build_dir}"
git -C "${build_dir}" checkout --quiet --detach "${starter_commit}"
if [[ "$(git -C "${build_dir}" rev-parse HEAD)" != "${starter_commit}" ]]; then
echo "Laravel Go starter checkout does not match the pinned commit." >&2
return 1
fi
(
cd "${build_dir}"
npm ci
npm run check
npm run build
PATH="${toolchain_dir}/bin:${PATH}" GOTOOLCHAIN=local go test ./...
PATH="${toolchain_dir}/bin:${PATH}" GOTOOLCHAIN=local go build -trimpath -o opsproof .
)
rm -rf "${release_dir}"
mv "${build_dir}" "${release_dir}"
build_dir=""
ln -sfn "${release_dir}" "${install_dir}/current"
if [[ -s "${install_dir}/.env" ]]; then
app_key="$(sed -n 's/^APP_KEY=//p' "${install_dir}/.env" | head -n 1)"
fi
if [[ "${app_key}" != base64:* ]]; then
app_key="base64:$(openssl rand -base64 32 | tr -d '\n')"
fi
umask 077
printf '%s\n' \
"APP_NAME=OpsProof" \
"APP_ENV=production" \
"APP_KEY=${app_key}" \
"APP_DEBUG=false" \
"APP_URL=http://${bind_ip}:${http_port}" \
"SERVER_HOST=${bind_ip}" \
"SERVER_PORT=${http_port}" \
"SESSION_DRIVER=file" \
"CACHE_STORE=file" \
"QUEUE_CONNECTION=sync" \
"LOG_CHANNEL=stderr" \
"LOG_LEVEL=info" >"${install_dir}/.env"
chmod 0600 "${install_dir}/.env"
sudo tee /etc/systemd/system/opsproof.service >/dev/null <<UNIT_EOF
[Unit]
Description=OpsProof evidence-first operations UI
After=network-online.target jeannie-server.service
Wants=network-online.target
[Service]
Type=simple
User=${service_user}
Group=${service_user}
WorkingDirectory=${install_dir}/current
EnvironmentFile=${install_dir}/.env
ExecStart=${install_dir}/current/opsproof
Restart=on-failure
RestartSec=5s
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=${install_dir}/current/storage
[Install]
WantedBy=multi-user.target
UNIT_EOF
sudo systemctl daemon-reload
sudo systemctl enable --now opsproof.service
until curl -fsS --connect-timeout 3 "http://${bind_ip}:${http_port}/up" >/dev/null; do
if ((elapsed >= 90)); then
echo "Timed out waiting for OpsProof on http://${bind_ip}:${http_port}/up" >&2
sudo systemctl status opsproof.service --no-pager >&2 || true
sudo journalctl -u opsproof.service -n 120 --no-pager >&2 || true
return 1
fi
sleep 3
elapsed=$((elapsed + 3))
done
echo "OpsProof Laravel Go shell is healthy at http://${bind_ip}:${http_port}/."
}
deploy_matrix() {
local mode="${LAB_MATRIX_DEPLOY:-true}"
local install_dir="${LAB_MATRIX_INSTALL_DIR:-/home/jv/matrix-server}"

View File

@ -44,5 +44,23 @@ class PrivacyServicesPipelineTests(unittest.TestCase):
self.assertIn('miniflux_server_name', main)
class OpsProofPipelineTests(unittest.TestCase):
def test_opsproof_is_debian_managed_and_version_pinned(self):
pipeline = (ROOT / "lib/jeannie/pipeline.sh").read_text(encoding="utf-8")
command = (ROOT / "jeannie").read_text(encoding="utf-8")
server = (ROOT / "cmd/jeannie-server/main.go").read_text(encoding="utf-8")
self.assertIn("deploy_opsproof()", pipeline)
self.assertIn('require_debian_server "deploy-opsproof"', pipeline)
self.assertIn('go_version="${LAB_OPSPROOF_GO_VERSION:-1.27.4}"', pipeline)
self.assertIn('go${go_version}.linux-amd64.tar.gz', pipeline)
self.assertIn("6dd8bd22b9d335e55b190aa16f3271e73c97cd25", pipeline)
self.assertIn("npm run check", pipeline)
self.assertIn("GOTOOLCHAIN=local go test ./...", pipeline)
self.assertIn("opsproof.service", pipeline)
self.assertIn("deploy-opsproof)", command)
self.assertIn('"deploy-opsproof": true', server)
if __name__ == "__main__":
unittest.main()