mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-09-19 16:39:15 +00:00
Previously only the Electron GUI had installers; server admins had to build the
core by hand (`make build` -> bare binary). This adds a first-class server
distribution:
- `make core-dist` -> packaging/core-dist.sh -> cmd/build/dist/
llmsproxy_<ver>_amd64.deb (systemd unit + adapters + example config)
llmsproxy-<ver>.x86_64.rpm
llmsproxy-<ver>-linux-amd64.tar.gz
- nfpm config (packaging/nfpm.yaml): binary to /usr/bin, systemd unit with the
measured memory tuning (GOGC=50, MALLOC_ARENA_MAX=2) baked in, Lua adapters to
/usr/share/llmsproxy/adapters, repo's config.yaml as the example.
- postinst seeds /etc/llmsproxy/config.yaml on first install and keeps existing
runtime state across reinstalls; prerm stops the service on removal.
Gotchas handled: nfpm v2 here does not render `{{ .Env.VERSION }}`, so the script
stamps the version into a throwaway config copy; and under `set -o pipefail` the
idiom `strings | grep -q` is broken (grep -q closes the pipe and strings dies on
SIGPIPE -> spurious 141), so the symbol sanity-gate stages strings in a temp file.
README (zh/en) updated: memory figures replaced with production-measured
32-35 MB settled (was 37-42), and the packaging docs now describe core-dist and
the dockerized Windows build.
83 lines
2.9 KiB
Makefile
83 lines
2.9 KiB
Makefile
.PHONY: all build test gui gui-dev gui-dist gui-deb gui-win gui-win-docker help clean
|
|
|
|
# ModelRouter - single-binary gateway + optional Electron desktop GUI (embedded core)
|
|
export BINARY
|
|
BINARY=llmsproxy
|
|
export BUILD_DIR
|
|
BUILD_DIR=build
|
|
export GUI_DIR
|
|
GUI_DIR=cmd/gui
|
|
VERSION ?= $(shell git describe --tags --dirty 2>/dev/null || echo "0.1.0")
|
|
|
|
# Clean env for GUI packaging: the host may have LD_LIBRARY_PATH polluted by
|
|
# third-party runtimes (e.g. /opt/cangjie) which electron-builder bakes into
|
|
# the produced binary's DT_RPATH/dep resolution -> the packaged app then
|
|
# SIGSEGVs inside ld.so on clean machines. Strip it for every pack step.
|
|
CLEAN_PACK_ENV = env -u LD_LIBRARY_PATH
|
|
|
|
all: build
|
|
|
|
# ---- core binary (server users / embedded core) ----
|
|
build:
|
|
@mkdir -p $(BUILD_DIR)
|
|
CGO_ENABLED=1 go build -tags luajit -trimpath -o $(BUILD_DIR)/$(BINARY) ./cmd/llmsproxy
|
|
@echo "Built: $(BUILD_DIR)/$(BINARY) ($(VERSION))"
|
|
|
|
# ---- core distribution packages (deb + rpm + tar.gz) -----
|
|
# Server admins install these with dpkg/rpm; unlike the GUI they are the bare
|
|
# gateway binary + systemd unit (with memory tuning) + Lua adapters.
|
|
core-dist:
|
|
./packaging/core-dist.sh $(VERSION)
|
|
|
|
.PHONY: core-dist
|
|
|
|
# ---- GUI (Electron) ----
|
|
gui:
|
|
@cd $(GUI_DIR) && npm start
|
|
|
|
gui-dev:
|
|
@cd $(GUI_DIR) && npm run dev
|
|
|
|
# build the embedded core into the GUI, then run electron-builder
|
|
# targets: deb + rpm + AppImage (linux); rpm needs system rpmbuild
|
|
# NOTE: run in a clean env (no LD_LIBRARY_PATH pollution) so the packaged
|
|
# binary does not link against host-only libs and crash on user machines.
|
|
gui-dist:
|
|
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) npm run dist:linux
|
|
./packaging/verify-dist.sh
|
|
|
|
# deb only (for local sharing), rpm needs rpmbuild
|
|
gui-deb:
|
|
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) npm run dist:debian
|
|
|
|
# windows nsis installer: host-built core (needs apt install gcc-mingw-w64-x86-64 + wine)
|
|
gui-win:
|
|
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) npm run dist:win
|
|
|
|
# windows nsis installer: full cross-build in docker (self-sufficient, no host mingw)
|
|
gui-win-docker:
|
|
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) ./scripts/dist-win-docker.sh
|
|
./packaging/verify-dist.sh
|
|
|
|
gui-dist-dir:
|
|
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) npm run dist:dir
|
|
|
|
test:
|
|
go test ./...
|
|
|
|
clean:
|
|
rm -rf $(BUILD_DIR) cmd/build cmd/gui/dist cmd/gui/build/gui-dist cmd/gui/bin
|
|
|
|
help:
|
|
@echo "Targets:"
|
|
@echo " make build build core binary (luajit)"
|
|
@echo " make core-dist build core packages: deb + rpm + tar.gz (needs nfpm)"
|
|
@echo " make gui run desktop GUI (dev)"
|
|
@echo " make gui-dev run GUI with devtools"
|
|
@echo " make gui-dist build deb + rpm + AppImage (linux)"
|
|
@echo " make gui-deb build deb only"
|
|
@echo " make gui-win build Windows nsis (needs host mingw + wine)"
|
|
@echo " make gui-win-docker build Windows nsis all-in-docker (no host mingw needed)"
|
|
@echo " make test run go tests"
|
|
@echo " make clean remove build dirs and packaged installers (build/, cmd/build/, cmd/gui/dist/)"
|