mirror of
https://github.com/qwibitai/nanoclaw.git
synced 2026-06-04 10:14:47 +08:00
7a9401ddf2
Two NanoClaw installs on the same host used to fight over the shared `com.nanoclaw` launchd label / `nanoclaw.service` systemd unit and the `nanoclaw-agent:latest` docker tag — the second install silently rewrote the service pointer and rebuilt the image out from under the first. Introduces a deterministic per-checkout slug (sha1(projectRoot)[:8]) and namespaces everything off it: - Service: `com.nanoclaw-v2-<slug>` / `nanoclaw-v2-<slug>.service` - Image: `nanoclaw-agent-v2-<slug>:latest` (base), `nanoclaw-agent-v2-<slug>:<agentGroupId>` (per-group) New shared helpers: src/install-slug.ts (host) + setup/lib/install-slug.sh (bash). Both compute the same slug so verify/probe/add-*.sh/build.sh/container-runner all agree. Any v1 `com.nanoclaw` service left on the host stays untouched and can coexist. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
46 lines
1.7 KiB
Bash
Executable File
46 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# Build the NanoClaw agent container image.
|
|
#
|
|
# Reads one optional build flag from ../.env:
|
|
# INSTALL_CJK_FONTS=true — add Chinese/Japanese/Korean fonts (~200MB)
|
|
# setup/container.ts reads the same file, so both build paths stay in sync.
|
|
# Callers can also override by exporting INSTALL_CJK_FONTS directly.
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
cd "$SCRIPT_DIR"
|
|
|
|
# Derive the image name from the project root so two NanoClaw installs on the
|
|
# same host don't overwrite each other's `nanoclaw-agent:latest` tag. Matches
|
|
# setup/lib/install-slug.sh + src/install-slug.ts.
|
|
# shellcheck source=../setup/lib/install-slug.sh
|
|
source "$PROJECT_ROOT/setup/lib/install-slug.sh"
|
|
IMAGE_NAME="$(container_image_base)"
|
|
TAG="${1:-latest}"
|
|
CONTAINER_RUNTIME="${CONTAINER_RUNTIME:-docker}"
|
|
|
|
# Caller's env takes precedence; fall back to .env.
|
|
if [ -z "${INSTALL_CJK_FONTS:-}" ] && [ -f "../.env" ]; then
|
|
INSTALL_CJK_FONTS="$(grep '^INSTALL_CJK_FONTS=' ../.env | tail -n1 | cut -d= -f2- | tr -d '"' | tr -d "'" | tr -d '[:space:]')"
|
|
fi
|
|
|
|
BUILD_ARGS=()
|
|
if [ "${INSTALL_CJK_FONTS:-false}" = "true" ]; then
|
|
echo "CJK fonts: enabled (adds ~200MB)"
|
|
BUILD_ARGS+=(--build-arg INSTALL_CJK_FONTS=true)
|
|
fi
|
|
|
|
echo "Building NanoClaw agent container image..."
|
|
echo "Image: ${IMAGE_NAME}:${TAG}"
|
|
|
|
${CONTAINER_RUNTIME} build "${BUILD_ARGS[@]}" -t "${IMAGE_NAME}:${TAG}" .
|
|
|
|
echo ""
|
|
echo "Build complete!"
|
|
echo "Image: ${IMAGE_NAME}:${TAG}"
|
|
echo ""
|
|
echo "Test with:"
|
|
echo " echo '{\"prompt\":\"What is 2+2?\",\"groupFolder\":\"test\",\"chatJid\":\"test@g.us\",\"isMain\":false}' | ${CONTAINER_RUNTIME} run -i ${IMAGE_NAME}:${TAG}"
|