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
|
@@ -25,7 +25,9 @@ services:
|
|
|
25
25
|
depends_on:
|
|
26
26
|
- app
|
|
27
27
|
app:
|
|
28
|
-
|
|
28
|
+
# The release this checkout belongs to (tests/core/linux-install.test.ts
|
|
29
|
+
# keeps it equal to package.json). Update: selfhost.sh update VERSION.
|
|
30
|
+
image: ${FREEHOLDER_IMAGE:-ghcr.io/campdenman/freeholder:0.2.0-beta.5}
|
|
29
31
|
restart: unless-stopped
|
|
30
32
|
# Not published to the host: Caddy is the only way in.
|
|
31
33
|
expose:
|
|
@@ -33,9 +35,15 @@ services:
|
|
|
33
35
|
env_file: ../.env
|
|
34
36
|
environment:
|
|
35
37
|
DATABASE_URL: postgres://freeholder:${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}@db:5432/freeholder
|
|
38
|
+
# C3.44: used when FREEHOLDER_STORAGE=local (the default from
|
|
39
|
+
# selfhost.sh prepare): media on the `media` volume, kept across image
|
|
40
|
+
# updates and included in the nightly backup.
|
|
41
|
+
LOCAL_STORAGE_ROOT: /var/lib/freeholder/media
|
|
36
42
|
# Caddy overwrites this header with the connecting address, and the app
|
|
37
43
|
# port is not published, so rate limits can tell visitors apart (C11.10).
|
|
38
44
|
TRUSTED_CLIENT_IP_HEADER: x-freeholder-client-ip
|
|
45
|
+
volumes:
|
|
46
|
+
- media:/var/lib/freeholder/media
|
|
39
47
|
depends_on:
|
|
40
48
|
db:
|
|
41
49
|
condition: service_healthy
|
|
@@ -64,7 +72,35 @@ services:
|
|
|
64
72
|
interval: 5s
|
|
65
73
|
timeout: 5s
|
|
66
74
|
retries: 20
|
|
75
|
+
# C3.44: nightly database and media backup into the `backups` volume,
|
|
76
|
+
# inside Compose so no host cron is needed. `selfhost.sh backup` runs one
|
|
77
|
+
# now and `selfhost.sh restore` restores one.
|
|
78
|
+
backup:
|
|
79
|
+
image: postgres:16-alpine
|
|
80
|
+
restart: unless-stopped
|
|
81
|
+
command: ["sh", "/usr/local/bin/freeholder-backup", "schedule"]
|
|
82
|
+
environment:
|
|
83
|
+
PGHOST: db
|
|
84
|
+
PGUSER: freeholder
|
|
85
|
+
PGDATABASE: freeholder
|
|
86
|
+
PGPASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}
|
|
87
|
+
BACKUP_HOUR_UTC: ${BACKUP_HOUR_UTC:-3}
|
|
88
|
+
BACKUP_KEEP: ${BACKUP_KEEP:-14}
|
|
89
|
+
volumes:
|
|
90
|
+
- ./backup.sh:/usr/local/bin/freeholder-backup:ro
|
|
91
|
+
# Not /media: Alpine ships one, and its contents would seed the volume.
|
|
92
|
+
- media:/srv/media
|
|
93
|
+
- backups:/backups
|
|
94
|
+
# After app: Docker gives a new named volume the ownership of the first
|
|
95
|
+
# container's mount point, and only the app image's is the app user's.
|
|
96
|
+
depends_on:
|
|
97
|
+
db:
|
|
98
|
+
condition: service_healthy
|
|
99
|
+
app:
|
|
100
|
+
condition: service_started
|
|
67
101
|
volumes:
|
|
68
102
|
pgdata:
|
|
103
|
+
media:
|
|
104
|
+
backups:
|
|
69
105
|
caddy_data:
|
|
70
106
|
caddy_config:
|
|
@@ -2,13 +2,21 @@
|
|
|
2
2
|
# SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
services:
|
|
4
4
|
app:
|
|
5
|
-
|
|
5
|
+
# The release this checkout belongs to (tests/core/linux-install.test.ts
|
|
6
|
+
# keeps it equal to package.json). Update: selfhost.sh update VERSION.
|
|
7
|
+
image: ${FREEHOLDER_IMAGE:-ghcr.io/campdenman/freeholder:0.2.0-beta.5}
|
|
6
8
|
restart: unless-stopped
|
|
7
9
|
ports:
|
|
8
10
|
- "3000:3000"
|
|
9
11
|
env_file: ../.env
|
|
10
12
|
environment:
|
|
11
13
|
DATABASE_URL: postgres://freeholder:${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}@db:5432/freeholder
|
|
14
|
+
# C3.44: used when FREEHOLDER_STORAGE=local (the default from
|
|
15
|
+
# selfhost.sh prepare): media on the `media` volume, kept across image
|
|
16
|
+
# updates and included in the nightly backup.
|
|
17
|
+
LOCAL_STORAGE_ROOT: /var/lib/freeholder/media
|
|
18
|
+
volumes:
|
|
19
|
+
- media:/var/lib/freeholder/media
|
|
12
20
|
depends_on:
|
|
13
21
|
db:
|
|
14
22
|
condition: service_healthy
|
|
@@ -37,5 +45,33 @@ services:
|
|
|
37
45
|
interval: 5s
|
|
38
46
|
timeout: 5s
|
|
39
47
|
retries: 20
|
|
48
|
+
# C3.44: nightly database and media backup into the `backups` volume,
|
|
49
|
+
# inside Compose so no host cron is needed. `selfhost.sh backup` runs one
|
|
50
|
+
# now and `selfhost.sh restore` restores one.
|
|
51
|
+
backup:
|
|
52
|
+
image: postgres:16-alpine
|
|
53
|
+
restart: unless-stopped
|
|
54
|
+
command: ["sh", "/usr/local/bin/freeholder-backup", "schedule"]
|
|
55
|
+
environment:
|
|
56
|
+
PGHOST: db
|
|
57
|
+
PGUSER: freeholder
|
|
58
|
+
PGDATABASE: freeholder
|
|
59
|
+
PGPASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}
|
|
60
|
+
BACKUP_HOUR_UTC: ${BACKUP_HOUR_UTC:-3}
|
|
61
|
+
BACKUP_KEEP: ${BACKUP_KEEP:-14}
|
|
62
|
+
volumes:
|
|
63
|
+
- ./backup.sh:/usr/local/bin/freeholder-backup:ro
|
|
64
|
+
# Not /media: Alpine ships one, and its contents would seed the volume.
|
|
65
|
+
- media:/srv/media
|
|
66
|
+
- backups:/backups
|
|
67
|
+
# After app: Docker gives a new named volume the ownership of the first
|
|
68
|
+
# container's mount point, and only the app image's is the app user's.
|
|
69
|
+
depends_on:
|
|
70
|
+
db:
|
|
71
|
+
condition: service_healthy
|
|
72
|
+
app:
|
|
73
|
+
condition: service_started
|
|
40
74
|
volumes:
|
|
41
75
|
pgdata:
|
|
76
|
+
media:
|
|
77
|
+
backups:
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Target: `docker-selfhost`
|
|
4
4
|
|
|
5
|
-
Follow the complete [Tier-1 migration runbook](../migration-runbook.md).
|
|
6
|
-
with the Compose Postgres service
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`
|
|
5
|
+
Follow the complete [Tier-1 migration runbook](../migration-runbook.md).
|
|
6
|
+
Restore with the Compose Postgres service (`selfhost.sh restore` takes a
|
|
7
|
+
backup directory in the `backups` volume with the same layout as the Linux
|
|
8
|
+
recipe's, so backups move between the two directly). Media goes to the
|
|
9
|
+
`media` volume with its storage keys as paths, or to the configured private
|
|
10
|
+
S3-compatible store; the local-development MinIO profile is not a migration
|
|
11
|
+
target. Keep the prior image in `PREVIOUS_FREEHOLDER_IMAGE` until database,
|
|
12
|
+
media and public URL checks pass.
|
|
@@ -7,32 +7,31 @@ maintainers: ["@tonyaly"]
|
|
|
7
7
|
freeholder_min_version: "0.0.0"
|
|
8
8
|
provides:
|
|
9
9
|
database: compose-postgres
|
|
10
|
-
storage:
|
|
10
|
+
storage: volume-or-s3
|
|
11
11
|
jobs: web-process
|
|
12
|
-
cron:
|
|
12
|
+
cron: compose-backup-service
|
|
13
13
|
estimated_monthly_cost_usd: { min: 0, typical: 20 }
|
|
14
14
|
limits:
|
|
15
|
-
- "
|
|
15
|
+
- "One server: media on the compose volume cannot be shared by a second app server; use S3 to scale out"
|
|
16
|
+
- "Copy the backups volume off the server; a backup on the same disk does not survive losing it"
|
|
16
17
|
- "MinIO is the local-dev profile only"
|
|
17
18
|
artifacts:
|
|
18
19
|
- deploy/docker-selfhost/infra/compose.yml
|
|
19
20
|
- deploy/docker-selfhost/infra/compose.https.yml
|
|
20
21
|
- deploy/docker-selfhost/infra/Caddyfile.https
|
|
22
|
+
- deploy/docker-selfhost/infra/backup.sh
|
|
23
|
+
- deploy/docker-selfhost/selfhost.sh
|
|
21
24
|
required_environment:
|
|
22
25
|
- POSTGRES_PASSWORD
|
|
23
26
|
- BOOTSTRAP_SECRET
|
|
24
27
|
- SESSION_SECRET
|
|
25
28
|
- CREDENTIAL_KEY
|
|
26
29
|
- APP_URL
|
|
27
|
-
-
|
|
28
|
-
- S3_ENDPOINT
|
|
29
|
-
- S3_REGION
|
|
30
|
-
- S3_ACCESS_KEY_ID
|
|
31
|
-
- S3_SECRET_ACCESS_KEY
|
|
30
|
+
- FREEHOLDER_STORAGE
|
|
32
31
|
operations:
|
|
33
32
|
install: "docker compose --env-file deploy/docker-selfhost/.env -f deploy/docker-selfhost/infra/compose.yml up -d"
|
|
34
33
|
install-https: "docker compose --env-file deploy/docker-selfhost/.env -f deploy/docker-selfhost/infra/compose.https.yml up -d"
|
|
35
|
-
verify: "
|
|
34
|
+
verify: "deploy/docker-selfhost/selfhost.sh check"
|
|
36
35
|
backup: "docker compose --env-file deploy/docker-selfhost/.env -f deploy/docker-selfhost/infra/compose.yml exec -T db pg_dump --format=custom --no-owner --no-privileges -U freeholder freeholder > freeholder.dump"
|
|
37
36
|
restore: "docker compose --env-file deploy/docker-selfhost/.env -f deploy/docker-selfhost/infra/compose.yml exec -T db pg_restore --no-owner --no-privileges -U freeholder -d freeholder < freeholder.dump"
|
|
38
37
|
migrate-in: "docker compose --env-file deploy/docker-selfhost/.env -f deploy/docker-selfhost/infra/compose.yml exec -T db pg_restore --no-owner --no-privileges -U freeholder -d freeholder < freeholder.dump && pnpm media:transfer -- --manifest ownership-export/media-manifest.json"
|
|
@@ -42,4 +41,4 @@ operations:
|
|
|
42
41
|
update:
|
|
43
42
|
strategy: image-swap
|
|
44
43
|
rollback: compose pull the previous tag
|
|
45
|
-
tested_on: "2026-
|
|
44
|
+
tested_on: "2026-11-06"
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Copyright (C) 2026 Tony Aly
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
#
|
|
5
|
+
# C3.44: run the Docker Compose recipe with only Docker and openssl on the
|
|
6
|
+
# host: no Node, pnpm or `pnpm install`. Run it from anywhere in a checkout:
|
|
7
|
+
#
|
|
8
|
+
# deploy/docker-selfhost/selfhost.sh prepare [--domain example.com] [--storage local|s3]
|
|
9
|
+
# deploy/docker-selfhost/selfhost.sh start
|
|
10
|
+
# deploy/docker-selfhost/selfhost.sh claim-link
|
|
11
|
+
#
|
|
12
|
+
# `pnpm launch:prepare --target docker-selfhost` writes the same .env and still
|
|
13
|
+
# works; this script exists so a server needs neither.
|
|
14
|
+
set -eu
|
|
15
|
+
|
|
16
|
+
here=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)
|
|
17
|
+
ENV_FILE="$here/.env"
|
|
18
|
+
REPOSITORY="CampDenman/freeholder"
|
|
19
|
+
|
|
20
|
+
say() { printf 'freeholder: %s\n' "$*"; }
|
|
21
|
+
warn() { printf 'freeholder: warning: %s\n' "$*" >&2; }
|
|
22
|
+
die() { printf 'freeholder: error: %s\n' "$*" >&2; exit 1; }
|
|
23
|
+
|
|
24
|
+
env_get() { [ -f "$ENV_FILE" ] && sed -n "s/^$1=//p" "$ENV_FILE" | tail -n 1 | sed -e 's/^"//' -e 's/"$//' || true; }
|
|
25
|
+
env_set() {
|
|
26
|
+
case "$2" in *[[:space:]\"\'\\]*) die "refusing to store a value for $1 with spaces, quotes or backslashes" ;; esac
|
|
27
|
+
tmp="$ENV_FILE.tmp.$$"
|
|
28
|
+
( umask 077; if [ -f "$ENV_FILE" ]; then grep -v "^$1=" "$ENV_FILE" > "$tmp" || true; else : > "$tmp"; fi )
|
|
29
|
+
printf '%s=%s\n' "$1" "$2" >> "$tmp"
|
|
30
|
+
chmod 600 "$tmp"
|
|
31
|
+
mv "$tmp" "$ENV_FILE"
|
|
32
|
+
}
|
|
33
|
+
ensure_secret() { [ -n "$(env_get "$1")" ] || env_set "$1" "$(openssl rand -hex 32)"; }
|
|
34
|
+
|
|
35
|
+
release_version() {
|
|
36
|
+
sed -n 's/^ "version": "\(.*\)",$/\1/p' "$here/../../package.json" | head -n 1
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
compose_file() {
|
|
40
|
+
case "$(env_get APP_URL)" in
|
|
41
|
+
https://*) echo "$here/infra/compose.https.yml" ;;
|
|
42
|
+
*) echo "$here/infra/compose.yml" ;;
|
|
43
|
+
esac
|
|
44
|
+
}
|
|
45
|
+
compose() { docker compose --env-file "$ENV_FILE" -f "$(compose_file)" "$@"; }
|
|
46
|
+
|
|
47
|
+
private_ipv4() {
|
|
48
|
+
case "$1" in
|
|
49
|
+
10.*|192.168.*|127.*|169.254.*|172.1[6-9].*|172.2[0-9].*|172.3[01].*) return 0 ;;
|
|
50
|
+
100.6[4-9].*|100.[7-9][0-9].*|100.1[01][0-9].*|100.12[0-7].*) return 0 ;;
|
|
51
|
+
esac
|
|
52
|
+
return 1
|
|
53
|
+
}
|
|
54
|
+
public_ipv4() {
|
|
55
|
+
ip=$(ip -4 route get 1.1.1.1 2>/dev/null | awk '{for (i = 1; i < NF; i++) if ($i == "src") {print $(i + 1); exit}}' || true)
|
|
56
|
+
if [ -z "$ip" ] || private_ipv4 "$ip"; then
|
|
57
|
+
ip=$(curl -4 -fsS --max-time 10 https://checkip.amazonaws.com 2>/dev/null | tr -d '[:space:]' || true)
|
|
58
|
+
fi
|
|
59
|
+
case "$ip" in *.*.*.*) printf '%s\n' "$ip" ;; *) return 1 ;; esac
|
|
60
|
+
}
|
|
61
|
+
sslip_host() { printf '%s.sslip.io\n' "$(printf '%s' "$1" | tr . -)"; }
|
|
62
|
+
|
|
63
|
+
cmd_prepare() {
|
|
64
|
+
domain="" storage="" local_only=""
|
|
65
|
+
while [ $# -gt 0 ]; do
|
|
66
|
+
case "$1" in
|
|
67
|
+
--domain) domain=$2; shift 2 ;;
|
|
68
|
+
--storage) storage=$2; shift 2 ;;
|
|
69
|
+
--localhost) local_only=1; shift ;;
|
|
70
|
+
*) die "prepare: unknown option $1" ;;
|
|
71
|
+
esac
|
|
72
|
+
done
|
|
73
|
+
command -v openssl >/dev/null 2>&1 || die "openssl is required"
|
|
74
|
+
[ -f "$ENV_FILE" ] || { ( umask 077; : > "$ENV_FILE" ); }
|
|
75
|
+
chmod 600 "$ENV_FILE"
|
|
76
|
+
ensure_secret POSTGRES_PASSWORD
|
|
77
|
+
ensure_secret BOOTSTRAP_SECRET
|
|
78
|
+
ensure_secret SESSION_SECRET
|
|
79
|
+
ensure_secret CREDENTIAL_KEY
|
|
80
|
+
if [ -n "$local_only" ]; then
|
|
81
|
+
env_set APP_URL http://localhost:3000
|
|
82
|
+
elif [ -n "$domain" ] || [ -z "$(env_get FREEHOLDER_DOMAIN)" ]; then
|
|
83
|
+
if [ -z "$domain" ]; then
|
|
84
|
+
ip=$(public_ipv4) || die "could not find this server's public IPv4 address; pass --domain"
|
|
85
|
+
domain=$(sslip_host "$ip")
|
|
86
|
+
say "using the temporary address https://$domain (move to your domain later with: prepare --domain example.com && start)"
|
|
87
|
+
fi
|
|
88
|
+
env_set FREEHOLDER_DOMAIN "$domain"
|
|
89
|
+
env_set APP_URL "https://$domain"
|
|
90
|
+
fi
|
|
91
|
+
[ -n "$(env_get FREEHOLDER_SEED_DEMO)" ] || env_set FREEHOLDER_SEED_DEMO 0
|
|
92
|
+
[ -n "$(env_get FREEHOLDER_IMAGE)" ] || env_set FREEHOLDER_IMAGE "ghcr.io/campdenman/freeholder:$(release_version)"
|
|
93
|
+
case "${storage:-$(env_get FREEHOLDER_STORAGE)}" in
|
|
94
|
+
""|local) env_set FREEHOLDER_STORAGE local ;;
|
|
95
|
+
s3)
|
|
96
|
+
env_set FREEHOLDER_STORAGE s3
|
|
97
|
+
for name in S3_ENDPOINT S3_REGION S3_BUCKET S3_ACCESS_KEY_ID S3_SECRET_ACCESS_KEY; do
|
|
98
|
+
[ -n "$(env_get "$name")" ] || warn "add $name to $ENV_FILE before starting"
|
|
99
|
+
done ;;
|
|
100
|
+
*) die "--storage is local or s3" ;;
|
|
101
|
+
esac
|
|
102
|
+
say "wrote $ENV_FILE (mode 600; secrets generated with openssl)"
|
|
103
|
+
say "start it with: $0 start"
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
cmd_start() {
|
|
107
|
+
[ -f "$ENV_FILE" ] || die "run '$0 prepare' first"
|
|
108
|
+
# Release tags do not move, so pull only what is not here yet (a locally
|
|
109
|
+
# built FREEHOLDER_IMAGE is never pulled).
|
|
110
|
+
compose up -d --wait --pull missing
|
|
111
|
+
url=$(env_get APP_URL)
|
|
112
|
+
say "waiting for $url"
|
|
113
|
+
i=0
|
|
114
|
+
until curl -fsS --max-time 10 -o /dev/null "$url/api/health"; do
|
|
115
|
+
i=$((i + 1)); [ "$i" -lt 60 ] || { warn "$url is not answering yet; check DNS and ports 80/443, then: $0 check"; break; }
|
|
116
|
+
sleep 3
|
|
117
|
+
done
|
|
118
|
+
say "Your private owner claim link (open it yourself):"
|
|
119
|
+
cmd_claim_link
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
cmd_claim_link() {
|
|
123
|
+
url=$(env_get APP_URL); secret=$(env_get BOOTSTRAP_SECRET)
|
|
124
|
+
[ -n "$url" ] && [ -n "$secret" ] || die "run '$0 prepare' first"
|
|
125
|
+
printf '%s/setup#claim=%s\n' "$url" "$secret"
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
cmd_check() {
|
|
129
|
+
failures=0
|
|
130
|
+
url=$(env_get APP_URL)
|
|
131
|
+
compose ps
|
|
132
|
+
for service in app db backup; do
|
|
133
|
+
state=$(docker inspect -f '{{.State.Status}}{{if .State.Health}}/{{.State.Health.Status}}{{end}}' "$(compose ps -q "$service")" 2>/dev/null || echo missing)
|
|
134
|
+
case "$state" in running|running/healthy) printf ' ok %s %s\n' "$service" "$state" ;; *) printf ' FAIL %s %s\n' "$service" "$state"; failures=$((failures + 1)) ;; esac
|
|
135
|
+
done
|
|
136
|
+
if curl -fsS --max-time 15 -o /dev/null "$url/api/health"; then printf ' ok %s/api/health\n' "$url"; else printf ' FAIL %s/api/health\n' "$url"; failures=$((failures + 1)); fi
|
|
137
|
+
latest=$(compose exec -T backup sh -c 'ls -1 /backups 2>/dev/null | grep -v partial | sort | tail -n 1' || true)
|
|
138
|
+
printf ' info latest backup: %s\n' "${latest:-none yet}"
|
|
139
|
+
[ "$failures" -eq 0 ] || { echo "$failures check(s) failed. Logs: docker compose --env-file $ENV_FILE -f $(compose_file) logs app"; return 1; }
|
|
140
|
+
echo "All checks passed."
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
cmd_backup() { compose exec -T backup sh /usr/local/bin/freeholder-backup now; }
|
|
144
|
+
|
|
145
|
+
cmd_restore() {
|
|
146
|
+
[ $# -eq 1 ] || die "usage: $0 restore NAME (see: $0 backups)"
|
|
147
|
+
name=$1
|
|
148
|
+
[ "$name" != latest ] || name=$(compose exec -T backup sh -c 'ls -1 /backups | grep -v partial | sort | tail -n 1')
|
|
149
|
+
say "taking a safety backup first"
|
|
150
|
+
cmd_backup
|
|
151
|
+
compose stop app
|
|
152
|
+
compose exec -T backup sh /usr/local/bin/freeholder-backup restore "$name" || { compose start app; die "restore failed; the current data was kept"; }
|
|
153
|
+
compose start app
|
|
154
|
+
compose up -d --wait app
|
|
155
|
+
say "restored $name"
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
cmd_update() {
|
|
159
|
+
[ $# -eq 1 ] || die "usage: $0 update VERSION (see https://github.com/$REPOSITORY/releases)"
|
|
160
|
+
version=${1#v}
|
|
161
|
+
case "$version" in *[!0-9A-Za-z.-]*) die "not a release version: $version" ;; esac
|
|
162
|
+
previous=$(env_get FREEHOLDER_IMAGE)
|
|
163
|
+
say "backing up before the update"
|
|
164
|
+
cmd_backup
|
|
165
|
+
env_set PREVIOUS_FREEHOLDER_IMAGE "$previous"
|
|
166
|
+
env_set FREEHOLDER_IMAGE "ghcr.io/campdenman/freeholder:$version"
|
|
167
|
+
compose pull --quiet app
|
|
168
|
+
if compose up -d --wait app; then
|
|
169
|
+
say "updated to $version; previous image kept as PREVIOUS_FREEHOLDER_IMAGE"
|
|
170
|
+
else
|
|
171
|
+
warn "$version did not become healthy; switching back to $previous"
|
|
172
|
+
env_set FREEHOLDER_IMAGE "$previous"
|
|
173
|
+
compose up -d --wait app
|
|
174
|
+
die "update failed; restore the pre-update backup if it had migrated the database: $0 restore NAME"
|
|
175
|
+
fi
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
usage() {
|
|
179
|
+
cat <<USAGE
|
|
180
|
+
Usage: $0 COMMAND
|
|
181
|
+
prepare [--domain NAME] [--storage local|s3] [--localhost]
|
|
182
|
+
write deploy/docker-selfhost/.env (secrets from openssl)
|
|
183
|
+
start pull the release image, start, print the claim link
|
|
184
|
+
claim-link print the private owner claim link
|
|
185
|
+
check container health, /api/health over HTTPS, latest backup
|
|
186
|
+
backup back up the database and media now (also runs nightly)
|
|
187
|
+
backups list backups
|
|
188
|
+
restore NAME restore a backup (or 'latest'), after a safety backup
|
|
189
|
+
update VERSION switch to a release image, backing up first
|
|
190
|
+
USAGE
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
command=${1:-help}
|
|
194
|
+
[ $# -eq 0 ] || shift
|
|
195
|
+
case "$command" in
|
|
196
|
+
prepare) cmd_prepare "$@" ;;
|
|
197
|
+
start) cmd_start ;;
|
|
198
|
+
claim-link) cmd_claim_link ;;
|
|
199
|
+
check|status) cmd_check ;;
|
|
200
|
+
backup) cmd_backup ;;
|
|
201
|
+
backups) compose exec -T backup ls -1 /backups ;;
|
|
202
|
+
restore) cmd_restore "$@" ;;
|
|
203
|
+
update) cmd_update "$@" ;;
|
|
204
|
+
logs) compose logs -f app ;;
|
|
205
|
+
*) usage ;;
|
|
206
|
+
esac
|
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
Complete the shared [Tier-1 verification](../recipe-verification.md), then the
|
|
4
4
|
platform checks below.
|
|
5
5
|
|
|
6
|
-
- [ ] `docker
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- [ ]
|
|
6
|
+
- [ ] `deploy/docker-selfhost/selfhost.sh check` passes: app, db and backup
|
|
7
|
+
running, the app healthy, and `/api/health` answering over HTTPS with a
|
|
8
|
+
valid certificate.
|
|
9
|
+
- [ ] `/api/health` returns `ok` and the release `version` you installed
|
|
10
|
+
(`FREEHOLDER_IMAGE` is a release tag, not `edge`).
|
|
11
|
+
- [ ] Doctor is green; with local storage it reports media on
|
|
12
|
+
`/var/lib/freeholder/media`.
|
|
13
|
+
- [ ] Upload an image, `docker compose ... up -d --force-recreate app`, and it
|
|
14
|
+
is still there (it is on the `media` volume).
|
|
15
|
+
- [ ] `selfhost.sh backup` then `selfhost.sh restore latest` brings back the
|
|
16
|
+
same pages and media.
|
|
@@ -1847,6 +1847,21 @@ v2.
|
|
|
1847
1847
|
- **F11** — `deploy/doc-claim-mapping.md`: strike S11 records the gap in MASTER §26 item 3; changeset when it ships.
|
|
1848
1848
|
- **F12** — `tests/core/plugins-lifecycle.test.ts`: Pending — publisher signs → registry index verified → plugin installed and verified.
|
|
1849
1849
|
|
|
1850
|
+
## C3.44 — WordPress-easy manual install on any host, native first, Docker optional
|
|
1851
|
+
|
|
1852
|
+
- **F01** — N/A — no schema change; media rows are unchanged and local-disk objects keep their storage keys as paths.
|
|
1853
|
+
- **F02** — `src/adapters/storage/local-mode.ts`: one rule for the persistent local-disk mode, used by `src/adapters/storage/local.ts`, Doctor and the update screen and preflight; `tests/core/local-storage-mode.test.ts`, `tests/core/storage.test.ts`.
|
|
1854
|
+
- **F03** — N/A — no contact or money record; media stays behind `authorizeObjectDelivery` in `app/media/[...key]/route.ts`.
|
|
1855
|
+
- **F04** — N/A as a new screen — Doctor and `/admin/updates` report the storage mode; the operator surface is `deploy/linux/freeholder` (`status`, `backup`, `restore`, `update`, `rollback`, `domain`, `claim-link`).
|
|
1856
|
+
- **F05** — `deploy/linux/install.sh`, `deploy/linux/freeholder` and `deploy/docker-selfhost/selfhost.sh` are the operator interfaces; no service change.
|
|
1857
|
+
- **F06** — N/A — operator shell output in English; no product copy changed.
|
|
1858
|
+
- **F07** — `tests/core/linux-install.test.ts` covers checksum-before-unpack, private secrets, safety backup before restore, and rollback of release and database after a failed update.
|
|
1859
|
+
- **F08** — `.github/workflows/release-tarballs.yml` installs each tarball with `install.sh` on x64 and arm64 runners against real PostgreSQL, then backs up and restores it; `tests/core/deploy-recipe.test.ts` pins the Docker volume and backup service.
|
|
1860
|
+
- **F09** — `deploy/linux/README.md` and `deploy/docker-selfhost/README.md`: nightly database and media backups with checksums, restore into a scratch database, the replaced database kept, and offsite copies.
|
|
1861
|
+
- **F10** — N/A — local reads go through the existing `/media` route; no new per-request work.
|
|
1862
|
+
- **F11** — `GETTING_STARTED.md`, `AGENTS.md`, `deploy/README.md`, `deploy/linux/README.md`; changeset `native-linux-install.md`.
|
|
1863
|
+
- **F12** — `.github/workflows/release-tarballs.yml`: Pending — a release carrying the tarballs, then the documented steps on a fresh server (HTTPS, claim, publish, backup, restore).
|
|
1864
|
+
|
|
1850
1865
|
## C4.01 — Build the work board, task tree/dependency view, assignment
|
|
1851
1866
|
|
|
1852
1867
|
- **F01** — No item-dedicated migration is named in §43; schema is owned per-module and applied through `db/migrations/0000_reviewed-baseline.sql` (reviewed baseline, C10.19); database coverage in `tests/core/agents-board.test.ts`.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright (C) 2026 Tony Aly
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
# /etc/freeholder/freeholder.env on a native install. `freeholder setup`
|
|
4
|
+
# writes it (root:freeholder, mode 640) and generates every secret with
|
|
5
|
+
# `openssl rand -hex 32`; you never need to fill it in by hand. Shown here so
|
|
6
|
+
# you know what is in it. Never use this example as a live file.
|
|
7
|
+
APP_URL=https://example.com
|
|
8
|
+
DATABASE_URL=postgres://freeholder:GENERATED@127.0.0.1:5432/freeholder
|
|
9
|
+
POSTGRES_PASSWORD=GENERATED
|
|
10
|
+
BOOTSTRAP_SECRET=GENERATED
|
|
11
|
+
SESSION_SECRET=GENERATED
|
|
12
|
+
CREDENTIAL_KEY=GENERATED
|
|
13
|
+
TRUSTED_CLIENT_IP_HEADER=x-freeholder-client-ip
|
|
14
|
+
FREEHOLDER_SEED_DEMO=0
|
|
15
|
+
# Media on this server's disk (default), included in the nightly backup.
|
|
16
|
+
FREEHOLDER_STORAGE=local
|
|
17
|
+
LOCAL_STORAGE_ROOT=/var/lib/freeholder/media
|
|
18
|
+
# Or S3-compatible storage: `freeholder setup --storage s3` asks for these.
|
|
19
|
+
# FREEHOLDER_STORAGE=s3
|
|
20
|
+
# S3_ENDPOINT=
|
|
21
|
+
# S3_REGION=
|
|
22
|
+
# S3_BUCKET=
|
|
23
|
+
# S3_ACCESS_KEY_ID=
|
|
24
|
+
# S3_SECRET_ACCESS_KEY=
|
|
25
|
+
# Optional: Let's Encrypt contact address, backups kept, offsite copy.
|
|
26
|
+
# ACME_EMAIL=
|
|
27
|
+
# BACKUP_KEEP=14
|
|
28
|
+
# BACKUP_RCLONE_REMOTE=offsite:my-backup-bucket/freeholder
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Linux server, no Docker (Tier 2)
|
|
2
|
+
|
|
3
|
+
Freeholder on one Ubuntu or Debian server: a release tarball that carries its
|
|
4
|
+
own Node.js runtime, PostgreSQL from the distribution, Caddy for automatic
|
|
5
|
+
HTTPS, and systemd. No Docker, Node, pnpm or source checkout on the server,
|
|
6
|
+
and no AI assistant needed. This is the WordPress-style install: download it,
|
|
7
|
+
run it, open the link.
|
|
8
|
+
|
|
9
|
+
## What you need
|
|
10
|
+
|
|
11
|
+
- A server running **Ubuntu 22.04 or newer, or Debian 12 or newer**, on x86_64
|
|
12
|
+
or arm64, with root access over SSH. 2 GB of memory works while the site is
|
|
13
|
+
small; 4 GB (2 vCPUs) is comfortable. Any provider works: DigitalOcean,
|
|
14
|
+
Hetzner, Linode, Vultr, OVH, AWS Lightsail, a box under your desk.
|
|
15
|
+
- Ports 80 and 443 open to the internet (Caddy needs both for the
|
|
16
|
+
certificate).
|
|
17
|
+
- Optionally, a domain. Without one, the site starts at a temporary
|
|
18
|
+
`https://<ip>.sslip.io` address with a real certificate, and you move it to
|
|
19
|
+
your domain later.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
curl -fsSLO https://github.com/CampDenman/freeholder/releases/download/v0.2.0-beta.5/install.sh
|
|
25
|
+
less install.sh # optional: read what it does
|
|
26
|
+
sudo sh install.sh # asks for your domain; Enter = temporary address
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`--domain example.com` skips the question. If that domain does not point at
|
|
30
|
+
the server yet, the installer starts on the temporary address and tells you the
|
|
31
|
+
command for later. It finishes in a few minutes and prints your private owner
|
|
32
|
+
claim link. Open it yourself, create the owner account and save the recovery
|
|
33
|
+
codes. Get the link again any time with `sudo freeholder claim-link`.
|
|
34
|
+
|
|
35
|
+
The installer, in order:
|
|
36
|
+
|
|
37
|
+
1. installs PostgreSQL (the distribution's package, or the official
|
|
38
|
+
PostgreSQL apt repository when the distribution's is older than 15), Caddy
|
|
39
|
+
(from Caddy's official apt repository), `curl` and `openssl`;
|
|
40
|
+
2. creates a `freeholder` system user;
|
|
41
|
+
3. downloads `freeholder-VERSION-linux-ARCH.tar.gz` from the GitHub release,
|
|
42
|
+
checks it against the published `.sha256`, and unpacks it to
|
|
43
|
+
`/opt/freeholder/releases/VERSION` with `/opt/freeholder/current` pointing
|
|
44
|
+
at it;
|
|
45
|
+
4. runs `freeholder setup` from that release, which creates the database and
|
|
46
|
+
role, writes `/etc/freeholder/freeholder.env` with secrets from
|
|
47
|
+
`openssl rand -hex 32`, installs the systemd units and the nightly backup
|
|
48
|
+
timer, writes `/etc/caddy/Caddyfile`, opens 80/443 if `ufw` is active, and
|
|
49
|
+
starts everything.
|
|
50
|
+
|
|
51
|
+
Running it again is safe: secrets, data and settings are kept. To check what
|
|
52
|
+
you downloaded came from this repository's release workflow, run
|
|
53
|
+
`gh attestation verify freeholder-*.tar.gz --repo CampDenman/freeholder`.
|
|
54
|
+
|
|
55
|
+
## Where everything is
|
|
56
|
+
|
|
57
|
+
| Path | What |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `/opt/freeholder/releases/VERSION` | Unpacked releases (root-owned, read-only to the app) |
|
|
60
|
+
| `/opt/freeholder/current` | Symlink to the running release |
|
|
61
|
+
| `/etc/freeholder/freeholder.env` | Settings and secrets (`root:freeholder`, mode 640) |
|
|
62
|
+
| `/var/lib/freeholder/media` | Uploaded media (local storage) |
|
|
63
|
+
| `/var/lib/freeholder/backups` | Nightly backups (root only) |
|
|
64
|
+
| `/etc/caddy/Caddyfile` | HTTPS proxy, rewritten by `freeholder setup` and `freeholder domain` |
|
|
65
|
+
| `freeholder.service`, `freeholder-backup.timer` | systemd units |
|
|
66
|
+
|
|
67
|
+
The app listens on `127.0.0.1:3000` only and PostgreSQL on localhost only;
|
|
68
|
+
Caddy is the only way in. Migrations run when the service starts, before it
|
|
69
|
+
reports ready.
|
|
70
|
+
|
|
71
|
+
## Day to day
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
sudo freeholder status # service, database, HTTPS certificate, storage, backups
|
|
75
|
+
sudo freeholder logs # follow the application log
|
|
76
|
+
sudo freeholder claim-link # the owner claim link, until the owner exists
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`freeholder status` is this recipe's health check (the Doctor): it needs no
|
|
80
|
+
Node, pnpm or checkout.
|
|
81
|
+
|
|
82
|
+
## Media storage: local disk or S3
|
|
83
|
+
|
|
84
|
+
By default uploaded media is stored on the server in
|
|
85
|
+
`/var/lib/freeholder/media` and served through Freeholder, which checks access
|
|
86
|
+
on every request (private galleries, paid files and trashed media stay
|
|
87
|
+
private). It is in every backup.
|
|
88
|
+
|
|
89
|
+
| | Local disk (default) | S3-compatible bucket |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| Setup | Nothing to do | Create a private bucket and a key scoped to it |
|
|
92
|
+
| Cost | Server disk | A few dollars a month |
|
|
93
|
+
| Survives losing the server | Only through your backups, so copy them off the server | Yes, media lives elsewhere |
|
|
94
|
+
| More than one app server | No | Yes |
|
|
95
|
+
| Large uploads | Through the app | Direct, resumable browser uploads |
|
|
96
|
+
|
|
97
|
+
To start with S3: `sudo sh install.sh --storage s3` (it asks for the endpoint,
|
|
98
|
+
region, bucket and key). To move an existing site to S3 later, copy the media
|
|
99
|
+
directory to the bucket with the same paths
|
|
100
|
+
(`rclone copy /var/lib/freeholder/media remote:bucket`), then run
|
|
101
|
+
`sudo freeholder setup --storage s3`.
|
|
102
|
+
|
|
103
|
+
## Backups and restore
|
|
104
|
+
|
|
105
|
+
`freeholder-backup.timer` runs `freeholder backup` every night at about 03:15
|
|
106
|
+
server time. Each backup is a directory in `/var/lib/freeholder/backups`:
|
|
107
|
+
|
|
108
|
+
- `database.dump`: the whole database (`pg_dump` custom format);
|
|
109
|
+
- `media.tar.gz`: the media directory (local storage only);
|
|
110
|
+
- `RELEASE.json`, `BACKUP`: the version and why it was taken;
|
|
111
|
+
- `SHA256SUMS`: checked before any restore.
|
|
112
|
+
|
|
113
|
+
The newest 14 are kept (`BACKUP_KEEP` in the env file). Backups do not contain
|
|
114
|
+
`/etc/freeholder/freeholder.env`; keep a copy of it somewhere safe once,
|
|
115
|
+
because `CREDENTIAL_KEY` is needed to read stored provider credentials.
|
|
116
|
+
|
|
117
|
+
**Keep a copy off the server.** A backup on the same disk does not survive
|
|
118
|
+
losing the server. Install `rclone`, configure a remote (`rclone config`, for
|
|
119
|
+
example an S3-compatible bucket), and set `BACKUP_RCLONE_REMOTE=remote:bucket/path`
|
|
120
|
+
in `/etc/freeholder/freeholder.env`; every backup is then copied there too.
|
|
121
|
+
|
|
122
|
+
Restore:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
sudo ls /var/lib/freeholder/backups
|
|
126
|
+
sudo freeholder restore latest # or a directory name from the list
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
It verifies the checksums, takes a safety backup of the current data, restores
|
|
130
|
+
the database into a scratch database and swaps it in (the replaced one is kept
|
|
131
|
+
as `freeholder_previous`), restores the media (the replaced directory is kept
|
|
132
|
+
as `/var/lib/freeholder/media.previous`), restarts and waits until the site is
|
|
133
|
+
ready. To restore on a new server, install Freeholder there, copy the old
|
|
134
|
+
`freeholder.env` secrets you kept (at least `CREDENTIAL_KEY`) into the new
|
|
135
|
+
`/etc/freeholder/freeholder.env`, copy the backup directory over, and run
|
|
136
|
+
`sudo freeholder restore /path/to/it`.
|
|
137
|
+
|
|
138
|
+
## Updates
|
|
139
|
+
|
|
140
|
+
```sh
|
|
141
|
+
sudo freeholder update latest # or: sudo freeholder update 0.2.0-beta.6
|
|
142
|
+
sudo freeholder rollback # undo the last update
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`update` downloads the release, checks its SHA-256, unpacks it beside the
|
|
146
|
+
current one, takes a backup, switches `current`, restarts and waits for
|
|
147
|
+
`/api/health`. If the new release does not become ready it switches back and
|
|
148
|
+
restores the database from that pre-update backup, because the new release
|
|
149
|
+
may already have migrated it. `rollback` does the same on request. The three
|
|
150
|
+
newest releases are kept. Release notes are on the
|
|
151
|
+
[releases page](https://github.com/CampDenman/freeholder/releases).
|
|
152
|
+
|
|
153
|
+
## Moving to your real domain
|
|
154
|
+
|
|
155
|
+
Point the domain's `A` record at the server, wait until `dig +short
|
|
156
|
+
example.com` shows its address, then:
|
|
157
|
+
|
|
158
|
+
```sh
|
|
159
|
+
sudo freeholder domain example.com
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Passkeys belong to the address they were created on. After the move, sign in
|
|
163
|
+
with your password at the new address and add a passkey again under
|
|
164
|
+
Settings → Security.
|
|
165
|
+
|
|
166
|
+
## Removing it
|
|
167
|
+
|
|
168
|
+
```sh
|
|
169
|
+
sudo systemctl disable --now freeholder freeholder-backup.timer
|
|
170
|
+
sudo rm -rf /opt/freeholder /etc/freeholder /etc/systemd/system/freeholder*.service \
|
|
171
|
+
/etc/systemd/system/freeholder-backup.timer /usr/local/bin/freeholder
|
|
172
|
+
sudo -u postgres dropdb freeholder; sudo -u postgres dropuser freeholder
|
|
173
|
+
# Your data and backups stay in /var/lib/freeholder until you delete it.
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Building the tarball yourself
|
|
177
|
+
|
|
178
|
+
From a checkout on Linux of the architecture you want:
|
|
179
|
+
`pnpm install --frozen-lockfile && pnpm build && pnpm release:build`. It writes
|
|
180
|
+
`dist/release/freeholder-VERSION-linux-ARCH.tar.gz`, its `.sha256` and
|
|
181
|
+
`install.sh`; install it with `sudo sh install.sh --tarball FILE`.
|