Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
env:
SHA: ${{ steps.sha.outputs.sha }}
run: |
docker build --build-arg "VERSION=$SHA" -t "$APP-local:$SHA" .
docker build --build-arg "VERSION=$SHA" --build-arg "BUILD_SHA=$SHA" -t "$APP-local:$SHA" .
docker save "$APP-local:$SHA" | gzip > image.tar.gz
ls -lh image.tar.gz

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

- name: Build image
run: |
docker build --build-arg "VERSION=$GITHUB_SHA" -t "$APP-local:$GITHUB_SHA" .
docker build --build-arg "VERSION=$GITHUB_SHA" --build-arg "BUILD_SHA=$GITHUB_SHA" -t "$APP-local:$GITHUB_SHA" .
docker save "$APP-local:$GITHUB_SHA" | gzip > image.tar.gz
ls -lh image.tar.gz

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
ghcr.io/meltforce/vimmary:latest
build-args: |
VERSION=${{ github.ref_name }}
BUILD_SHA=${{ github.sha }}

- name: GitHub release
env:
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ COPY --from=frontend /app/web/dist ./web/dist
# /version and the loopback /healthz report it as "build"; pipeline-deploy
# waits for the SHA on /version. Without it every build reports "dev".
ARG VERSION=dev
# The full commit SHA; /healthz on the real listener reports it as "sha".
ARG BUILD_SHA=dev
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags="-s -w -X main.Version=${VERSION}" -o vimmary ./cmd/vimmary
go build -ldflags="-s -w -X main.Version=${VERSION} -X main.BuildSHA=${BUILD_SHA}" -o vimmary ./cmd/vimmary

