Bundle the frontend into one binary with production CLI startup - #8
Merged
luhe19001 merged 6 commits intoAug 4, 2026
Conversation
Serve the compiled frontend and the API from one loopback origin, so running the product needs neither Node nor a second process. Go cannot embed ../frontend/dist, so `make release` stages it into internal/web/dist before compiling; the staged copy stays untracked behind a committed placeholder that keeps the package building in a plain checkout. A binary without staged assets says so at / instead of serving nothing, which keeps `make run` plus `npm run dev` working. The frontend handler serves real files as themselves, extensionless paths as index.html so client routes survive a refresh, and anything else as a 404 — a missing hashed asset is a broken build, not a route. An unrouted /api path 404s rather than falling through to the SPA. Add --version (ldflags-injected), --port, and --no-open, and bind the listener before opening the browser so a port conflict is an error the user reads rather than a tab pointed at nothing. Handlers move to api.go unchanged, leaving main.go to startup.
Make build-and-run the path people follow first, with clear paths from the collector directory and a short develop note. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep the release path simple while the product shell is still settling. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
Reduce inline comments, only use inline comments for todos or special cases, not as overall logic or plan |
milanshen
reviewed
Aug 4, 2026
milanshen
reviewed
Aug 4, 2026
- `build`, `run`, and `clean` now clear internal/web/dist first, so a build after `make release` no longer embeds that release's frontend. - `make run` passes --no-open; the README points dev at Vite on 5173. - Cut the explanatory inline comments added by this branch.
Collaborator
Author
|
Trimmed the comments in |
Captures the conventions this PR's review surfaced — comment discipline, build targets that clear the state they consume, and docs that match real behavior. Discoverable by Codex via .agents/skills, Claude Code via the .claude/skills link, and Cursor via a .cursor rule.
SKILL.md is all the skill needs; openai.yaml only earns its place when a skill declares tool dependencies.
luhe19001
deleted the
helu/eng-1313-bundle-the-frontend-into-one-binary-with-production-cli
branch
August 4, 2026 03:56
luhe19001
restored the
helu/eng-1313-bundle-the-frontend-into-one-binary-with-production-cli
branch
August 4, 2026 04:03
This was referenced Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Running the product needed Node, Vite, and a separate API process. This change produces one executable that serves the compiled React app and the Go API from the same loopback origin, so a release build is enough to run the full product locally.
Host/origin hardening, CI for the release path, and published artifacts are intentionally out of scope.
Changes
make releasebuilds the frontend, stages it into the Go module for embedding, and writes a singlebin/coslashbinary; missingindex.htmlfails the build clearly.index.htmlfor client routes like/coslash, and returns 404 for missing asset paths and unrouted/api/*paths.--version,--port, and--no-open, with actionable errors for port conflicts and browser-open failures.Test
make release— passedgo build ./...— passed--port 8899 --no-open/and/coslash→ 200 HTML/assets/*→ 200/api/sessions→ 200 JSON/api/bogus→ 404--version, bad--port, and port conflict → actionable errors