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 SUITE := noc SUITE_DIR := noc GITEA_VERSION := 1.23 deploy-suite: build ssh $(SUITE) 'mkdir -p ~/bin /data/noc/tools ~/.config/systemd/user && systemctl --user stop noc 2>/dev/null || true' scp target/release/noc $(SUITE):~/bin/ scp config.suite.yaml $(SUITE):/data/noc/config.yaml scp noc.service.in $(SUITE):/data/noc/ scp -r tools/ $(SUITE):/data/noc/tools/ ssh $(SUITE) 'bash -lc "\ cd /data/noc \ && sed -e \"s|@REPO@|/data/noc|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"' 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"'