build: add multi-stage Dockerfile for HTTP / k3s deployment#11
build: add multi-stage Dockerfile for HTTP / k3s deployment#11jacky1967 wants to merge 1 commit into
Conversation
Adds a Dockerfile to enable container deployment of the graphthulhu-vault
HTTP server, useful for k3s clusters or dedicated Linux servers.
- Multi-stage build: golang:1.24-alpine -> alpine:3.20
- Static binary: CGO_ENABLED=0, stripped via -ldflags "-s -w"
- Final image: 27.4 MB
- Read-only vault mount via -v /path:/vault:ro
- Default CMD targets serve --backend obsidian on :7878
Note: volume-mounted vaults on macOS Docker Desktop suffer from degraded
fsnotify performance. The native binary remains preferred for local macOS
workflows. Container deployment is intended for Linux hosts or k3s clusters.
Build: docker build -t graphthulhu-vault:dev .
Run: docker run --rm -p 7878:7878 -v /path/to/vault:/vault:ro \
graphthulhu-vault:dev serve --backend obsidian \
--vault /vault --http :7878
|
Thanks for this - the multi-stage layering and static build are great. Before merging, a few small things if you don't mind:
Also if it's no trouble, would you mind translating the comments to English for the upstream? Happy to keep the structure and explanation, just in English. Thanks again - useful contribution. |
Summary
Adds a multi-stage
Dockerfileto enable container deployment of thegraphthulhuHTTP server, targeting k3s clusters or dedicated Linux servers.Motivation
Several downstream uses (Linux-only environments, k3s deployments, multi-tenant hosting, CI test rigs) benefit from a ready-to-build container image. Until now only the native binary was distributed.
What's added
A 27-line
Dockerfile, multi-stage:golang:1.24-alpine,go.mod/go.sumcopied first for layer caching,CGO_ENABLED=0 GOOS=linuxstatic binary stripped via-ldflags "-s -w".alpine:3.20+ca-certificatesonly.ENTRYPOINT+CMDexposingserve --backend obsidian --vault /vault --http :7878on port7878./vault.Image size
Tested
docker build -t graphthulhu-vault:dev .succeeds cleanly.docker run --rm graphthulhu-vault:dev --helpreturns the expected CLI usage.No side-effect
go.mod/go.sumuntouched).Caveats
Volume-mounted vaults on macOS Docker Desktop suffer from degraded
fsnotifyperformance (well-known Docker-for-Mac limitation). The native binary remains preferred for local macOS workflows; container deployment is intended for Linux hosts or k3s clusters.Usage
docker build -t graphthulhu-vault:dev . docker run --rm -p 7878:7878 \ -v /path/to/vault:/vault:ro \ graphthulhu-vault:dev \ serve --backend obsidian --vault /vault --http :7878Happy to iterate on naming, base image, or
HEALTHCHECKif you'd like.