Edgeweir
Reference

Command line

Parameters, variables and exit codes of deploy.sh and the node install.sh, Compose operations, the container entry point, account recovery and dev commands.

deploy.sh

Install and operations script for 宝塔 / aaPanel and any Linux host with Docker and Compose v2. Usage: ./deploy.sh <command> [arguments]. Behaviour, files written and backup layout: deploy.sh reference.

Commands

CommandArgumentsEffect
install—Interactive install: database mode (host or bundled), .env and Compose file, start. The script must be downloaded to a file first (curl … | bash does not work)
update[tag], --no-backupBacks up, then upgrades to tag (default stable; latest follows master builds, or a dated tag). A channel resolves to the dated tag written to EDGEWEIR_VERSION in .env. --no-backup skips the backup. Alias upgrade
backup—Backs up the database, .env (without the master key) and the Compose file to backups/; how many are kept: EDGEWEIR_BACKUP_KEEP
restore<backup>, --no-backupBacks up the current database, then replaces it with the backup's edgeweir.dump; .env is unchanged. Needs EDGEWEIR_YES=1 when not run interactively
config—Changes the console URL and the node channel URL
start—Starts, applying .env changes
stop—Stops
restart—Recreates the console container and starts it, applying .env changes
status—Container status, deployment directory, mode and running version
logs[service]Follows the logs from the last 200 lines; service console or postgres
setup-token—Prints the first-run setup token; fails once setup is done or while the container is not running
templatehost | bundledPrints a Compose template for pasting into a panel by hand
self-update—Replaces the script with the /app/deploy.sh of the current image; without one, downloads EDGEWEIR_SCRIPT_URL
help, -h, --help—Prints the usage

Environment variables

VariableDefaultEffect
EDGEWEIR_YESUnsetNon-empty: no questions on /dev/tty; defaults or the variables below are used (unattended); restore asks for no confirmation
EDGEWEIR_DBInteractive: asked; unattended: bundledDatabase mode of install: host (local or cloud PostgreSQL, host network) or bundled (PostgreSQL in the Compose project); any other value fails
DATABASE_URLNoneConnection string of the host mode of install; required unattended. No whitespace, quotes, $ or #
EDGEWEIR_PUBLIC_URLNoneConsole URL of install; required unattended
EDGEWEIR_NODE_API_URLhttps://<console host>:<EDGEWEIR_NODE_API_PORT>Node channel URL of install; must be https://; its port is the node channel port. In host mode the port is at least 1024
EDGEWEIR_NODE_API_PORT8443Port in the default node channel URL of install
EDGEWEIR_HTTP_PORT3000Web port of install (the number after the last :); a port in use is asked again interactively and fails unattended
EDGEWEIR_VERSIONstableImage tag of install; a channel resolves to a dated tag
EDGEWEIR_DIR/opt/edgeweir; /www/dk_project/edgeweir when /www/server/panel existsInstall directory of install (absolute, empty). The other commands look for a deployment in: EDGEWEIR_DIR, the script's directory, the current directory, /www/dk_project/edgeweir, /opt/edgeweir
EDGEWEIR_NO_PULLUnsetNon-empty: never pull, use images already on the host (docker load)
EDGEWEIR_POSTGRES_IMAGEpostgres:18.6-alpine (pinned by digest)PostgreSQL image of the bundled mode, and the image of the host mode's checks and backups
EDGEWEIR_BACKUP_KEEP5Backups kept; 0 keeps all; a non-number fails
EDGEWEIR_SCRIPT_URLhttps://raw.githubusercontent.com/marvinli001/edgeweir/master/deploy.shFallback download URL of self-update

Exit codes

Exit codeMeaning
0Done, or help
1A check or step failed (stderr prints ✗ and the reason), or an unknown command (with the usage)

Node install script

The console serves install.sh at /install.sh; it installs and enrolls edgeweir-node on a node. Install commands generated by the console fill in --server and --ca-sha256; see Adding nodes.

node
sh <<'EDGEWEIR_INSTALL'
set -eu
unset EDGEWEIR_TOKEN
umask 077
d=
trap '[ -z "$d" ] || rm -rf "$d"' EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
d=$(mktemp -d "${TMPDIR:-/tmp}/edgeweir-install.XXXXXXXX")
chmod 0700 "$d"
cat >"$d/token" <<'EDGEWEIR_ENROLLMENT_TOKEN'
<one-time-token>
EDGEWEIR_ENROLLMENT_TOKEN
chmod 0600 "$d/token"
curl -fsSL https://cdn-admin.example.com/install.sh -o "$d/install.sh"
set -- --token-file "$d/token" --server https://cdn-admin.example.com:8443 --ca-sha256 <ca-sha256>
if [ "$(id -u)" = 0 ]; then
  bash "$d/install.sh" "$@" </dev/null
