Files
Vasanthdev2004 888fab6028 fix(infra): serialize the upgrade and write compose through a unique temp path
The compose reinstall added last round is not safe under overlap, and `main`
never wrote compose from this document, so the race arrives with that commit.

Two executions — a double run, a retry while the first is still pulling, two
operators — shared the fixed `/opt/gitlawb/compose.yaml.new`. The second
truncates the file the first is about to install; and once the first renames,
the second's open descriptor keeps writing into the live `compose.yaml` inode.
Both outcomes stay valid YAML, so the `up -d --remove-orphans` on the next line
accepts a blended or truncated service set and deletes whatever fell off — on a
live node, the local postgres or the TLS terminator. Both reviewers reproduced
it independently; one measured a short file in 12 of 12 trials.

The whole step now runs under `flock -n` on /opt/gitlawb/.upgrade.lock and
exits non-zero if the lock is held, so a second run cannot restart against a
file the first is mid-install. The temp file comes from `mktemp`, so concurrent
writers cannot truncate each other, with a trap to clean it up on failure.

The compose body is base64-encoded rather than written through a nested
heredoc. The rendering carries `$${VAR}` passthroughs that must reach the file
unexpanded, which needs a quoted delimiter, and a shell heredoc nested inside an
indented Terraform heredoc depends on the dedent landing that delimiter at
column 0. Decoding one line has neither failure mode and no delimiter can
collide with the content.

Not validated locally: terraform is not installed on this machine, so this
change has had no `fmt`, `validate`, or `plan` run against it.
2026-08-16 11:00:21 +05:30
..
2026-06-05 22:38:53 +08:00

infra/

Deployment configuration, organized by target — one subdirectory per platform.

infra/
├── fly/
│   └── fly.toml    # Fly.io app config (gitlawb-node-test)
└── aws/            # Terraform: single EC2 + Docker (see aws/README.md)

Deploying to Fly.io

Run from the repo root so the Docker build context includes crates/, Cargo.toml, and bootstrap-peers.json:

fly deploy -c infra/fly/fly.toml

The dockerfile path inside fly.toml is resolved relative to the config file, so it points to ../../Dockerfile.

Deploying to AWS

See aws/README.md — Terraform for a single EC2 instance running the published ghcr.io/gitlawb/node image with Docker compose.

What intentionally stays at the repo root

  • Dockerfile / Dockerfile.bins — shared by the release CI workflow (.github/workflows/release.yml), scripts/build-bins.sh, and Fly builds.
  • docker-compose.yml — local dev stack; bundled into the macOS app by scripts/build-macos-app.sh and used for repo detection by the app.

Future targets should follow the same per-platform layout.