Compare commits

...
Author SHA1 Message Date
BaaRai 486465a91e docs: add an installation guide, issue form, and video script
INSTALL.md collects the supported Docker paths, first login, remote access,
and the errors behind most installation questions. The README links it from
the nav and above the quick start. The installation issue form asks for OS,
Docker setup, version, logs and health output, and reminds reporters to strip
the setup token. The video script keeps a short demo aligned with the guide.
2026-11-28 13:32:27 +01:00
BaaRai e9659c8ae1 Merge pull request #640 from BaaRai/feat/version-identity
feat: report the build identity in the UI and /health
2026-11-28 10:36:47 +01:00
BaaRai 869b44a327 feat: report the build identity in the UI and /health
A local Docker build passed ARTEX_VERSION=dev, so every such install showed
the same meaningless version and could not name its source. update.sh now
stamps ARTEX_VERSION and ARTEX_REVISION from git before a rebuild (and no
longer aborts when the pull is declined), Docker builds forward the revision
and publish OCI labels, release images stamp the commit, and /health reports
version, commit, Go version and build time. The top bar renders dev (abc1234)
when a local build has no describe tag but does carry a revision.
2026-11-28 10:16:00 +01:00
BaaRai 91da8341cd Merge pull request #639 from BaaRai/land/verified-stack-2026-11-28
Land verified review fixes: #602, #621, #604, #616, #629 (extra_hosts), #619 bench-v2, #580 docs
2026-11-28 10:15:34 +01:00
17 changed files with 550 additions and 22 deletions
+5
View File
@@ -19,6 +19,11 @@ POSTGRES_PASSWORD=change-me-please
POSTGRES_DB=artex
# Prebuilt GHCR image tag for docker-compose.ghcr.yml. Unset uses latest.
# ARTEX_IMAGE_TAG=latest
# Build identity shown in the UI and the startup banner. update.sh refreshes both
# from git before a rebuild; a manual `docker compose build` without them reports
# "dev". ARTEX_REVISION is the full commit, ARTEX_VERSION the describe tag/hash.
# ARTEX_VERSION=
# ARTEX_REVISION=
# LLM (fill one or both; you can also leave empty and configure in the UI)
ANTHROPIC_API_KEY=
+87
View File
@@ -0,0 +1,87 @@
name: Installation help
description: Ask for help installing, starting or reaching the ARTEX console
title: "[install] "
labels: ["question"]
body:
- type: markdown
attributes:
value: |
Thanks for the report. Read [INSTALL.md](https://github.com/BaaRai/ARTEX/blob/main/INSTALL.md)
first and try the matching troubleshooting section. Remove the setup token, passwords, API
keys and target data from every output you paste.
- type: input
id: os
attributes:
label: OS and architecture
placeholder: Ubuntu 24.04 amd64, Windows 11 with Docker Desktop, macOS 15 arm64
validations:
required: true
- type: dropdown
id: setup
attributes:
label: Docker setup
options:
- Docker Desktop on Windows
- Docker Desktop on macOS
- Docker Engine on Linux
- Docker Engine inside WSL2
- No Docker, local binary or source build
- Other, explained below
validations:
required: true
- type: dropdown
id: method
attributes:
label: Installation method
options:
- ./install.sh
- docker compose up -d --build
- docker-compose.ghcr.yml
- Prebuilt release binary
- Built from source
- Other, explained below
validations:
required: true
- type: input
id: version
attributes:
label: Version shown in the top right
description: For example v0.7.1, main-abc1234, or dev.
placeholder: dev
- type: textarea
id: error
attributes:
label: What happens
description: The exact error, the command that produced it, and what you expected.
render: shell
validations:
required: true
- type: textarea
id: ps
attributes:
label: docker compose ps
description: Paste the full output.
render: shell
- type: textarea
id: logs
attributes:
label: docker compose logs --tail=120 artex
description: Remove the setup token, passwords, API keys and target data before pasting.
render: shell
validations:
required: true
- type: textarea
id: health
attributes:
label: Health check from the Docker host
description: Output of curl -sS http://127.0.0.1:8787/api/health
render: shell
- type: checkboxes
id: checks
attributes:
label: Before posting
options:
- label: I read INSTALL.md and tried the matching troubleshooting section.
required: true
- label: I removed the setup token, passwords, API keys and target data from the logs.
required: true
+3 -1
View File
@@ -196,7 +196,9 @@ jobs:
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: ARTEX_VERSION=${{ github.ref_name }}
build-args: |
ARTEX_VERSION=${{ github.ref_name }}
ARTEX_REVISION=${{ github.sha }}
provenance: true
sbom: true
cache-from: type=gha
+7
View File
@@ -34,6 +34,7 @@ COPY . .
# Reuse the frontend built above; build.sh skips its own frontend step.
COPY --from=web /src/web/out ./server/webui/dist
ARG ARTEX_VERSION=dev
ARG ARTEX_REVISION=
ARG TARGETOS
ARG TARGETARCH
# Same flags as the release binaries job (ARTEX_COMPRESS=0, -trimpath,
@@ -43,6 +44,7 @@ RUN ARTEX_SKIP_FRONTEND=1 \
ARTEX_COMPRESS=0 \
ARTEX_OUTPUT=/out/artex \
ARTEX_BUILD_VERSION="${ARTEX_VERSION}" \
ARTEX_REVISION="${ARTEX_REVISION}" \
bash ./build.sh --target "${TARGETOS:-linux}/${TARGETARCH:-amd64}"
# ------------------------------------------------------- third-party tools ---
@@ -160,6 +162,11 @@ RUN set -eux; \
# ---------------------------------------------------------------- runtime ---
FROM python:3.12-slim-bookworm@sha256:935c3c5b12357a7e10caa9c1e6ca5692344d97cf229832ef584be2cec9fc03df
ARG TARGETARCH
ARG ARTEX_VERSION=dev
ARG ARTEX_REVISION=
LABEL org.opencontainers.image.title="ARTEX" \
org.opencontainers.image.version="${ARTEX_VERSION}" \
org.opencontainers.image.revision="${ARTEX_REVISION}"
# Common tools: ripgrep / curl / vim, plus a set of recon staples (add/remove as needed).
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates ripgrep curl wget vim git jq unzip xz-utils \
+191
View File
@@ -0,0 +1,191 @@
# Install ARTEX
ARTEX is self-hosted. The supported setup is Docker Compose, which starts ARTEX and PostgreSQL
together. You need an LLM API key for exploration, but the console starts without one and you can
add it later in the UI.
| Path | Needs | Use it when |
| --- | --- | --- |
| One-click script | Docker with Compose v2, or Go 1.26 and Node 22 | You want the script to choose Docker or a local build |
| Docker Compose | Docker Engine 24+ or Docker Desktop, Compose v2, buildx | You want to see and control every step |
| Prebuilt binary or source build | Go 1.26, Node 22, an existing PostgreSQL | You cannot run Docker or want a single binary |
## Requirements
- Docker Engine with the Compose v2 plugin and the buildx plugin. Docker Desktop includes both.
The checkout build stops at `failed to parse platform` when buildx is missing.
- PostgreSQL 16 is started by the Compose files. A local binary or a standalone container needs an
existing database.
- An Anthropic or OpenAI compatible API key for exploration. It can be set in `.env` or later in
**System, LLM**.
- Ports 8787 (console) and 8788 (recording proxy) free on the host.
## Option 1: one-click script, recommended
```bash
git clone https://github.com/BaaRai/ARTEX.git
cd ARTEX
./install.sh
```
Choose **1) all-Docker**. The script creates `.env`, starts the stack and prints the URL. It can
also install Docker on supported Linux distributions.
Open <http://localhost:8787>. On the first visit, `/setup` asks for the one-time setup token printed
at startup:
```bash
docker compose logs artex | grep "Setup token"
```
## Option 2: Docker Compose manual
```bash
git clone https://github.com/BaaRai/ARTEX.git
cd ARTEX
cp .env.example .env # set POSTGRES_PASSWORD, optionally an LLM key
docker compose up -d --build
docker compose logs artex | grep "Setup token"
```
Open <http://localhost:8787>, paste the setup token, then choose the console password.
Check the stack:
```bash
docker compose ps
docker compose port artex 8787
curl -sS http://127.0.0.1:8787/api/health
```
`/api/health` answers `{"ok":true}` without a session. `docker compose port` should show
`127.0.0.1:8787`.
### Docker Desktop on Windows and macOS
Docker Desktop serves host bind mounts in a way that defeats the agent isolation self-test, so the
`artex` container can restart in a loop with `self-test failed`. Layer the named-volume file:
```bash
docker compose -f docker-compose.yml -f docker-compose.desktop.yml up -d --build
```
Use the same `-f` pair for later commands (`logs`, `up -d artex`, `down`). Docker Engine inside WSL2
with the repository under `/mnt/c` has the same problem: use the overlay or move the checkout to the
WSL2 native filesystem. See the README section
[Docker Desktop on Windows and macOS](README.md#docker-desktop-on-windows-and-macos) for the
migration of an existing `keys` and `data` directory.
### Access from another machine
The console binds `127.0.0.1` by default. To reach it from Windows when ARTEX runs in WSL, from a
remote server, or from another host, either keep the loopback binding and use a tunnel:
```bash
ssh -L 8787:127.0.0.1:8787 user@server
```
then open <http://localhost:8787> on your machine, or expose it deliberately:
```bash
# .env
ARTEX_BIND_ADDR=0.0.0.0
```
```bash
docker compose up -d artex
```
Only expose it behind a firewall or a reverse proxy. The setup token protects the first-run claim,
not the console afterwards.
## Other installation paths
- Prebuilt binaries and release archives: see [Installation](README.md#installation) options 3 and 5.
- Build the binary from source: see option 4 in the same section.
- Prebuilt GHCR images: the image is published from the next tagged release. Until then,
`docker-compose.ghcr.yml` and `docker pull ghcr.io/baarai/artex` return `denied`; use the checkout
build above.
## Troubleshooting
### `http://localhost:8787` does not answer
1. `docker compose ps` must show `postgres` and `artex` as running, not restarting.
2. `docker compose port artex 8787` must show a mapping. If it prints nothing, you started the wrong
Compose file or an override removed the ports.
3. `curl -sS http://127.0.0.1:8787/api/health` on the Docker host. If it returns `{"ok":true}`, ARTEX
is up and the problem is networking or the browser.
4. Read the startup log: `docker compose logs --tail=120 artex`. Do not share the setup token.
5. If the browser is not on the Docker host, see [Access from another machine](#access-from-another-machine).
### The `artex` container restarts in a loop
Look for `self-test failed` or `crash` in the logs. On Docker Desktop, or with Docker Engine inside
WSL2 on `/mnt/c`, use the [Desktop overlay](#docker-desktop-on-windows-and-macos). On native Linux,
check that `./data`, `./keys` and `./skills` are on a filesystem that enforces POSIX ownership, not a
Windows or 9p mount.
### `docker buildx version` fails
Install the buildx plugin:
- Debian/Ubuntu: `sudo apt-get install docker-buildx-plugin`
- Fedora: `sudo dnf install docker-buildx-plugin`
- macOS with Colima: `brew install docker-buildx`
### `fork/exec /usr/bin/bash: no such file or directory`
The agent Bash tool starts `bash` before running your command, so your command never ran. This is a
host or image problem, not a command error. Inside the container or on the host:
```bash
ls -l /usr/bin/bash /bin/bash /bin/sh
file /usr/bin/bash
ldd /usr/bin/bash
```
Install bash if it is missing (`apt-get install -y bash` on Debian/Ubuntu, `apk add bash` on Alpine).
If only `/bin/bash` exists, create the expected path with `ln -s /bin/bash /usr/bin/bash` as root, or
use the official Docker image, which includes bash. Restart ARTEX after the fix.
### The top right says `dev`
`dev` means the build carried no version stamp, not a different branch. A checkout built through
`install.sh` or `update.sh` on current main stamps `ARTEX_VERSION` from `git describe` and
`ARTEX_REVISION` from `git rev-parse HEAD`. To identify an older local build, run `git describe
--tags --always --dirty` or `git rev-parse HEAD` in the checkout it was built from. If the checkout is
gone, the image ID and build date are the only remaining identifiers.
### Port 8787 or 8788 is already allocated
Stop the process using the port (`ss -ltnp | grep 8787`) or change the host side of the mapping in
`docker-compose.yml`. The container side stays 8787.
### I lost the setup token
The token is printed at startup. Read it again from the current container log:
```bash
docker compose logs artex | grep -i "setup token"
```
If the first-run setup is already complete, use the console password instead. Restarting the stack
does not reset an existing password.
### The GHCR image cannot be pulled
The release image is not published yet. Use the checkout build in [Option 2](#option-2-docker-compose-manual)
until the next tagged release.
## Update and back up
Update a checkout build with `./update.sh`, or rebuild with `docker compose up -d --build` after a
`git pull`. Back up PostgreSQL, `./data` and `./keys`: see [Backups](README.md#backups). A database
dump without `keys/secret.key` cannot restore the encrypted secrets.
## Getting help
Open an installation issue with your OS, Docker setup, installation method, `docker compose ps`,
the exact error and the last 120 log lines. Remove the setup token, passwords, API keys and target
data first. The issue form asks for these fields.
+4 -1
View File
@@ -16,7 +16,7 @@ and every finding stays bound to the assets and HTTP traffic that prove it.
[![Go](https://img.shields.io/github/go-mod/go-version/BaaRai/ARTEX?color=6b34db)](go.mod)
[![Discord](https://img.shields.io/badge/Discord-join%20the%20server-5865F2?logo=discord&logoColor=white)](https://discord.gg/VKyvMTcgXh)
[Quick start](#quick-start) · [Screenshots](#screenshots) · [How it works](#how-it-works) · [Install](#installation) · [Configuration](#configuration) · [Security](SECURITY.md)
[Quick start](#quick-start) · [Install guide](INSTALL.md) · [Screenshots](#screenshots) · [How it works](#how-it-works) · [Installation](#installation) · [Configuration](#configuration) · [Security](SECURITY.md)
[![Join us on Discord](https://img.shields.io/badge/JOIN%20US%20ON-DISCORD-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/VKyvMTcgXh)
@@ -43,6 +43,9 @@ justify it, and every autonomous action passes through scope rules, approval gat
---
> **Installing ARTEX for the first time?** [INSTALL.md](INSTALL.md) has the three-command Docker
> setup, the first login with the setup token, and fixes for the most common installation errors.
## Quick start
```bash
+12 -2
View File
@@ -99,6 +99,14 @@ if [ -z "${ARTEX_BUILD_VERSION:-}" ]; then
fi
# Release tags are commonly passed with a v prefix; keep the binary version consistent.
ARTEX_BUILD_VERSION="${ARTEX_BUILD_VERSION#v}"
# Source revision, shown by /health and the UI next to the version. Docker builds
# pass it explicitly because the build context has no .git; a local build derives
# it from the checkout.
ARTEX_REVISION="${ARTEX_REVISION:-}"
if [ -z "$ARTEX_REVISION" ] && command -v git >/dev/null 2>&1 \
&& git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
ARTEX_REVISION="$(git rev-parse HEAD 2>/dev/null || true)"
fi
ARTEX_OUTPUT_DIR="${ARTEX_OUTPUT_DIR:-dist}"
ARTEX_PACKAGE_DIR="${ARTEX_PACKAGE_DIR:-$ARTEX_OUTPUT_DIR}"
ARTEX_UPX_ARGS="${ARTEX_UPX_ARGS:---best --lzma}"
@@ -213,7 +221,9 @@ build_target() {
fi
mkdir -p "$(dirname "$output")"
info "Compiling ${goos}/${goarch}, version ${ARTEX_BUILD_VERSION}"
info "Compiling ${goos}/${goarch}, version ${ARTEX_BUILD_VERSION}${ARTEX_REVISION:+ (${ARTEX_REVISION:0:12})}"
LDFLAGS="-s -w -buildid= -X main.version=${ARTEX_BUILD_VERSION}"
[ -n "${ARTEX_REVISION:-}" ] && LDFLAGS="${LDFLAGS} -X main.revision=${ARTEX_REVISION}"
GOSUMDB="$ARTEX_GOSUMDB" \
CGO_ENABLED=0 \
GOOS="$goos" \
@@ -221,7 +231,7 @@ build_target() {
go build \
-tags embedui \
-trimpath \
-ldflags "-s -w -buildid= -X main.version=${ARTEX_BUILD_VERSION}" \
-ldflags "${LDFLAGS}" \
-o "$output" \
./cmd/artex
+7 -2
View File
@@ -61,6 +61,10 @@ func logConfigSnapshot(s configSnapshot) {
// -ldflags "-X main.version=<tag>". Defaults to "dev" for local builds.
var version = "dev"
// revision is the full source commit, injected via
// -ldflags "-X main.revision=<sha>". Empty when the build had no git context.
var revision = ""
const banner = `
_ ____ _____ _______ __
/ \ | _ \_ _| ____\ \/ /
@@ -117,9 +121,10 @@ func run() int {
)
flag.Parse()
// hand the build version to the server package so GET /api/health can report it
// to the frontend top bar.
// hand the build version and source revision to the server package so
// GET /api/health can report them to the frontend top bar.
server.BuildVersion = version
server.BuildCommit = revision
printBanner(*addr)
+1
View File
@@ -28,6 +28,7 @@ services:
context: .
args:
ARTEX_VERSION: ${ARTEX_VERSION:-dev}
ARTEX_REVISION: ${ARTEX_REVISION:-}
extra_hosts:
- "host.docker.internal:host-gateway"
image: artex:local
+61
View File
@@ -0,0 +1,61 @@
# Installation video script
Audience: a first-time self-hoster who has Docker but has never seen ARTEX.
Length: 75 to 90 seconds. Format: 16:9, 1080p, terminal and browser, captions, optional calm
voiceover. The commands must match [INSTALL.md](../INSTALL.md); if the guide changes, update this
script in the same pull request.
## Before recording
- Use a clean terminal, dark theme, font size 16 or larger, and a neutral prompt such as
`~/artex-demo`.
- Use the placeholder password `change-me-please`. Never show a real setup token, API key, cookie
or target data. Replace the token with `SETUP-TOKEN` in post if needed.
- Pre-pull the base images so the build does not dominate the video.
- Keep the cursor movements deliberate. Cut dead time; do not speed up text the viewer must read.
## Shot list
| Time | Visual | On-screen text | Voiceover |
| --- | --- | --- | --- |
| 0:00 to 0:08 | ARTEX logo and console screenshot | Install ARTEX in three commands | ARTEX is self-hosted and installs with Docker Compose. |
| 0:08 to 0:20 | Requirement card | Docker Desktop or Docker Engine, Compose v2, buildx. An LLM key is optional at install time. | You need Docker with Compose v2 and buildx. PostgreSQL comes with the stack. |
| 0:20 to 0:38 | Terminal: clone, enter, copy env | `git clone`, `cd ARTEX`, `cp .env.example .env` | Clone the repository and create your environment file. |
| 0:38 to 0:48 | Editor open on `.env`, cursor on `POSTGRES_PASSWORD` | Set `POSTGRES_PASSWORD` | Set a database password. Add an LLM key here or later in the UI. |
| 0:48 to 1:05 | Terminal: compose up, compose ps | `docker compose up -d --build`, `docker compose ps` | Start the stack. Two containers come up, ARTEX and PostgreSQL. |
| 1:05 to 1:20 | Terminal: log grep, then browser at localhost:8787 | `docker compose logs artex \| grep "Setup token"` | The logs print a one-time setup token. Open localhost port 8787 and paste it. |
| 1:20 to 1:28 | Browser setup screen, fake token, password form | One-time setup, then choose your console password | Choose the console password and you are in. |
| 1:28 to 1:38 | Three troubleshooting cards | Cannot open: check `docker compose port artex 8787`. Docker Desktop: add the desktop overlay. Version says `dev`: run `./update.sh`. | If localhost does not answer, check the port mapping. On Docker Desktop use the overlay file. |
| 1:38 to 1:45 | End card | INSTALL.md, Discord | The full guide and troubleshooting are in INSTALL.md. Questions go to Discord. |
## Commands to record
```bash
git clone https://github.com/BaaRai/ARTEX.git
cd ARTEX
cp .env.example .env
# edit .env: POSTGRES_PASSWORD=change-me-please
docker compose up -d --build
docker compose ps
docker compose logs artex | grep "Setup token"
# open http://localhost:8787
```
Docker Desktop alternative for the troubleshooting card:
```bash
docker compose -f docker-compose.yml -f docker-compose.desktop.yml up -d --build
```
## Caption style
- Commands in monospace, one per line, no wrapping in the middle of a flag.
- Say "localhost port 8787" instead of reading the URL character by character.
- Use "one-time setup token", not "password", for the token.
- No meme captions or hype. The tone is a short, accurate setup demo.
## What not to show
- A real setup token, database password, API key or JWT.
- Real target names or captured traffic.
- A terminal history or shell prompt containing a username you do not want published.
+40 -2
View File
@@ -9,6 +9,40 @@ warn(){ printf '\033[33m[!]\033[0m %s\n' "$*"; }
die(){ printf '\033[31m[x]\033[0m %s\n' "$*" >&2; exit 1; }
ask(){ local p="$1" d="${2:-}" a; read -rp "$p${d:+ [$d]}: " a; echo "${a:-$d}"; }
rand(){ head -c 18 /dev/urandom | base64 | tr -dc 'A-Za-z0-9' | head -c 24; }
# ── Build identity: keep .env and the binary in step with the checkout ─────────
BUILD_VERSION="dev"
BUILD_REVISION=""
# set_env replaces KEY=... in .env (or appends it) without touching other lines.
set_env(){
local key="$1" value="$2" tmp
tmp="$(mktemp)"
awk -v k="$key" -v v="$value" '
$0 ~ "^" k "=" { print k "=" v; found=1; next }
{ print }
END { if (!found) print k "=" v }
' .env > "$tmp"
chmod --reference=.env "$tmp" 2>/dev/null || true
mv "$tmp" .env
}
# stamp_version records the commit the image or binary is built from. Without it
# docker-compose.yml passes ARTEX_VERSION=dev and every local install reports the
# same meaningless version in the UI and the startup banner.
stamp_version(){
if ! command -v git >/dev/null 2>&1 || ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
warn "not a git working copy: leaving ARTEX_VERSION in .env unchanged"
return 0
fi
BUILD_VERSION="$(git describe --tags --always --dirty 2>/dev/null || git rev-parse --short HEAD)"
BUILD_REVISION="$(git rev-parse HEAD 2>/dev/null || true)"
if [ -f .env ]; then
set_env ARTEX_VERSION "$BUILD_VERSION"
[ -n "$BUILD_REVISION" ] && set_env ARTEX_REVISION "$BUILD_REVISION"
fi
ok "Build identity: ${BUILD_VERSION}${BUILD_REVISION:+ (${BUILD_REVISION:0:12})}"
}
# json_str prints $1 as a JSON string literal: backslash, double quote and the
# control characters read -r can return are escaped.
json_str(){
@@ -121,6 +155,7 @@ install_docker(){
else
info "reusing existing .env"
fi
stamp_version
info "building the image from this checkout and starting..."
docker compose up -d --build
ok "started → http://localhost:8787"
@@ -168,6 +203,9 @@ JSON
# go environment check
command -v go >/dev/null 2>&1 || die "Go not detected; please install Go (>=1.26) first: https://go.dev/dl/"
ok "Go: $(go version)"
stamp_version
LDFLAGS="-X main.version=${BUILD_VERSION}"
[ -n "${BUILD_REVISION}" ] && LDFLAGS="${LDFLAGS} -X main.revision=${BUILD_REVISION}"
# embedding the frontend requires node to produce the static assets
if command -v npm >/dev/null 2>&1; then
@@ -175,10 +213,10 @@ JSON
( cd web && npm ci --ignore-scripts && npm run build:static )
rm -rf server/webui/dist && mkdir -p server/webui && cp -r web/out server/webui/dist
info "compiling embedded single binary..."
CGO_ENABLED=0 go build -tags embedui -trimpath -o artex ./cmd/artex
CGO_ENABLED=0 go build -tags embedui -trimpath -ldflags "${LDFLAGS}" -o artex ./cmd/artex
else
warn "npm not detected: building a backend WITHOUT the embedded frontend (run npm run dev separately for the frontend)"
CGO_ENABLED=0 go build -o artex ./cmd/artex
CGO_ENABLED=0 go build -ldflags "${LDFLAGS}" -o artex ./cmd/artex
fi
ok "build complete → ./artex"
+40
View File
@@ -0,0 +1,40 @@
package server
import "runtime/debug"
// BuildCommit is the full source commit, injected from cmd/artex (which gets it
// from -ldflags "-X main.revision=<sha>"). Empty when the build had no git
// context; currentBuildInfo falls back to the VCS stamp Go embeds for local
// builds.
var BuildCommit = ""
// buildInfo is the build identity reported by GET /api/health. Version is the
// value shown in the UI top bar; Commit lets "dev" builds still name their
// source revision.
type buildInfo struct {
Version string `json:"version"`
Commit string `json:"commit,omitempty"`
GoVersion string `json:"go_version,omitempty"`
BuildTime string `json:"build_time,omitempty"`
Modified bool `json:"modified,omitempty"`
}
func currentBuildInfo(version, commit string) buildInfo {
bi := buildInfo{Version: version, Commit: commit}
if info, ok := debug.ReadBuildInfo(); ok {
bi.GoVersion = info.GoVersion
for _, s := range info.Settings {
switch s.Key {
case "vcs.revision":
if bi.Commit == "" {
bi.Commit = s.Value
}
case "vcs.time":
bi.BuildTime = s.Value
case "vcs.modified":
bi.Modified = s.Value == "true"
}
}
}
return bi
}
+28
View File
@@ -0,0 +1,28 @@
package server
import "testing"
func TestCurrentBuildInfoUsesInjectedIdentity(t *testing.T) {
bi := currentBuildInfo("main-test", "0123456789abcdef")
if bi.Version != "main-test" {
t.Fatalf("Version = %q, want main-test", bi.Version)
}
if bi.Commit != "0123456789abcdef" {
t.Fatalf("Commit = %q, want the injected revision", bi.Commit)
}
if bi.GoVersion == "" {
t.Fatal("GoVersion is empty; debug.ReadBuildInfo should report the toolchain")
}
}
func TestCurrentBuildInfoDevWithoutRevision(t *testing.T) {
bi := currentBuildInfo("dev", "")
if bi.Version != "dev" {
t.Fatalf("Version = %q, want dev", bi.Version)
}
// A test binary has no VCS stamp, so the empty commit stays empty rather
// than turning into a misleading value.
if bi.Commit != "" {
t.Fatalf("Commit = %q, want empty when the build has no revision", bi.Commit)
}
}
+1 -1
View File
@@ -1136,7 +1136,7 @@ func (s *Server) health(w http.ResponseWriter, r *http.Request) {
writeJSON(w, 200, map[string]any{"ok": true})
return
}
out := map[string]any{"ok": true, "service": "artex", "version": BuildVersion}
out := map[string]any{"ok": true, "service": "artex", "version": BuildVersion, "build": currentBuildInfo(BuildVersion, BuildCommit)}
// The web UI shows a banner on every page for a degraded isolation (isolation.go).
if s.isolation.Mode != "" {
out["isolation"] = s.isolation
+49 -12
View File
@@ -12,21 +12,56 @@ warn(){ printf '\033[33m[!]\033[0m %s\n' "$*"; }
die(){ printf '\033[31m[x]\033[0m %s\n' "$*" >&2; exit 1; }
ask(){ local p="$1" d="${2:-}" a; read -rp "$p${d:+ [$d]}: " a; echo "${a:-$d}"; }
# ── Build identity: keep .env and the binary in step with the checkout ─────────
BUILD_VERSION="dev"
BUILD_REVISION=""
# set_env replaces KEY=... in .env (or appends it) without touching other lines.
set_env(){
local key="$1" value="$2" tmp
tmp="$(mktemp)"
awk -v k="$key" -v v="$value" '
$0 ~ "^" k "=" { print k "=" v; found=1; next }
{ print }
END { if (!found) print k "=" v }
' .env > "$tmp"
chmod --reference=.env "$tmp" 2>/dev/null || true
mv "$tmp" .env
}
# stamp_version records the commit the image is about to be built from. Without
# it docker-compose.yml passes ARTEX_VERSION=dev and every local install reports
# the same meaningless version in the UI and the startup banner.
stamp_version(){
if ! command -v git >/dev/null 2>&1 || ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
warn "not a git working copy: leaving ARTEX_VERSION in .env unchanged"
return 0
fi
BUILD_VERSION="$(git describe --tags --always --dirty 2>/dev/null || git rev-parse --short HEAD)"
BUILD_REVISION="$(git rev-parse HEAD 2>/dev/null || true)"
if [ -f .env ]; then
set_env ARTEX_VERSION "$BUILD_VERSION"
[ -n "$BUILD_REVISION" ] && set_env ARTEX_REVISION "$BUILD_REVISION"
fi
ok "Build identity: ${BUILD_VERSION}${BUILD_REVISION:+ (${BUILD_REVISION:0:12})}"
}
# ── Optional: sync the repo to the latest code (compose/scripts/local build sources all update through it) ───────
sync_repo(){
[ -d .git ] && command -v git >/dev/null 2>&1 || { warn "not a git working copy, skipping git pull"; return; }
[ "$(ask 'Pull the latest code (git pull --ff-only)? (y/n)' y)" = y ] || return
if ! git pull --ff-only; then
# Continuing would rebuild the OLD tree and still print "Build complete":
# exactly the silent stale upgrade this script exists to prevent.
cat >&2 <<'RECOVER'
[ -d .git ] && command -v git >/dev/null 2>&1 || { warn "not a git working copy, skipping git pull"; return 0; }
if [ "$(ask 'Pull the latest code (git pull --ff-only)? (y/n)' y)" = y ]; then
if ! git pull --ff-only; then
# Continuing would rebuild the OLD tree and still print "Build complete":
# exactly the silent stale upgrade this script exists to prevent.
cat >&2 <<'RECOVER'
[!] git pull could not fast-forward. This happens when the checkout has local
changes, or when it was cloned before the history rewrite of 2026-10-23.
Refusing to rebuild stale code. Recover, then rerun this script:
keep your changes: git stash && git fetch origin && git reset --hard origin/main && git stash pop
discard them: git fetch origin && git reset --hard origin/main
RECOVER
die "aborting: nothing was rebuilt"
die "aborting: nothing was rebuilt"
fi
fi
}
@@ -55,16 +90,18 @@ update_local(){
command -v go >/dev/null 2>&1 || die "Go (>=1.26) not detected: https://go.dev/dl/"
[ -f config.json ] || warn "config.json not found — use ./install.sh instead for a first-time deployment"
ok "Go: $(go version)"
LDFLAGS="-X main.version=${BUILD_VERSION}"
[ -n "${BUILD_REVISION}" ] && LDFLAGS="${LDFLAGS} -X main.revision=${BUILD_REVISION}"
if command -v npm >/dev/null 2>&1; then
info "Rebuilding frontend static assets…"
( cd web && npm ci --ignore-scripts && npm run build:static )
rm -rf server/webui/dist && mkdir -p server/webui && cp -r web/out server/webui/dist
info "Recompiling the embedded single binary…"
CGO_ENABLED=0 go build -tags embedui -trimpath -o artex ./cmd/artex
info "Recompiling the embedded single binary (version ${BUILD_VERSION})…"
CGO_ENABLED=0 go build -tags embedui -trimpath -ldflags "${LDFLAGS}" -o artex ./cmd/artex
else
warn "npm not detected: building a backend **without the embedded frontend** (run the frontend separately with npm run dev)"
CGO_ENABLED=0 go build -o artex ./cmd/artex
CGO_ENABLED=0 go build -ldflags "${LDFLAGS}" -o artex ./cmd/artex
fi
ok "Build complete → ./artex"
warn "Restart the running artex process to take effect (schema migrates automatically on restart)"
@@ -76,7 +113,7 @@ echo " 1) Docker update (pull new image and rebuild)"
echo " 2) Local update (rebuild with go)"
echo "=============================="
case "$(ask 'Choose' 1)" in
1) sync_repo; update_docker ;;
2) sync_repo; update_local ;;
1) sync_repo; stamp_version; update_docker ;;
2) sync_repo; stamp_version; update_local ;;
*) die "invalid choice" ;;
esac
@@ -50,7 +50,11 @@ export function MainContent({ children }: { children: ReactNode }) {
api
.health()
.then((h) => {
setVersion((h.version ?? "").replace(/^v(?=\d)/, ""));
const v = (h.version ?? "").replace(/^v(?=\d)/, "");
// A local "dev" build still identifies its source revision when the Go
// VCS stamp (or -X main.revision) is present.
const commit = h.build?.commit ?? "";
setVersion(v === "dev" && commit ? `${v} (${commit.slice(0, 7)})` : v);
const l = h.latest_version ?? "";
setLatest(l && getLocalStorageValue(UPDATE_DISMISSED_KEY) !== l ? l : "");
setDegraded(h.isolation?.mode === "degraded" ? (h.isolation.reason ?? "") : null);
+9
View File
@@ -278,12 +278,21 @@ function interceptPageQuery(page: number, size: number, filter: InterceptApprova
export const api = {
// Backend application version (injected via ldflags at release, default "dev").
// build.commit fills in the source revision for local builds, so the top bar
// can show `dev (abc1234)` instead of a version that identifies nothing.
// isolation: result of the startup agent isolation self-test; "degraded" shows a banner on every page.
health: () =>
get<{
ok: boolean;
service: string;
version: string;
build?: {
version: string;
commit?: string;
go_version?: string;
build_time?: string;
modified?: boolean;
};
latest_version?: string;
isolation?: { mode: "isolated" | "degraded"; reason?: string };
}>("/health"),