Compare commits

...
Author SHA1 Message Date
spark 34a18bb862 Desktop 0.3.1: the release build gives the bundler the updater public key
ci / rust (push) Successful in 12m43s
ci / typescript (push) Successful in 14m5s
desktop-release / build (deb,appimage, linux-x86_64, ubuntu-latest) (push) Failing after 34m21s
Signed installers failed to verify (Missing comment in public key) because plugins.updater.pubkey was empty at build time.

Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
2026-10-13 10:57:28 +01:00
spark daf7fa7c11 Come back by itself after a reboot: boot unit for api and site, TMPDIR at boot, PM2 retries
ci / rust (push) Successful in 9m14s
ci / typescript (push) Successful in 11m18s
photoreport-boot.service runs infra/deploy/boot.sh at boot (starts the PM2 apps from the last built code, without depending on a saved PM2 list); tmpfiles rule for TMPDIR; deploys pm2 save; PM2 retries with exponential backoff while the database starts.

Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
2026-10-13 10:32:56 +01:00
spark 07fe64f95f ZIP downloads: accented file names survive unzip on Linux
ci / rust (push) Successful in 8m3s
ci / typescript (push) Successful in 10m29s
The archive is now made by Unix: Info-ZIP unzip read names of an MS-DOS archive as OEM code page despite the UTF-8 flag (this also failed the CI zip test).

Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
2026-10-13 09:49:57 +01:00
15 changed files with 111 additions and 9 deletions

No files matched your search

