Files
noc/Makefile
Fam Zheng 035d9b9be2 add suite: all-in-one Docker image with noc + Gitea
- Switch to rustls (drop OpenSSL dependency) for musl static build
- Add deploy/ with Dockerfile and entrypoint (Gitea auto-setup + admin token)
- Add Makefile targets: build-musl, docker
- Add doc/suite.md: design doc for human-AI collaboration interfaces
2026-04-10 21:09:15 +01:00

55 lines
1.9 KiB
Makefile

REPO := $(shell pwd)
HERA := heradev
HERA_DIR := noc
IMAGE := noc-suite
.PHONY: build build-musl test deploy deploy-hera docker
build:
cargo build --release
build-musl:
cargo build --release --target x86_64-unknown-linux-musl
strip target/x86_64-unknown-linux-musl/release/noc
test:
cargo clippy -- -D warnings
cargo test -- --nocapture
# ── docker ──────────────────────────────────────────────────────────
docker: build-musl
cp target/x86_64-unknown-linux-musl/release/noc deploy/noc
cp -r tools deploy/tools
cp config.example.yaml deploy/config.example.yaml
sudo docker build -t $(IMAGE) deploy/
rm -f deploy/noc deploy/config.example.yaml
rm -rf deploy/tools
# ── systemd deploy ──────────────────────────────────────────────────
noc.service: noc.service.in
sed -e 's|@REPO@|$(REPO)|g' -e 's|@PATH@|$(PATH)|g' $< > $@
deploy: test build noc.service
mkdir -p ~/bin ~/.config/systemd/user
systemctl --user stop noc 2>/dev/null || true
install target/release/noc ~/bin/noc
cp noc.service ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable --now noc
systemctl --user restart noc
deploy-hera: build
ssh $(HERA) 'mkdir -p ~/bin ~/$(HERA_DIR) ~/.config/systemd/user && systemctl --user stop noc 2>/dev/null || true'
scp target/release/noc $(HERA):~/bin/
scp config.hera.yaml noc.service.in $(HERA):~/$(HERA_DIR)/
ssh $(HERA) 'bash -lc "\
cd ~/$(HERA_DIR) \
&& mv -f config.hera.yaml config.yaml \
&& sed -e \"s|@REPO@|\$$HOME/$(HERA_DIR)|g\" -e \"s|@PATH@|\$$PATH|g\" noc.service.in > ~/.config/systemd/user/noc.service \
&& systemctl --user daemon-reload \
&& systemctl --user enable --now noc \
&& systemctl --user restart noc \
&& systemctl --user status noc"'