Skip to content

Deploy updates automatically

scripts/deploy/deploy.sh keeps a Docker Compose installation tracking the latest commit of a branch. A systemd timer runs it every two minutes and redeploys when new commits arrive.

What a deploy does

  • Frontend-only changes copy updated static files directly into the running container without restarting it, so active chats keep streaming uninterrupted. This path also covers tests, deployment scripts, root Markdown files, and non-Markdown assets under docs/.
  • Backend or image changes rebuild the Docker image, wait for any in-flight generations to finish (up to 10 minutes), and recreate the container. Open browser tabs reconnect automatically. Adding, editing, moving, or deleting a Markdown page under docs/ takes this path so Numi reads the updated manual.

The script refuses to run if the working tree has local modifications and only fast-forwards (git merge --ff-only), stopping safely if the branch has diverged.

Requirements

  • A Docker checkout configured as described in Run with Docker, with .env in place.
  • Working git fetch access for the user who owns the checkout.
  • Docker with the Compose plugin, plus systemd.

Install

Run these commands from the repository root to install and start the timer (tracking main by default):

sed "s#/opt/numi-chat#$PWD#" scripts/deploy/numi-chat-deploy.service \
  | sudo tee /etc/systemd/system/numi-chat-deploy.service >/dev/null
sudo cp scripts/deploy/numi-chat-deploy.timer /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now numi-chat-deploy.timer

To follow a different branch, edit NUMI_CHAT_BRANCH in /etc/systemd/system/numi-chat-deploy.service and run sudo systemctl daemon-reload.

Version shown in About

After each deploy, the script writes the commit hash, commit timestamp, and deploy timestamp to state/build.json. The server reads that file on every /api/v1/version request, so About in the profile menu reflects the newly deployed version immediately (even after a frontend-only update), and open tabs offer a Reload banner when a newer build is live.

Check and troubleshoot

Task Command
Check next and last timer runs systemctl list-timers numi-chat-deploy.timer
View recent deploy logs journalctl -u numi-chat-deploy.service -n 50
Trigger a deploy immediately sudo systemctl start numi-chat-deploy.service
Pause automatic deploys sudo systemctl stop numi-chat-deploy.timer
Force a full image rebuild on next run sudo rm .git/numi-deploy-<branch>

The last deployed commit is recorded in .git/numi-deploy-<branch>. Removing that marker file forces the next run to perform a full image rebuild. Each full deploy also prunes untagged images and build cache older than 24 hours.