+1 -1
View File
@@ -33,7 +33,7 @@ jobs:
- run: pnpm -r typecheck
- run: pnpm -r test
- name: Deploy scripts parse
run: bash -n infra/deploy/deploy.sh
run: bash -n infra/deploy/deploy.sh && bash -n infra/deploy/boot.sh
rust:
runs-on: ubuntu-latest
+4 -1
View File
@@ -59,7 +59,10 @@ jobs:
run: |
extra=()
# Signed updater artifacts only when the release key is there (a build without it still works).
if [[ -n "$TAURI_SIGNING_PRIVATE_KEY" ]]; then extra=(--config '{"bundle":{"createUpdaterArtifacts":true}}'); fi
# The bundler checks each signature against plugins.updater.pubkey, so the public key goes into the config too.
if [[ -n "$TAURI_SIGNING_PRIVATE_KEY" ]]; then
extra=(--config "$(node -e 'console.log(JSON.stringify({bundle:{createUpdaterArtifacts:true},plugins:{updater:{pubkey:process.env.PHOTOREPORT_UPDATER_PUBKEY}}}))')")
fi
pnpm --filter @photoreport/desktop exec tauri build --bundles ${{ matrix.bundles }} ${{ matrix.args }} "${extra[@]}"
- name: Update manifest
if: env.TAURI_SIGNING_PRIVATE_KEY != ''
+4 -1
View File
@@ -78,7 +78,9 @@ export async function zipStream(entries: ZipEntry[]): Promise<{ stream: Readable
const dir = Buffer.alloc(46);
dir.writeUInt32LE(0x02014b50, 0);
dir.writeUInt16LE(20, 4); // made by
// Made by Unix, spec 6.3: Info-ZIP unzip (Linux) reads the names of an archive "made by" MS-DOS as OEM code
// page even with the UTF-8 flag set, which mangled accented names; with a Unix origin it honours the flag.
dir.writeUInt16LE((3 << 8) | 63, 4);
dir.writeUInt16LE(20, 6);
dir.writeUInt16LE(0x0800, 8);
dir.writeUInt16LE(0, 10);
@@ -88,6 +90,7 @@ export async function zipStream(entries: ZipEntry[]): Promise<{ stream: Readable
dir.writeUInt32LE(f.size, 20);
dir.writeUInt32LE(f.size, 24);
dir.writeUInt16LE(f.name.length, 28);
dir.writeUInt32LE((0o100644 << 16) >>> 0, 38); // a regular file, rw-r--r--
dir.writeUInt32LE(offset, 42);
central.push(dir, f.name);
offset += 30 + f.name.length + f.size;
+3 -1
View File
@@ -34,6 +34,8 @@ describe("zip", () => {
const test = execFileSync("unzip", ["-t", file]).toString();
expect(test).toContain("No errors detected");
expect(execFileSync("unzip", ["-p", file, "Benfica x Porto_001_2.jpg"]).toString()).toBe("olá");
expect(execFileSync("unzip", ["-Z1", file]).toString().trim().split("\n")).toEqual(["Benfica x Porto_001.jpg", "Benfica x Porto_001_2.jpg", "Ação.jpg"]);
// Accented names must survive any locale (the CI runner's is UTF-8, a plain C one prints the bytes as they are).
const utf8 = { env: { ...process.env, LC_ALL: "C.UTF-8" } };
expect(execFileSync("unzip", ["-Z1", file], utf8).toString().trim().split("\n")).toEqual(["Benfica x Porto_001.jpg", "Benfica x Porto_001_2.jpg", "Ação.jpg"]);
});
});
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@photoreport/desktop",
"version": "0.3.0",
"version": "0.3.1",
"private": true,
"type": "module",
"scripts": {
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "photoreport-desktop"
version = "0.3.0"
version = "0.3.1"
edition = "2024"
publish = false
description = "PhotoReport desktop: the web app in a native shell, with keychain sign-in and (later) local FTP and the native engine."
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "PhotoReport",
"version": "0.3.0",
"version": "0.3.1",
"identifier": "pt.photoreport.desktop",
"build": {
"devUrl": "http://localhost:5173",
+7
View File
@@ -51,6 +51,13 @@ Gitea -> webhook -> the container pulls and redeploys itself. No manual `scp`/`r
3. `/etc/photoreport/deploy-receiver.env` from `infra/deploy-receiver/.env.example` (0600), with a new secret.
4. `pnpm install && pnpm --filter @photoreport/deploy-receiver build`, then enable
`photoreport-deploy-receiver.service` and include `infra/nginx/deploy-receiver.conf` in the site.
Then, for a service that comes back by itself after any reboot (container or Proxmox host):
`cp infra/systemd/photoreport-boot.service /etc/systemd/system/ && systemctl enable photoreport-boot.service`,
`cp infra/systemd/photoreport-tmp.conf /etc/tmpfiles.d/photoreport.conf`, and `pm2 startup systemd`.
`photoreport-boot.service` runs `infra/deploy/boot.sh`, which starts the PM2 processes (api, site) from the code
the last deploy left built, without relying on PM2's saved list; deploys also `pm2 save`. PM2 retries crashed
processes with a growing pause, so the API waits for a database that starts later. Check after setting it up:
`reboot` the container, then `/health` (api) or the home page (site) must answer without anyone doing anything.
5. In Gitea: Settings -> Webhooks -> add `https://<container-domain>/_deploy/gitea`, content type JSON,
the same secret, push events only, branch filter `main`.
6. API container only, once: `create-owner` (see README) for the first organization.
+55
View File
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
# Brings this container's PhotoReport service back after a reboot (container or Proxmox host), from the code that
# is already checked out and built by the last deploy: nothing is fetched, built or migrated here.
# Run by photoreport-boot.service: boot.sh <api|app|site|ingest>. Safe to run by hand at any time.
set -Eeuo pipefail
SERVICE="${1:-${DEPLOY_SERVICE:-}}"
[[ -n "$SERVICE" ]] || { echo "usage: boot.sh <api|app|site|ingest>" >&2; exit 2; }
# The unit reads the receiver's env file for DEPLOY_SERVICE; its own PORT (and secret) must not reach PM2, which
# copies this environment into the apps (--update-env): the API would try to listen on the receiver's port.
unset PORT DEPLOY_WEBHOOK_SECRET DEPLOY_SERVICE DEPLOY_SCRIPT DEPLOY_LOG
REPO_DIR="${DEPLOY_REPO_DIR:-/srv/photoreport}"
API_PORT="${API_PORT:-3000}"
SITE_PORT="${SITE_PORT:-3100}"
HEALTH_TRIES="${BOOT_HEALTH_TRIES:-90}"
log() { printf '[%s] boot %s: %s\n' "$(date -u +%FT%TZ)" "$SERVICE" "$*"; }
# pnpm and other tools write to $TMPDIR; on these containers it points under /tmp, which is emptied at boot.
[[ -n "${TMPDIR:-}" ]] && mkdir -p "$TMPDIR" && chmod 700 "$TMPDIR"
export PATH="$HOME/.cargo/bin:/usr/local/bin:$PATH"
cd "$REPO_DIR"
SHA="$(git rev-parse HEAD)"
wait_for() {
local url="$1" i
for ((i = 1; i <= HEALTH_TRIES; i++)); do
curl -fsS --max-time 3 -o /dev/null "$url" 2>/dev/null && return 0
sleep 2
done
return 1
}
case "$SERVICE" in
api)
APP_VERSION="$SHA" pm2 startOrReload infra/pm2/api.config.cjs --update-env
pm2 save --force >/dev/null
# The database may come up after this container: PM2 keeps retrying (exp_backoff_restart_delay), so a slow
# start is reported, not treated as fatal.
wait_for "http://127.0.0.1:${API_PORT}/health" && log "api up at $SHA" || log "WARNING: api not healthy yet (PM2 keeps retrying)"
;;
site)
if [[ -f apps/site/.env ]]; then set -a; source apps/site/.env; set +a; fi
APP_VERSION="$SHA" pm2 startOrReload infra/pm2/site.config.cjs --update-env
pm2 save --force >/dev/null
wait_for "http://127.0.0.1:${SITE_PORT}/" && log "site up at $SHA" || log "WARNING: site not answering yet (PM2 keeps retrying)"
;;
app | ingest | workers | ml)
# Static files behind nginx (app) and SFTPGo (ingest) are plain systemd services, enabled at install.
log "nothing to start (systemd services)"
;;
*)
log "unknown service"; exit 2 ;;
esac
+5 -1
View File
@@ -17,6 +17,8 @@ log() { printf '[%s] %s\n' "$(date -u +%FT%TZ)" "$*"; }
die() { log "ERROR: $*"; exit 1; }
[[ "$SHA" =~ ^[0-9a-f]{40}$ ]] || die "invalid sha: $SHA"
# pnpm needs $TMPDIR to exist; on these containers it is under /tmp, which a reboot empties.
[[ -n "${TMPDIR:-}" ]] && mkdir -p "$TMPDIR" && chmod 700 "$TMPDIR"
cd "$REPO_DIR"
# Keep a copy of every .env before touching anything (norm BIT-25005). Deploys never write them.
@@ -60,6 +62,8 @@ deploy_api() {
bash infra/faces/download-models.sh "${MODELS_DIR:-/srv/photoreport-data/models}" || log "WARNING: face models could not be downloaded"
APP_VERSION="$sha" pm2 startOrReload infra/pm2/api.config.cjs --update-env
wait_for_version "http://127.0.0.1:${API_PORT}/health" "$sha"
# The process list PM2 restores after a reboot follows every deploy (photoreport-boot.service starts it too).
pm2 save --force >/dev/null
}
# Rust in the deploy user's home (no root): installed the first time, then only put on PATH (systemd's PATH
@@ -119,7 +123,7 @@ deploy_site() {
APP_VERSION="$sha" pm2 startOrReload infra/pm2/site.config.cjs --update-env
local i
for ((i = 1; i <= HEALTH_TRIES; i++)); do
if curl -fsS --max-time 3 -o /dev/null "http://127.0.0.1:${SITE_PORT:-3100}/"; then return 0; fi
if curl -fsS --max-time 3 -o /dev/null "http://127.0.0.1:${SITE_PORT:-3100}/"; then pm2 save --force >/dev/null; return 0; fi
sleep 2
done
return 1
+2 -1
View File
@@ -49,7 +49,8 @@ step "Installer (API: $API)"
extra=(--bundles dmg)
if [[ -n "${TAURI_SIGNING_PRIVATE_KEY:-}" && -n "${TAURI_UPDATER_PUBKEY:-}" ]]; then
export PHOTOREPORT_UPDATER_PUBKEY="$TAURI_UPDATER_PUBKEY"
extra=(--bundles dmg,app --config '{"bundle":{"createUpdaterArtifacts":true}}')
# The bundler checks each signature against plugins.updater.pubkey, so the public key goes into the config too.
extra=(--bundles dmg,app --config "$(node -e 'console.log(JSON.stringify({bundle:{createUpdaterArtifacts:true},plugins:{updater:{pubkey:process.env.PHOTOREPORT_UPDATER_PUBKEY}}}))')")
fi
VITE_API_URL="$API" PHOTOREPORT_API_URL="$API" pnpm --filter @photoreport/desktop exec tauri build --target universal-apple-darwin "${extra[@]}"
BUNDLE="apps/desktop/src-tauri/target/universal-apple-darwin/release/bundle"
+6
View File
@@ -23,6 +23,9 @@ module.exports = {
exec_mode: apiOverride.exec_mode ?? "cluster",
max_memory_restart: "1G",
kill_timeout: 10000,
// Keep retrying with a growing pause (up to 15 s) instead of giving up after 15 quick crashes, e.g. while
// the database container is still starting after a host reboot.
exp_backoff_restart_delay: 200,
},
{
// One worker per installation (FTP ingest + delivery queue): it owns the drop folder, so never clustered.
@@ -34,6 +37,9 @@ module.exports = {
exec_mode: "fork",
max_memory_restart: "2G",
kill_timeout: 30000,
// Keep retrying with a growing pause (up to 15 s) instead of giving up after 15 quick crashes, e.g. while
// the database container is still starting after a host reboot.
exp_backoff_restart_delay: 200,
},
],
};
+2
View File
@@ -8,6 +8,8 @@ module.exports = {
args: "start -p 3100",
instances: 2,
exec_mode: "cluster",
// Keep retrying with a growing pause instead of giving up after 15 quick crashes (e.g. after a reboot).
exp_backoff_restart_delay: 200,
env: { NODE_ENV: "production", PORT: "3100", API_URL: process.env.API_URL || "http://127.0.0.1:3000" },
},
],
+17
View File
@@ -0,0 +1,17 @@
# Starts this container's PhotoReport processes after any reboot, from the code the last deploy left in place
# (infra/deploy/boot.sh). Doesn't depend on a saved PM2 process list. One per container, like the receiver.
[Unit]
Description=PhotoReport: start the service after a reboot
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
Environment=HOME=/root
EnvironmentFile=/etc/photoreport/deploy-receiver.env
ExecStart=/bin/bash /srv/photoreport/infra/deploy/boot.sh
TimeoutStartSec=300
[Install]
WantedBy=multi-user.target
+2
View File
@@ -0,0 +1,2 @@
# /etc/tmpfiles.d/photoreport.conf: the temporary folder pnpm and the deploy use (TMPDIR) is created at every boot.
d /tmp/user/0 0700 root root -