create-freeholder 0.2.0-beta.4 → 0.2.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/template/.changeset/native-linux-install.md +6 -0
- package/dist/template/.changeset/public-beta-5.md +4 -0
- package/dist/template/.github/ISSUE_TEMPLATE/bug_report.yml +1 -1
- package/dist/template/.github/workflows/release-tarballs.yml +117 -0
- package/dist/template/AGENTS.md +15 -2
- package/dist/template/Dockerfile +3 -0
- package/dist/template/MASTER.md +34 -4
- package/dist/template/README.md +1 -1
- package/dist/template/deploy/README.md +26 -9
- package/dist/template/deploy/docker-selfhost/.env.example +11 -1
- package/dist/template/deploy/docker-selfhost/README.md +78 -50
- package/dist/template/deploy/docker-selfhost/infra/backup.sh +81 -0
- package/dist/template/deploy/docker-selfhost/infra/compose.https.yml +37 -1
- package/dist/template/deploy/docker-selfhost/infra/compose.yml +37 -1
- package/dist/template/deploy/docker-selfhost/migrate.md +8 -5
- package/dist/template/deploy/docker-selfhost/recipe.yaml +9 -10
- package/dist/template/deploy/docker-selfhost/selfhost.sh +206 -0
- package/dist/template/deploy/docker-selfhost/verify.md +11 -4
- package/dist/template/deploy/f-criteria-matrix.md +15 -0
- package/dist/template/deploy/linux/.env.example +28 -0
- package/dist/template/deploy/linux/README.md +181 -0
- package/dist/template/deploy/linux/freeholder +655 -0
- package/dist/template/deploy/linux/install.sh +173 -0
- package/dist/template/deploy/linux/migrate.md +17 -0
- package/dist/template/deploy/linux/recipe.yaml +50 -0
- package/dist/template/deploy/linux/share/Caddyfile.template +19 -0
- package/dist/template/deploy/linux/share/systemd/freeholder-backup.service +13 -0
- package/dist/template/deploy/linux/share/systemd/freeholder-backup.timer +12 -0
- package/dist/template/deploy/linux/share/systemd/freeholder.service +41 -0
- package/dist/template/deploy/linux/verify.md +22 -0
- package/dist/template/gitignore.template +1 -0
- package/dist/template/package.json +3 -2
- package/dist/template/packages/cli/package.json +1 -1
- package/dist/template/packages/create-freeholder/package.json +1 -1
- package/dist/template/packages/freeholder-app/package.json +1 -1
- package/dist/template/packages/mobile-app/package.json +1 -1
- package/dist/template/packages/plugin-kit/package.json +1 -1
- package/dist/template/packages/sdk/package.json +1 -1
- package/dist/template/packages/sdk/src/version.ts +1 -1
- package/dist/template/packages/templates/package.json +1 -1
- package/dist/template/scripts/build-release.d.mts +4 -0
- package/dist/template/scripts/build-release.mjs +171 -0
- package/dist/template/scripts/launch-prepare.mjs +6 -3
- package/dist/template/scripts/recipe-matrix.sh +22 -7
- package/dist/template/security/adversarial-audit-2026-10-08.md +1 -1
- package/dist/template/src/adapters/storage/local-mode.ts +54 -0
- package/dist/template/src/adapters/storage/local.ts +53 -26
- package/dist/template/src/core/doctor/index.ts +19 -10
- package/dist/template/src/core/env.ts +6 -1
- package/dist/template/src/core/update/preflight.ts +3 -2
- package/dist/template/src/core/update/release-declaration.json +1 -1
- package/dist/template/src/core/update/service.ts +7 -17
- package/dist/template/tests/core/agent-launch.test.ts +7 -2
- package/dist/template/tests/core/client-readiness-security.test.ts +3 -1
- package/dist/template/tests/core/deploy-recipe.test.ts +54 -4
- package/dist/template/tests/core/linux-install.test.ts +169 -0
- package/dist/template/tests/core/local-storage-mode.test.ts +29 -0
- package/dist/template/tests/core/storage.test.ts +38 -2
- package/dist/template-manifest.json +168 -63
- package/package.json +1 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Copyright (C) 2026 Tony Aly
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
#
|
|
5
|
+
# Install Freeholder on a plain Ubuntu or Debian server, without Docker (C3.44).
|
|
6
|
+
#
|
|
7
|
+
# curl -fsSLO https://github.com/CampDenman/freeholder/releases/download/vVERSION/install.sh
|
|
8
|
+
# sudo sh install.sh # asks for your domain, or uses a temporary address
|
|
9
|
+
# sudo sh install.sh --domain example.com # no questions
|
|
10
|
+
#
|
|
11
|
+
# Read it first; it is meant to be read. What it does, in order:
|
|
12
|
+
# 1. Installs PostgreSQL (distribution package, or the official PostgreSQL
|
|
13
|
+
# apt repository when the distribution's is older than 15), Caddy (the
|
|
14
|
+
# official Caddy apt repository), curl and openssl.
|
|
15
|
+
# 2. Creates a `freeholder` system user.
|
|
16
|
+
# 3. Downloads the release tarball for this machine (it bundles its own
|
|
17
|
+
# Node.js runtime), checks its SHA-256, and unpacks it to
|
|
18
|
+
# /opt/freeholder/releases/VERSION with /opt/freeholder/current pointing
|
|
19
|
+
# at it.
|
|
20
|
+
# 4. Hands over to `freeholder setup` from that release, which creates the
|
|
21
|
+
# database, generates secrets with openssl into /etc/freeholder (mode 640),
|
|
22
|
+
# writes the systemd units, the Caddyfile and the nightly backup timer,
|
|
23
|
+
# starts everything and prints your private claim link.
|
|
24
|
+
#
|
|
25
|
+
# Running it again is safe: it keeps existing secrets, data and settings.
|
|
26
|
+
# Everything it creates is listed in deploy/linux/README.md, including how to
|
|
27
|
+
# remove it.
|
|
28
|
+
set -eu
|
|
29
|
+
|
|
30
|
+
# Bumped with every release (tests/core/linux-install.test.ts checks it
|
|
31
|
+
# matches package.json), so a downloaded install.sh installs its own release.
|
|
32
|
+
FREEHOLDER_VERSION_DEFAULT="0.2.0-beta.5"
|
|
33
|
+
REPOSITORY="CampDenman/freeholder"
|
|
34
|
+
|
|
35
|
+
say() { printf 'freeholder: %s\n' "$*"; }
|
|
36
|
+
die() { printf 'freeholder: error: %s\n' "$*" >&2; exit 1; }
|
|
37
|
+
|
|
38
|
+
usage() {
|
|
39
|
+
cat <<'USAGE'
|
|
40
|
+
Usage: sudo sh install.sh [options]
|
|
41
|
+
|
|
42
|
+
--domain NAME The site's domain. Without it you are asked, and an empty
|
|
43
|
+
answer uses a temporary https://<ip>.sslip.io address
|
|
44
|
+
until you run `freeholder domain NAME`.
|
|
45
|
+
--email ADDRESS Optional address Let's Encrypt may contact about the
|
|
46
|
+
certificate.
|
|
47
|
+
--storage local|s3 Where uploaded media lives (default: local, on this
|
|
48
|
+
server under /var/lib/freeholder/media, included in the
|
|
49
|
+
nightly backup). s3 asks for a bucket and key.
|
|
50
|
+
--version VERSION Release to install (default: this script's release).
|
|
51
|
+
--tarball FILE Install from a downloaded tarball; FILE.sha256 must sit
|
|
52
|
+
beside it.
|
|
53
|
+
--yes Never ask; use defaults for anything not given.
|
|
54
|
+
--help Show this.
|
|
55
|
+
USAGE
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
version="$FREEHOLDER_VERSION_DEFAULT"
|
|
59
|
+
tarball=""
|
|
60
|
+
setup_args=""
|
|
61
|
+
while [ $# -gt 0 ]; do
|
|
62
|
+
case "$1" in
|
|
63
|
+
--domain|--email|--storage)
|
|
64
|
+
[ $# -ge 2 ] || die "$1 needs a value"
|
|
65
|
+
setup_args="$setup_args $1 $2"; shift 2 ;;
|
|
66
|
+
--version) [ $# -ge 2 ] || die "--version needs a value"; version="${2#v}"; shift 2 ;;
|
|
67
|
+
--tarball) [ $# -ge 2 ] || die "--tarball needs a file"; tarball="$2"; shift 2 ;;
|
|
68
|
+
--yes) setup_args="$setup_args --yes"; shift ;;
|
|
69
|
+
--help|-h) usage; exit 0 ;;
|
|
70
|
+
*) die "unknown option $1 (see --help)" ;;
|
|
71
|
+
esac
|
|
72
|
+
done
|
|
73
|
+
case "$version" in
|
|
74
|
+
*[!0-9A-Za-z.-]*|"") die "not a release version: $version" ;;
|
|
75
|
+
esac
|
|
76
|
+
|
|
77
|
+
[ "$(id -u)" = 0 ] || die "run it as root: sudo sh install.sh"
|
|
78
|
+
[ -r /etc/os-release ] || die "this installer supports Ubuntu and Debian"
|
|
79
|
+
. /etc/os-release
|
|
80
|
+
case "${ID:-} ${ID_LIKE:-}" in
|
|
81
|
+
*ubuntu*|*debian*) ;;
|
|
82
|
+
*) die "this installer supports Ubuntu and Debian (found ${PRETTY_NAME:-unknown}); see deploy/README.md for other hosts" ;;
|
|
83
|
+
esac
|
|
84
|
+
command -v systemctl >/dev/null 2>&1 || die "systemd is required"
|
|
85
|
+
case "$(uname -m)" in
|
|
86
|
+
x86_64|amd64) arch=x64 ;;
|
|
87
|
+
aarch64|arm64) arch=arm64 ;;
|
|
88
|
+
*) die "release tarballs exist for x86_64 and arm64, not $(uname -m)" ;;
|
|
89
|
+
esac
|
|
90
|
+
memory_kb=$(awk '/^MemTotal:/ {print $2}' /proc/meminfo)
|
|
91
|
+
if [ "${memory_kb:-0}" -lt 1800000 ]; then
|
|
92
|
+
say "warning: this server has less than 2 GB of memory; Freeholder and PostgreSQL need about 1 GB together and more as the site grows."
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
export DEBIAN_FRONTEND=noninteractive
|
|
96
|
+
apt_updated=""
|
|
97
|
+
apt_update() { [ -n "$apt_updated" ] || { apt-get update -q; apt_updated=1; }; }
|
|
98
|
+
apt_install() { apt_update; apt-get install -y -q --no-install-recommends "$@"; }
|
|
99
|
+
|
|
100
|
+
say "installing curl, openssl and PostgreSQL"
|
|
101
|
+
apt_install ca-certificates curl openssl gnupg tar gzip postgresql-common
|
|
102
|
+
|
|
103
|
+
# PostgreSQL 15 or newer. Ubuntu 24.04 and Debian 12 ship it; older releases
|
|
104
|
+
# use the PostgreSQL project's own apt repository, set up by the script that
|
|
105
|
+
# Debian's postgresql-common package provides for exactly this.
|
|
106
|
+
pg_package=postgresql
|
|
107
|
+
candidate=$(apt-cache policy postgresql | awk '/Candidate:/ {print $2}')
|
|
108
|
+
candidate_major=${candidate%%+*}
|
|
109
|
+
case "$candidate_major" in
|
|
110
|
+
''|*[!0-9]*) candidate_major=0 ;;
|
|
111
|
+
esac
|
|
112
|
+
if [ "$candidate_major" -lt 15 ]; then
|
|
113
|
+
say "this distribution's PostgreSQL is older than 15; adding the official PostgreSQL apt repository"
|
|
114
|
+
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
|
|
115
|
+
apt_updated=""
|
|
116
|
+
pg_package=postgresql-16
|
|
117
|
+
fi
|
|
118
|
+
apt_install "$pg_package"
|
|
119
|
+
systemctl enable --now postgresql >/dev/null
|
|
120
|
+
|
|
121
|
+
if ! command -v caddy >/dev/null 2>&1; then
|
|
122
|
+
say "installing Caddy from its official apt repository"
|
|
123
|
+
keyring=/usr/share/keyrings/caddy-stable-archive-keyring.gpg
|
|
124
|
+
curl -fsSL https://dl.cloudsmith.io/public/caddy/stable/gpg.key | gpg --batch --yes --dearmor -o "$keyring"
|
|
125
|
+
chmod 644 "$keyring"
|
|
126
|
+
curl -fsSL https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt > /etc/apt/sources.list.d/caddy-stable.list
|
|
127
|
+
apt_updated=""
|
|
128
|
+
apt_install caddy
|
|
129
|
+
fi
|
|
130
|
+
|
|
131
|
+
if ! id freeholder >/dev/null 2>&1; then
|
|
132
|
+
say "creating the freeholder system user"
|
|
133
|
+
useradd --system --user-group --home-dir /var/lib/freeholder --shell /usr/sbin/nologin freeholder
|
|
134
|
+
fi
|
|
135
|
+
install -d -m 755 -o root -g root /opt/freeholder /opt/freeholder/releases
|
|
136
|
+
|
|
137
|
+
name="freeholder-${version}-linux-${arch}"
|
|
138
|
+
release="/opt/freeholder/releases/${version}"
|
|
139
|
+
if [ ! -x "$release/bin/freeholder" ]; then
|
|
140
|
+
work=$(mktemp -d)
|
|
141
|
+
trap 'rm -rf "$work"' EXIT
|
|
142
|
+
if [ -n "$tarball" ]; then
|
|
143
|
+
[ -f "$tarball" ] && [ -f "$tarball.sha256" ] || die "--tarball needs FILE and FILE.sha256"
|
|
144
|
+
cp "$tarball" "$work/$name.tar.gz"
|
|
145
|
+
cp "$tarball.sha256" "$work/$name.tar.gz.sha256"
|
|
146
|
+
else
|
|
147
|
+
base="https://github.com/${REPOSITORY}/releases/download/v${version}"
|
|
148
|
+
say "downloading $name"
|
|
149
|
+
curl -fsSL --retry 3 -o "$work/$name.tar.gz" "$base/$name.tar.gz"
|
|
150
|
+
curl -fsSL --retry 3 -o "$work/$name.tar.gz.sha256" "$base/$name.tar.gz.sha256"
|
|
151
|
+
fi
|
|
152
|
+
expected=$(awk '{print $1; exit}' "$work/$name.tar.gz.sha256")
|
|
153
|
+
actual=$(sha256sum "$work/$name.tar.gz" | awk '{print $1}')
|
|
154
|
+
[ -n "$expected" ] && [ "$expected" = "$actual" ] || die "checksum mismatch for $name.tar.gz; nothing was installed"
|
|
155
|
+
say "checksum verified ($actual)"
|
|
156
|
+
tar -xzf "$work/$name.tar.gz" -C "$work"
|
|
157
|
+
top=$(tar -tzf "$work/$name.tar.gz" | head -1 | cut -d/ -f1)
|
|
158
|
+
[ -x "$work/$top/bin/freeholder" ] && [ -x "$work/$top/runtime/node/bin/node" ] || die "the tarball is not a Freeholder release"
|
|
159
|
+
rm -rf "$release.partial"
|
|
160
|
+
mv "$work/$top" "$release.partial"
|
|
161
|
+
chown -R root:root "$release.partial"
|
|
162
|
+
mv "$release.partial" "$release"
|
|
163
|
+
rm -rf "$work"
|
|
164
|
+
trap - EXIT
|
|
165
|
+
fi
|
|
166
|
+
if [ ! -e /opt/freeholder/current ]; then
|
|
167
|
+
ln -sfn "releases/${version}" /opt/freeholder/current.new
|
|
168
|
+
mv -T /opt/freeholder/current.new /opt/freeholder/current
|
|
169
|
+
fi
|
|
170
|
+
ln -sfn /opt/freeholder/current/bin/freeholder /usr/local/bin/freeholder
|
|
171
|
+
|
|
172
|
+
# shellcheck disable=SC2086 # setup_args is a list of words built above.
|
|
173
|
+
exec "$release/bin/freeholder" setup $setup_args
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Migrate to or from a Linux server
|
|
2
|
+
|
|
3
|
+
Target: `linux`
|
|
4
|
+
|
|
5
|
+
Follow the complete [Tier-1 migration runbook](../migration-runbook.md).
|
|
6
|
+
|
|
7
|
+
- **Out:** `sudo freeholder backup` writes `database.dump` (PostgreSQL custom
|
|
8
|
+
format) and `media.tar.gz`, whose paths are the storage keys. Restore the
|
|
9
|
+
dump on the target with `pg_restore --no-owner`, and copy the media to the
|
|
10
|
+
target's bucket with the same keys, for example
|
|
11
|
+
`rclone copy /var/lib/freeholder/media remote:bucket`.
|
|
12
|
+
- **In:** copy a backup directory from another Linux install (or build one: a
|
|
13
|
+
`pg_dump --format=custom` as `database.dump`, the bucket's objects as
|
|
14
|
+
`media/` inside `media.tar.gz`, and `sha256sum ./* > SHA256SUMS`) and run
|
|
15
|
+
`sudo freeholder restore /path/to/that-directory`.
|
|
16
|
+
- Keep `/etc/freeholder/freeholder.env` from the source: `CREDENTIAL_KEY`
|
|
17
|
+
decrypts stored provider credentials, and a new one cannot read them.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Copyright (C) 2026 Tony Aly
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
# C3.44: Freeholder on a plain Ubuntu/Debian server, no Docker.
|
|
4
|
+
name: linux
|
|
5
|
+
schema: freeholder-deploy-recipe/v1
|
|
6
|
+
tier: 2
|
|
7
|
+
maintainers: ["@tonyaly"]
|
|
8
|
+
freeholder_min_version: "0.2.0-beta.5"
|
|
9
|
+
provides:
|
|
10
|
+
database: distro-postgres
|
|
11
|
+
storage: local-disk-or-s3
|
|
12
|
+
jobs: web-process
|
|
13
|
+
cron: systemd-timer
|
|
14
|
+
estimated_monthly_cost_usd: { min: 6, typical: 24 }
|
|
15
|
+
limits:
|
|
16
|
+
- "One server: local-disk media cannot be shared by a second app server; move media to S3 before scaling out"
|
|
17
|
+
- "Ubuntu 22.04+ or Debian 12+ with systemd, on x86_64 or arm64"
|
|
18
|
+
- "Media and the database are on the server's disk: keep the nightly backups somewhere else too (BACKUP_RCLONE_REMOTE)"
|
|
19
|
+
artifacts:
|
|
20
|
+
- deploy/linux/install.sh
|
|
21
|
+
- deploy/linux/freeholder
|
|
22
|
+
- deploy/linux/share/systemd/freeholder.service
|
|
23
|
+
- deploy/linux/share/systemd/freeholder-backup.service
|
|
24
|
+
- deploy/linux/share/systemd/freeholder-backup.timer
|
|
25
|
+
- deploy/linux/share/Caddyfile.template
|
|
26
|
+
- scripts/build-release.mjs
|
|
27
|
+
required_environment:
|
|
28
|
+
- APP_URL
|
|
29
|
+
- DATABASE_URL
|
|
30
|
+
- BOOTSTRAP_SECRET
|
|
31
|
+
- SESSION_SECRET
|
|
32
|
+
- CREDENTIAL_KEY
|
|
33
|
+
- FREEHOLDER_STORAGE
|
|
34
|
+
- LOCAL_STORAGE_ROOT
|
|
35
|
+
operations:
|
|
36
|
+
install: "sudo sh install.sh --domain $FREEHOLDER_DOMAIN"
|
|
37
|
+
verify: "sudo freeholder status"
|
|
38
|
+
backup: "sudo freeholder backup"
|
|
39
|
+
restore: "sudo freeholder restore latest"
|
|
40
|
+
migrate-in: "sudo freeholder restore /path/to/backup-directory"
|
|
41
|
+
migrate-out: "sudo freeholder backup && sudo ls /var/lib/freeholder/backups"
|
|
42
|
+
update: "sudo freeholder update $FREEHOLDER_VERSION"
|
|
43
|
+
rollback: "sudo freeholder rollback"
|
|
44
|
+
update:
|
|
45
|
+
# The release tarball plays the image: a new one is unpacked beside the
|
|
46
|
+
# old, `current` is switched, and a failed health check switches back.
|
|
47
|
+
strategy: image-swap
|
|
48
|
+
rollback: previous release directory plus the pre-update database backup
|
|
49
|
+
automatable: false
|
|
50
|
+
tested_on: "2026-11-06"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Copyright (C) 2026 Tony Aly
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
# managed-by-freeholder: `freeholder setup` and `freeholder domain` rewrite
|
|
4
|
+
# this file. Caddy obtains and renews the HTTPS certificate itself; the
|
|
5
|
+
# domain must resolve to this server with ports 80 and 443 open.
|
|
6
|
+
__GLOBAL__
|
|
7
|
+
__DOMAIN__ {
|
|
8
|
+
encode zstd gzip
|
|
9
|
+
# C11.10: Next's image optimizer is off (images.unoptimized); refuse its
|
|
10
|
+
# endpoint at the edge too (GHSA-2464-fhr4-w9xw).
|
|
11
|
+
@nextImage path /_next/image /_next/image/*
|
|
12
|
+
respond @nextImage 404
|
|
13
|
+
# C11.10: the connecting address, overwritten on every request. The app
|
|
14
|
+
# trusts it because TRUSTED_CLIENT_IP_HEADER names it and the app listens
|
|
15
|
+
# only on 127.0.0.1.
|
|
16
|
+
reverse_proxy 127.0.0.1:3000 {
|
|
17
|
+
header_up X-Freeholder-Client-Ip {client_ip}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright (C) 2026 Tony Aly
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
# C3.44: nightly database and media backup (freeholder-backup.timer).
|
|
4
|
+
[Unit]
|
|
5
|
+
Description=Freeholder nightly backup
|
|
6
|
+
After=postgresql.service
|
|
7
|
+
|
|
8
|
+
[Service]
|
|
9
|
+
Type=oneshot
|
|
10
|
+
ExecStart=/usr/local/bin/freeholder backup --scheduled
|
|
11
|
+
UMask=0077
|
|
12
|
+
Nice=10
|
|
13
|
+
IOSchedulingClass=idle
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Copyright (C) 2026 Tony Aly
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
# C3.44: the Freeholder web process on a native Linux install. Migrations run
|
|
4
|
+
# inside this process before it reports ready (instrumentation.node.ts), the
|
|
5
|
+
# same as the container image, so there is no separate migration unit that
|
|
6
|
+
# could run a different release's migrations.
|
|
7
|
+
[Unit]
|
|
8
|
+
Description=Freeholder
|
|
9
|
+
Documentation=https://github.com/CampDenman/freeholder/blob/main/deploy/linux/README.md
|
|
10
|
+
After=network-online.target postgresql.service
|
|
11
|
+
Wants=network-online.target postgresql.service
|
|
12
|
+
|
|
13
|
+
[Service]
|
|
14
|
+
Type=simple
|
|
15
|
+
User=freeholder
|
|
16
|
+
Group=freeholder
|
|
17
|
+
EnvironmentFile=/etc/freeholder/freeholder.env
|
|
18
|
+
Environment=NODE_ENV=production NEXT_MANUAL_SIG_HANDLE=true PORT=3000 HOSTNAME=127.0.0.1
|
|
19
|
+
WorkingDirectory=/opt/freeholder/current/app
|
|
20
|
+
ExecStart=/opt/freeholder/current/runtime/node/bin/node server.js
|
|
21
|
+
Restart=always
|
|
22
|
+
RestartSec=5
|
|
23
|
+
TimeoutStopSec=45
|
|
24
|
+
UMask=0027
|
|
25
|
+
LimitNOFILE=65536
|
|
26
|
+
# The release is root-owned and read-only to the service; it may write only
|
|
27
|
+
# its data directory (media, Next's cache).
|
|
28
|
+
NoNewPrivileges=yes
|
|
29
|
+
ProtectSystem=strict
|
|
30
|
+
ProtectHome=yes
|
|
31
|
+
PrivateTmp=yes
|
|
32
|
+
PrivateDevices=yes
|
|
33
|
+
ReadWritePaths=/var/lib/freeholder
|
|
34
|
+
ProtectKernelTunables=yes
|
|
35
|
+
ProtectKernelModules=yes
|
|
36
|
+
ProtectControlGroups=yes
|
|
37
|
+
RestrictSUIDSGID=yes
|
|
38
|
+
LockPersonality=yes
|
|
39
|
+
|
|
40
|
+
[Install]
|
|
41
|
+
WantedBy=multi-user.target
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Verify: Linux server (no Docker)
|
|
2
|
+
|
|
3
|
+
Also complete the shared [Tier-1 verification](../recipe-verification.md);
|
|
4
|
+
where it says "bucket", read "`/var/lib/freeholder/media`" for local storage.
|
|
5
|
+
|
|
6
|
+
- [ ] `sudo freeholder status` passes every check: service, PostgreSQL, Caddy,
|
|
7
|
+
local readiness, HTTPS with a valid certificate, media directory, backup
|
|
8
|
+
timer and free disk. It is the Doctor for this recipe and needs no Node,
|
|
9
|
+
pnpm or checkout.
|
|
10
|
+
- [ ] `https://YOUR-DOMAIN` loads with no browser warning and a fresh
|
|
11
|
+
instance sends you to `/setup`.
|
|
12
|
+
- [ ] Only ports 22, 80 and 443 answer from outside. PostgreSQL listens on
|
|
13
|
+
localhost only (`ss -ltn | grep 5432` shows `127.0.0.1`), and so does the
|
|
14
|
+
app (`127.0.0.1:3000`).
|
|
15
|
+
- [ ] Upload an image, then `sudo ls -R /var/lib/freeholder/media`: it is
|
|
16
|
+
there, and `sudo systemctl restart freeholder` keeps it.
|
|
17
|
+
- [ ] `sudo freeholder backup` writes a directory under
|
|
18
|
+
`/var/lib/freeholder/backups` with `database.dump`, `media.tar.gz` and
|
|
19
|
+
`SHA256SUMS`.
|
|
20
|
+
- [ ] `sudo freeholder restore latest` brings the site back with the same
|
|
21
|
+
pages and media. **Do this once before you trust the backup.**
|
|
22
|
+
- [ ] `systemctl list-timers freeholder-backup.timer` shows the next run.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "freeholder",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "0.2.0-beta.
|
|
4
|
+
"version": "0.2.0-beta.5",
|
|
5
5
|
"description": "The open-source operating system for a one-person business (active development, not a release candidate) — the deployable monolith: public site + CMS, admin, unified CRM spine, commerce, booking, galleries, mail, analytics, MCP server",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": "Tony Aly <tony@paradisemodern.com> (https://tonyaly.com)",
|
|
@@ -49,7 +49,8 @@
|
|
|
49
49
|
"sdk:generate": "node scripts/generate-sdk.mjs",
|
|
50
50
|
"doctor": "node scripts/doctor.mjs",
|
|
51
51
|
"perf:budgets": "node scripts/performance-budgets.mjs",
|
|
52
|
-
"launch:prepare": "node scripts/launch-prepare.mjs"
|
|
52
|
+
"launch:prepare": "node scripts/launch-prepare.mjs",
|
|
53
|
+
"release:build": "node scripts/build-release.mjs"
|
|
53
54
|
},
|
|
54
55
|
"dependencies": {
|
|
55
56
|
"@formatjs/icu-messageformat-parser": "^3.5.21",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@freeholder/cli",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.5",
|
|
4
4
|
"description": "freeholder update and freeholder launch: keep a Freeholder site current, or stand up a new hosted one, from a terminal",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Tony Aly <tony@paradisemodern.com> (https://tonyaly.com)",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-freeholder",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.5",
|
|
4
4
|
"description": "npx create-freeholder \u2014 scaffold a Freeholder source project, check the environment, install, migrate, and print the setup URL",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Tony Aly <tony@paradisemodern.com> (https://tonyaly.com)",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "freeholder-app",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.5",
|
|
4
4
|
"description": "npx freeholder-app init \u2014 pull instance branding and write store-ready icons, splash, metadata and an auditable Expo config diff",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Tony Aly <tony@paradisemodern.com> (https://tonyaly.com)",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@freeholder/mobile-app",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.5",
|
|
4
4
|
"description": "White-label Expo/React Native app for a Freeholder instance's customers, driven entirely by the generated SDK",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Tony Aly <tony@paradisemodern.com> (https://tonyaly.com)",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@freeholder/plugin-kit",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.5",
|
|
4
4
|
"description": "Authoring contract for Freeholder plugins \u2014 definePlugin, permissions, compatibility (MASTER.md \u00a724, C3.08)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Tony Aly <tony@paradisemodern.com> (https://tonyaly.com)",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@freeholder/sdk",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.5",
|
|
4
4
|
"description": "Typed HTTP client for a Freeholder instance, generated from the live service registry",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Tony Aly <tony@paradisemodern.com> (https://tonyaly.com)",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@freeholder/templates",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.5",
|
|
4
4
|
"description": "Bench-token business presets with full page, entity and email trees for Freeholder",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Tony Aly <tony@paradisemodern.com> (https://tonyaly.com)",
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// Copyright (C) 2026 Tony Aly
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// C3.44: package a built Freeholder as a self-contained Linux release tarball
|
|
4
|
+
// that runs without Docker, Node or pnpm on the server.
|
|
5
|
+
//
|
|
6
|
+
// pnpm build && node scripts/build-release.mjs [--allow-dirty]
|
|
7
|
+
//
|
|
8
|
+
// The tarball holds the Next standalone server, its static assets, the
|
|
9
|
+
// migrations, the official Node runtime (checksum-verified against
|
|
10
|
+
// nodejs.org's SHASUMS256.txt), the `freeholder` operator command and the
|
|
11
|
+
// systemd/Caddy templates the installer writes. It is built for the machine's
|
|
12
|
+
// own architecture, because sharp's native binary in the standalone output is
|
|
13
|
+
// the build host's: linux-x64 on x64 runners, linux-arm64 on arm64 runners.
|
|
14
|
+
//
|
|
15
|
+
// Output in dist/release/: freeholder-<version>-linux-<arch>.tar.gz, its
|
|
16
|
+
// .sha256, and install.sh, which are the release assets the installer
|
|
17
|
+
// downloads.
|
|
18
|
+
import assert from "node:assert/strict";
|
|
19
|
+
import { execFileSync } from "node:child_process";
|
|
20
|
+
import { createHash } from "node:crypto";
|
|
21
|
+
import { chmod, cp, mkdir, readFile, rm, stat, writeFile, mkdtemp, readdir } from "node:fs/promises";
|
|
22
|
+
import { tmpdir } from "node:os";
|
|
23
|
+
import { join, resolve } from "node:path";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
25
|
+
|
|
26
|
+
const root = resolve(fileURLToPath(new URL("..", import.meta.url)));
|
|
27
|
+
const allowDirty = process.argv.includes("--allow-dirty");
|
|
28
|
+
const output = resolve(root, "dist", "release");
|
|
29
|
+
const nodeCache = resolve(root, ".tools", "node-runtime");
|
|
30
|
+
|
|
31
|
+
function run(command, args, options = {}) {
|
|
32
|
+
return execFileSync(command, args, { cwd: root, encoding: "utf8", ...options });
|
|
33
|
+
}
|
|
34
|
+
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
35
|
+
|
|
36
|
+
export function releaseArch(arch = process.arch) {
|
|
37
|
+
if (arch === "x64") return "x64";
|
|
38
|
+
if (arch === "arm64") return "arm64";
|
|
39
|
+
throw new Error(`Release tarballs are built for x64 and arm64 Linux, not ${arch}.`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function releaseName(version, arch) {
|
|
43
|
+
if (!/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/.test(version)) throw new Error(`Not a release version: ${version}`);
|
|
44
|
+
return `freeholder-${version}-linux-${releaseArch(arch)}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function download(url) {
|
|
48
|
+
const response = await fetch(url, { redirect: "follow" });
|
|
49
|
+
if (!response.ok) throw new Error(`Download of ${url} failed with HTTP ${response.status}`);
|
|
50
|
+
return Buffer.from(await response.arrayBuffer());
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The official Node binary for this release, verified and cached. */
|
|
54
|
+
async function nodeRuntime(version, arch) {
|
|
55
|
+
const name = `node-v${version}-linux-${arch}`;
|
|
56
|
+
const directory = resolve(nodeCache, name);
|
|
57
|
+
const recordPath = resolve(directory, "SOURCE.json");
|
|
58
|
+
try {
|
|
59
|
+
const record = JSON.parse(await readFile(recordPath, "utf8"));
|
|
60
|
+
assert.equal(record.archive, `${name}.tar.xz`);
|
|
61
|
+
assert.equal(record.binarySha256, sha256(await readFile(resolve(directory, "bin", "node"))));
|
|
62
|
+
return { directory, record };
|
|
63
|
+
} catch {
|
|
64
|
+
await rm(directory, { recursive: true, force: true });
|
|
65
|
+
await mkdir(nodeCache, { recursive: true });
|
|
66
|
+
}
|
|
67
|
+
const base = `https://nodejs.org/dist/v${version}`;
|
|
68
|
+
const archiveName = `${name}.tar.xz`;
|
|
69
|
+
const [archive, sums] = await Promise.all([download(`${base}/${archiveName}`), download(`${base}/SHASUMS256.txt`)]);
|
|
70
|
+
const line = sums.toString("utf8").split(/\r?\n/).find((entry) => entry.endsWith(` ${archiveName}`));
|
|
71
|
+
if (!line) throw new Error(`nodejs.org lists no checksum for ${archiveName}`);
|
|
72
|
+
const expected = line.split(/\s+/)[0];
|
|
73
|
+
assert.equal(sha256(archive), expected, "Node runtime checksum mismatch");
|
|
74
|
+
const temporary = await mkdtemp(join(tmpdir(), "freeholder-node-"));
|
|
75
|
+
try {
|
|
76
|
+
const archivePath = join(temporary, archiveName);
|
|
77
|
+
await writeFile(archivePath, archive);
|
|
78
|
+
run("tar", ["-xJf", archivePath, "-C", nodeCache, `${name}/bin/node`, `${name}/LICENSE`]);
|
|
79
|
+
} finally {
|
|
80
|
+
await rm(temporary, { recursive: true, force: true });
|
|
81
|
+
}
|
|
82
|
+
const record = {
|
|
83
|
+
version,
|
|
84
|
+
archive: archiveName,
|
|
85
|
+
archiveSha256: expected,
|
|
86
|
+
binarySha256: sha256(await readFile(resolve(directory, "bin", "node"))),
|
|
87
|
+
source: `${base}/${archiveName}`,
|
|
88
|
+
};
|
|
89
|
+
await writeFile(recordPath, `${JSON.stringify(record, null, 2)}\n`);
|
|
90
|
+
return { directory, record };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function exists(path) {
|
|
94
|
+
return stat(path).then(() => true, () => false);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function main() {
|
|
98
|
+
if (process.platform !== "linux") throw new Error("Build Linux release tarballs on Linux.");
|
|
99
|
+
const arch = releaseArch();
|
|
100
|
+
const dirty = run("git", ["status", "--porcelain"]).trim().length > 0;
|
|
101
|
+
if (dirty && !allowDirty) throw new Error("Refusing to package a dirty tree; commit first or pass --allow-dirty for a local test build.");
|
|
102
|
+
const pkg = JSON.parse(await readFile(resolve(root, "package.json"), "utf8"));
|
|
103
|
+
const version = pkg.version;
|
|
104
|
+
const commit = run("git", ["rev-parse", "HEAD"]).trim();
|
|
105
|
+
const nodeVersion = (await readFile(resolve(root, ".node-version"), "utf8")).trim();
|
|
106
|
+
const standalone = resolve(root, ".next", "standalone");
|
|
107
|
+
if (!(await exists(resolve(standalone, "server.js")))) throw new Error("Run pnpm build first: .next/standalone/server.js is missing.");
|
|
108
|
+
// sharp ships a per-architecture binary; a tarball carrying another
|
|
109
|
+
// machine's would fail on the first image upload, not at install.
|
|
110
|
+
const pnpmStore = await readdir(resolve(standalone, "node_modules", ".pnpm")).catch(() => []);
|
|
111
|
+
if (pnpmStore.some((entry) => entry.startsWith("sharp@")) && !pnpmStore.some((entry) => entry.startsWith(`@img+sharp-linux-${arch}@`))) {
|
|
112
|
+
throw new Error(`The standalone output has no sharp binary for linux-${arch}; build on a linux-${arch} machine.`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const name = releaseName(version, arch);
|
|
116
|
+
const stage = resolve(output, name);
|
|
117
|
+
await rm(stage, { recursive: true, force: true });
|
|
118
|
+
await mkdir(resolve(stage, "app", ".next"), { recursive: true });
|
|
119
|
+
// The same files the Docker runtime stage copies (Dockerfile).
|
|
120
|
+
await cp(standalone, resolve(stage, "app"), { recursive: true, verbatimSymlinks: true });
|
|
121
|
+
await cp(resolve(root, ".next", "static"), resolve(stage, "app", ".next", "static"), { recursive: true });
|
|
122
|
+
await cp(resolve(root, "public"), resolve(stage, "app", "public"), { recursive: true });
|
|
123
|
+
await cp(resolve(root, "db"), resolve(stage, "app", "db"), { recursive: true });
|
|
124
|
+
await mkdir(resolve(stage, "app", "scripts"), { recursive: true });
|
|
125
|
+
await cp(resolve(root, "scripts", "owner-password.mjs"), resolve(stage, "app", "scripts", "owner-password.mjs"));
|
|
126
|
+
// Next writes its runtime cache here. The installer points it at a
|
|
127
|
+
// directory the service may write, so the release itself stays read-only.
|
|
128
|
+
await rm(resolve(stage, "app", ".next", "cache"), { recursive: true, force: true });
|
|
129
|
+
|
|
130
|
+
const runtime = await nodeRuntime(nodeVersion, arch);
|
|
131
|
+
await mkdir(resolve(stage, "runtime", "node", "bin"), { recursive: true });
|
|
132
|
+
await cp(resolve(runtime.directory, "bin", "node"), resolve(stage, "runtime", "node", "bin", "node"));
|
|
133
|
+
await cp(resolve(runtime.directory, "LICENSE"), resolve(stage, "runtime", "node", "LICENSE"));
|
|
134
|
+
|
|
135
|
+
await mkdir(resolve(stage, "bin"), { recursive: true });
|
|
136
|
+
await cp(resolve(root, "deploy", "linux", "freeholder"), resolve(stage, "bin", "freeholder"));
|
|
137
|
+
await chmod(resolve(stage, "bin", "freeholder"), 0o755);
|
|
138
|
+
await cp(resolve(root, "deploy", "linux", "share"), resolve(stage, "share"), { recursive: true });
|
|
139
|
+
await cp(resolve(root, "deploy", "linux", "install.sh"), resolve(stage, "share", "install.sh"));
|
|
140
|
+
await cp(resolve(root, "LICENSE"), resolve(stage, "LICENSE"));
|
|
141
|
+
await cp(resolve(root, "NOTICE"), resolve(stage, "NOTICE"));
|
|
142
|
+
|
|
143
|
+
const release = {
|
|
144
|
+
schema: "freeholder/linux-release/v1",
|
|
145
|
+
version,
|
|
146
|
+
commit,
|
|
147
|
+
platform: `linux-${arch}`,
|
|
148
|
+
node: { version: nodeVersion, source: runtime.record.source, archiveSha256: runtime.record.archiveSha256 },
|
|
149
|
+
};
|
|
150
|
+
await writeFile(resolve(stage, "RELEASE.json"), `${JSON.stringify(release, null, 2)}\n`);
|
|
151
|
+
await writeFile(resolve(stage, "VERSION"), `${version}\n`);
|
|
152
|
+
|
|
153
|
+
const tarball = resolve(output, `${name}.tar.gz`);
|
|
154
|
+
// Root-owned, sorted and dated by the commit so two builds of one commit
|
|
155
|
+
// differ only where the toolchain does.
|
|
156
|
+
const date = run("git", ["show", "-s", "--format=%cI", "HEAD"]).trim();
|
|
157
|
+
run("tar", ["--sort=name", `--mtime=${date}`, "--owner=0", "--group=0", "--numeric-owner", "-czf", tarball, "-C", output, name]);
|
|
158
|
+
const digest = sha256(await readFile(tarball));
|
|
159
|
+
await writeFile(`${tarball}.sha256`, `${digest} ${name}.tar.gz\n`);
|
|
160
|
+
await cp(resolve(root, "deploy", "linux", "install.sh"), resolve(output, "install.sh"));
|
|
161
|
+
await rm(stage, { recursive: true, force: true });
|
|
162
|
+
const bytes = (await stat(tarball)).size;
|
|
163
|
+
console.log(`release: ${name}.tar.gz (${(bytes / 1048576).toFixed(1)} MB) sha256 ${digest}`);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
167
|
+
main().catch((error) => {
|
|
168
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
169
|
+
process.exitCode = 1;
|
|
170
|
+
});
|
|
171
|
+
}
|