else
  sudo bash "$d/install.sh" "$@" </dev/null
fi
EDGEWEIR_INSTALL

Options

In the complete install command, add options at the end of the set -- --token-file … line.

<console> is EDGEWEIR_PUBLIC_URL, written into the script when the console serves it.

OptionArgumentDefaultEffect
--serverURLRequiredNode channel URL: https://host[:port] (the node channel port, default 443), or wss://, ws://host[:port] (the WebSocket entry on the web port; needs edgeweir-node 0.2.0 or later)
--ca-sha256HEXRequiredSHA-256 fingerprint of the console's node CA, 64 lowercase hex characters; pinned at enrollment
--token-filePATHNoneReads the enrollment token from a file (all whitespace removed); wins over EDGEWEIR_TOKEN
--versionVERlatestedgeweir-node version, semantic version, optional v prefix. latest resolves from the mirror's latest file, then GitHub's latest release. On an enrolled host without this option (and without --force) nothing is downloaded or installed: the service is started or restarted and checked
--formatauto | deb | rpm | tarautoPackage format. auto: deb with dpkg and apt-get; rpm with rpm and dnf or yum; otherwise tar
--mirrorURL<console>/downloads/edgeweir-nodeedgeweir-node release mirror (http, https), files at URL/latest and URL/v<version>/<file>; cosign from the sibling cosign/v<version>/. Each file is tried on the mirror first, then GitHub
--mirror-only—OffNever fall back to GitHub
--no-modsecurity—OffSkip edgeweir-openresty-modsecurity: the node does not support OWASP CRS
--no-start—OffInstall and enroll only: no systemd needed, the service is not enabled or started, no health check
--force—OffEnroll an enrolled host again (needs a new token): packages are installed as on a new host, edgeweir-node is stopped, its identity replaced and the service started
--allow-unsigned—OffSkip the cosign signature check, development only; SHA-256 is still verified
-h, --help——Prints the usage
Environment variableEffect
EDGEWEIR_TOKENLegacy enrollment input, ewt_ followed by [A-Za-z0-9_-]; prefer the complete generated command or --token-file. The script immediately prevents child inheritance, then writes a private file for enroll's --token-file and cleans it on exit. Not used on an enrolled host without --force

--token and --token=… are refused: command-line arguments are visible in the process list.

Requirements and checks