# Stage 3: Runtime
FROM alpine:3.24
Expand Down
6 changes: 5 additions & 1 deletion cmd/vimmary/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ import (

var Version = "dev"

// BuildSHA is the commit the binary was built from, set at build time via
// -ldflags from the BUILD_SHA build argument. /healthz reports it.
var BuildSHA = "dev"

// The startup sequence is the subject of two entries in INCIDENTS.md, both from
// 2026-08-06, and both about the order rather than about any single step. It is
// therefore spread over the named functions below in the order they must run:
Expand Down Expand Up @@ -394,7 +398,7 @@ func runMCPStdio(svc *service.Service, log *slog.Logger) error {
// openListener, and keeping the two apart is what lets the health listener come
// after everything is mounted.
func buildHTTPServer(cfg *config.Config, svc *service.Service, store *storage.DB, authn *auth.Auth, log *slog.Logger) (*server.Server, error) {
srv := server.New(svc, store, Version, log, authn)
srv := server.New(svc, store, Version, BuildSHA, log, authn)

// With login configured, /mcp takes personal access tokens with scope
// mcp, and WhoIs only while tsnet runs; without it, WhoIs as before.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/horiagug/youtube-transcript-api-go v0.0.13
github.com/jackc/pgx/v5 v5.13.0
github.com/mark3labs/mcp-go v1.5.0
github.com/meltforce/meltkit v0.4.0
github.com/meltforce/meltkit v0.4.1
github.com/pgvector/pgvector-go v0.4.1
github.com/yuin/goldmark v1.8.7
golang.org/x/term v0.48.0
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ github.com/mdlayher/sdnotify v1.0.0 h1:Ma9XeLVN/l0qpyx1tNeMSeTjCPH6NtuD6/N9XdTlQ
github.com/mdlayher/sdnotify v1.0.0/go.mod h1:HQUmpM4XgYkhDLtd+Uad8ZFK1T9D5+pNxnXQjCeJlGE=
github.com/mdlayher/socket v0.7.0 h1:qVREPVwtUMg17pwvveQxpurq0PVisMxi3FGgpsorMYQ=
github.com/mdlayher/socket v0.7.0/go.mod h1:f7iKql2EK/rfsWYDKofKjk2Ig7I+6HQWdMIdn1tO4A4=
github.com/meltforce/meltkit v0.3.0 h1:cic5C9gaJUlNFWMAl/Wu1gpC7gSB2sHNJDjSaZTmO8Q=
github.com/meltforce/meltkit v0.3.0/go.mod h1:CYQKT7ZNW2yTZVvll0jbhz1KsZ2K2K6zXf+ZhIX+gDc=
github.com/meltforce/meltkit v0.4.0 h1:+PEITWLt5caApuUXoyORHWZKB26zSWv0mFgZPInHfsk=
github.com/meltforce/meltkit v0.4.0/go.mod h1:CYQKT7ZNW2yTZVvll0jbhz1KsZ2K2K6zXf+ZhIX+gDc=
github.com/meltforce/meltkit v0.4.1 h1:d1IvaZmV9H+0x3XFxqeVB8D5IT2OQ1u2DIJ+LauRGIg=
github.com/meltforce/meltkit v0.4.1/go.mod h1:CYQKT7ZNW2yTZVvll0jbhz1KsZ2K2K6zXf+ZhIX+gDc=
github.com/miekg/dns v1.1.73 h1:uhT8nJxmTrPJYClxVxTCX+CVn6qnzSiybRk72Z6DgrE=
github.com/miekg/dns v1.1.73/go.mod h1:RW2Obtfd5NZHvOFe3zYG0W8koWOQtAzyHaLo8vASBuQ=
github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc=
Expand Down
34 changes: 34 additions & 0 deletions internal/server/health_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package server

import (
"io"
"log/slog"
"net/http"
"net/http/httptest"
"testing"
)

// /healthz on the real listener reports status and the commit the image was
// built from; "dev" outside a pipeline build.
func TestHealthzReportsBuildSHA(t *testing.T) {
const sha = "0123456789abcdef0123456789abcdef01234567"
log := slog.New(slog.NewTextHandler(io.Discard, nil))
for _, tc := range []struct{ name, sha, want string }{
{"pipeline build", sha, `{"status":"ok","sha":"` + sha + `"}`},
{"local build", "dev", `{"status":"ok","sha":"dev"}`},
} {
t.Run(tc.name, func(t *testing.T) {
rec := httptest.NewRecorder()
newBase(tc.sha, log).ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/healthz", nil))
if rec.Code != http.StatusOK {
t.Errorf("status = %d, want 200", rec.Code)
}
if ct := rec.Header().Get("Content-Type"); ct != "application/json" {
t.Errorf("Content-Type = %q, want application/json", ct)
}
if rec.Body.String() != tc.want {
t.Errorf("body = %q, want %q", rec.Body.String(), tc.want)
}
})
}
}
21 changes: 14 additions & 7 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,18 @@ type Server struct {
isDisabled func(ctx context.Context, userID int) (bool, error)
}

// New builds the router. authn is nil when login is not configured.
func New(svc *service.Service, store *storage.DB, version string, log *slog.Logger, authn *auth.Auth) *Server {
// newBase builds the meltkit server, whose /healthz answers
// {"status":"ok","sha":"<sha>"} (homelab STANDARDS.md § Image registry &
// tagging).
func newBase(sha string, log *slog.Logger) *mkserver.Server {
return mkserver.New(mkserver.WithLogger(log), mkserver.WithBuildSHA(sha))
}

// New builds the router. sha is the commit /healthz reports. authn is nil
// when login is not configured.
func New(svc *service.Service, store *storage.DB, version, sha string, log *slog.Logger, authn *auth.Auth) *Server {
s := &Server{
Server: mkserver.New(mkserver.WithLogger(log)),
Server: newBase(sha, log),
svc: svc,
store: store,
version: version,
Expand All @@ -57,10 +65,9 @@ func (s *Server) routes() {
r := s.Router()

// Version route — no Tailscale auth, same as /healthz. It reports which
// build is serving, which is what lets a deploy gate tell a real rollout
// from a green pipeline over an unchanged image. meltkit owns /healthz and
// answers a fixed "ok", so this is a route of its own rather than an
// override.
// build is serving and whether the database answers; pipeline-deploy waits
// on it. meltkit owns /healthz, which reports status and the build SHA
// without touching the database, so this is a route of its own.
r.Get("/version", s.handleVersion)

// Webhook route — no Tailscale auth, uses per-user Bearer token
Expand Down
2 changes: 1 addition & 1 deletion scripts/e2e
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if [[ "$upgrade" == 1 ]]; then
fi

step "building vimmary-local:${BUILD_SHA}"
docker build -q --build-arg "VERSION=${BUILD_SHA}" -t "vimmary-local:${BUILD_SHA}" . >/dev/null
docker build -q --build-arg "VERSION=${BUILD_SHA}" --build-arg "BUILD_SHA=${BUILD_SHA}" -t "vimmary-local:${BUILD_SHA}" . >/dev/null

if [[ "$upgrade" == 1 ]]; then
step "1. base image on an empty database"
Expand Down
Loading