CheckFails when
SystemNot Linux; not root; no curl, sha256sum or tar; no systemd without --no-start
ArchitectureNot x86_64 (amd64) or aarch64 (arm64)
glibcOlder than 2.34 (RHEL / Rocky / AlmaLinux 9, Debian 12, Ubuntu 22.04 or later)
Node channel (https://)Unreachable; with openssl installed, the SHA-256 of the last certificate the server presents is not --ca-sha256 (a proxy or CDN terminates TLS)
Node channel (wss://, ws://)<web URL>/node-channel answers 404 (WebSocket entry closed) or any status other than 426
ObjectVerification
checksums.txtcosign keyless signature (checksums.txt.sigstore.json). Certificate identity: https://github.com/marvinli001/edgeweir-node/.github/workflows/release.yml@refs/tags/v<version>; OIDC issuer: https://token.actions.githubusercontent.com
PackagesSHA-256 against the signed checksums.txt
cosignWithout cosign on the machine, v3.1.3 is downloaded and checked against the SHA-256 built into the script

Nothing downloaded runs before verification passes. Steps and results: Adding nodes.

Exit codes

Exit codeMeaning
0Installed and enrolled; edgeweir-node healthcheck passed (not checked with --no-start)
1A check or step failed, including an unknown option or a health check that did not pass within 90 seconds; stderr prints [edgeweir] error: and the reason
2--server or --ca-sha256 missing, an option without its argument, or -h, --help; stderr prints the usage

The script does not uninstall. Node upgrades: Node upgrades.

Docker Compose

Run in the directory of compose.yml; other Compose files with -f <file>.

OperationCommand
Start, or apply .env changesdocker compose up -d
Build from source and startdocker compose up -d --build
Stopdocker compose stop
Remove containers and networks, keep volumesdocker compose down
Restart (does not apply .env changes)docker compose restart console
Statusdocker compose ps
Follow logsdocker compose logs -f console
Setup token log linedocker compose logs console | grep setupToken
Health check (host)curl -s http://127.0.0.1:3000/healthz
Health check (in the container)docker compose exec console edgeweir-healthcheck
Account recoverydocker compose exec console node dist/server/recover.js <options>; see Account recovery
Pull the image EDGEWEIR_VERSION names and recreatedocker compose pull && docker compose up -d
Start ClickHouseSet COMPOSE_PROFILES=analytics in .env, then docker compose up -d

docker compose down -v deletes the named volumes such as postgres-data: all data.

Print only the setup token:

docker compose logs --no-color --no-log-prefix console \
  | sed -n 's/.*"setupToken":"\([^"]*\)".*/\1/p' | tail -n 1

/healthz returns {"status":"ok","version":"<version>"}. Use EDGEWEIR_HTTP_PORT instead of 3000 when it differs. Upgrade and rollback steps: Versions, upgrades and rollback.

Container

ItemValue
Imageghcr.io/marvinli001/edgeweir:<tag>, linux/amd64, linux/arm64
Entry point/sbin/tini --
Commandnode --enable-source-maps dist/server/main.js, working directory /app
Usernode
Ports3000 (web, API), 8443 (node channel)
Environment defaultsNODE_ENV=production, ROLE=all, HOST=0.0.0.0, PORT=3000, NODE_API_PORT=8443, EDGEWEIR_VERSION=<build version>, EDGEWEIR_CERTD_BIN=/usr/local/bin/edgeweir-certd
Health checkedgeweir-healthcheck; interval 10 s, timeout 3 s, start period 30 s, 5 retries
Bundled files/usr/local/bin/edgeweir-certd, /usr/local/bin/edgeweir-healthcheck, /app/deploy.sh, /app/dist/server/recover.js
Stop signalsSIGTERM, SIGINT: the HTTP and node channel listeners close and nodes' watch streams end, requests in flight get up to 3 s while pg-boss gets up to 5 s, and the process exits 0; not done within 8 s, it exits 1

edgeweir-healthcheck: with ROLE=worker it returns 0; other roles request http://127.0.0.1:${PORT}/healthz (PORT default 3000) with a 2-second timeout and return non-zero on failure.

ROLE

ValueComponents
all (default)Web and API, node channel, pg-boss worker
appWeb and API, node channel
workerpg-boss worker; no listeners

Scaling: Deployment overview.

Account recovery

dist/server/recover.js resets the password of the console's only account, turns off its two-factor authentication or clears the login IP allow list, for when signing in is no longer possible. It reads the console's environment variables (DATABASE_URL, EDGEWEIR_MASTER_KEY, …) and changes the database directly, not through the web UI or HTTP. Steps: Account recovery.

docker compose exec console node dist/server/recover.js --reset-password --disable-two-factor
DeploymentCommand
Docker Composedocker compose exec console node dist/server/recover.js <options>
Docker Compose, console container not runningdocker compose run --rm console node dist/server/recover.js <options>
宝塔 / aaPanel (deploy.sh)docker exec -it edgeweir-console node dist/server/recover.js <options>
Sourcepnpm --filter @edgeweir/console recover <options>; see Commands

Options

OptionEffect
--reset-passwordSets a new password, 12–128 characters
--disable-two-factorTurns two-factor authentication off and deletes the TOTP secret and backup codes
--clear-login-allowlistClears the login IP allow list: every address may sign in again
-h, --helpPrints the usage to standard output

Give at least one of --reset-password, --disable-two-factor, --clear-login-allowlist.

New password

Standard inputRead as
Terminal (allocated by default by docker compose exec and docker exec -it)Prompts New password: and Repeat new password: without echo; nothing changes when they differ. Ctrl-C cancels
Pipe or fileThe first line, without a trailing \n or \r\n; empty fails
docker compose exec -T console node dist/server/recover.js --reset-password < new-password.txt

-T allocates no terminal; use it only with a pipe or file: typed at a terminal, the password would be shown on screen. The password is never taken from a command-line argument or environment variable: arguments are visible in the process list and the shell history.

Result

The changes and the audit entry commit in one transaction; any failure rolls back all of them:

ChangeDescription
PasswordHashed by better-auth (scrypt) into the account's password credential
Two-factor authenticationOff; TOTP secret and backup codes deleted
Login IP allow listRemoved
SessionsEvery session of the account deleted, with pending two-factor sign-ins and trusted-device records
Audit logaccount.recover, actor system (name recover); metadata passwordReset, twoFactorDisabled, sessionsRevoked, and loginAllowListCleared (the ranges before clearing) when the allow list is cleared

Name, e-mail, passkeys and AccessKeys stay. Standard output shows the account's name and e-mail and what was done, never the password, its hash or a session token:

Account: Ops <admin@example.com>
Password reset.
Two-factor authentication turned off.
Signed out 2 sessions.
OperationOutput
--disable-two-factorTwo-factor authentication turned off.; Two-factor authentication was already off. when it was not on
--clear-login-allowlistLogin allow list cleared (N ranges).; The login allow list was already off. when it was empty
SessionsSigned out N sessions. (always)

Exit codes

Exit codeMeaning
0Done, or -h, --help
1Nothing changed: no account (setup not done), password length out of range, the two entries differ, no password on standard input, cancelled, invalid configuration, database connection or write failed; stderr prints error: and the reason
2Unknown option, extra argument or no operation; stderr prints the usage

Development

Requirements: Node.js 24.11.0 or later, pnpm 12.6.0, Docker; helpers/certd and pnpm e2e also need Go 1.27.2. buf comes with the development dependencies.

Run locally

  1. Install dependencies.

    pnpm install
  2. Start the development database (compose.dev.yml, port in DEV_POSTGRES_PORT).

    docker compose -f compose.dev.yml up -d
  3. Create .env and set EDGEWEIR_MASTER_KEY (openssl rand -base64 32). The template's DATABASE_URL matches the development database.

    cp .env.example .env
  4. Start the console.

    pnpm dev
  5. Check.

    curl -s http://localhost:3000/healthz

    Expected output: {"status":"ok","version":"dev"}.

Issuing certificates needs the certificate helper: cd helpers/certd && go build -o bin/edgeweir-certd ., then put its absolute path in EDGEWEIR_CERTD_BIN.

Commands

Run in the repository root.

CommandEffect
pnpm devAPI, node channel and Vite HMR in one process; reads .env in the repository root when present; web on PORT
pnpm buildTurborepo build of every package; the console goes to apps/console/dist
pnpm typecheckType check
pnpm testVitest; the database is PGlite, no Docker needed
pnpm lintbiome check ., buf lint proto and knip
pnpm formatbiome check --write .
pnpm proto:lintbuf lint proto
pnpm proto:breakingChecks proto/ for breaking changes (scripts/proto-breaking.sh)
pnpm proto:genGenerates packages/proto/src/gen from proto/
pnpm db:generateGenerates SQL migrations from packages/db/src/schema into packages/db/migrations (drizzle-kit)
pnpm e2eRuns scripts/e2e.sh
pnpm --filter @edgeweir/console startRuns the built dist/server/main.js
pnpm --filter @edgeweir/console recover <options>Account recovery from source; reads .env in the repository root when present. No -- before the options
pnpm --filter @edgeweir/console test:e2ePlaywright tests

End-to-end tests

scripts/e2e.sh runs against compose.e2e.yml. It needs curl, jq, docker and node; the installer step also needs goreleaser v2, syft, Go 1.27.2 and the sibling edgeweir-node checkout, the signed upgrade step cosign v3.1.3; the run needs access to deb.debian.org and openresty.org.

docker compose -f compose.e2e.yml up -d --build
pnpm e2e
ArgumentEffect
--upRuns docker compose -f compose.e2e.yml up -d --build first
--downRuns docker compose -f compose.e2e.yml --profile '*' down -v at the end, removing the profile services and their volumes too
--skip-uiSkips the Playwright browser tests
--only <section,…>Runs the named sections, and on a fresh stack the sections they need
--from <section>Runs from that section to the end
--listLists the sections with what each needs
--planPrints the sections a run would take, then exits
--serialNo parallel lanes: every section in turn

Arguments go after the script: bash scripts/e2e.sh --up --down; an unknown argument exits 2. A fresh stack runs the core section first; on a stack that got past core, the run continues where it stopped (.e2e/run.env, .e2e/run.done). Every section's time is printed at the end and kept in .e2e/timings.tsv.

VariableDefaultEffect
COMPOSE_PROJECT_NAMEedgeweir-e2eCompose project name
E2E_CONSOLE_PORT13000Console host port
E2E_NODE_PORT18080Node HTTP host port
E2E_NODE_TLS_PORT18443Node HTTPS host port (TCP, UDP)
E2E_TAGe2eTag of the built images
E2E_SUBNET172.28.213.0/24Default network's subnet; the script adds it to the origin allow list
E2E_ISOLATED_SUBNET172.28.214.0/24Isolated network's subnet; stays off the allow list
E2E_INSTALL_IMAGEdebian:bookworm-slim@sha256:…Clean system image for testing install.sh
E2E_ANALYTICSliteThe console's EDGEWEIR_ANALYTICS
E2E_STATS_INTERVAL5sStatistics report interval of the test nodes
E2E_CLICKHOUSE_PORT19123ClickHouse HTTP port, bound to 127.0.0.1
E2E_ACME_PORT14000Pebble ACME port, bound to 127.0.0.1
E2E_ACME_MGMT_PORT15000Pebble management port, bound to 127.0.0.1
E2E_MOCK_PORT19090Mock service port
EDGEWEIR_NODE_CONTEXT../edgeweir-nodeedgeweir-node source directory

For a second stack on the same machine, change COMPOSE_PROJECT_NAME, the ports, E2E_TAG, E2E_SUBNET and E2E_ISOLATED_SUBNET.

Edit on GitHub

On this page