# ── GoClaw Agent Container ──────────────────────────────────────────────────── # # Autonomous agent microservice that: # 1. Exposes a lightweight HTTP API (port 8080) for receiving tasks # 2. Has access to the Swarm overlay network (goclaw-net) # 3. Connects to the shared MySQL database for persistence # 4. Calls the LLM API via the GoClaw Gateway # 5. Auto-registers itself with the orchestrator on startup # # Build: docker build -f docker/Dockerfile.agent -t goclaw-agent:latest . # Deploy: docker service create --name goclaw-agent-NAME \ # --network goclaw-net \ # -e AGENT_ID=NAME \ # -e GATEWAY_URL=http://goclaw-gateway:18789 \ # -e DATABASE_URL=mysql://... \ # goclaw-agent:latest # ───────────────────────────────────────────────────────────────────────────── # ── Stage 1: Build Go agent binary ─────────────────────────────────────────── FROM golang:1.23-alpine AS builder WORKDIR /src # Copy gateway module (agent reuses gateway internals) COPY gateway/go.mod gateway/go.sum ./ RUN go mod download COPY gateway/ ./ # Build the agent server binary RUN go build -o /agent-server ./cmd/agent/... # ── Stage 2: Runtime ────────────────────────────────────────────────────────── FROM alpine:3.20 RUN apk add --no-cache ca-certificates curl wget tzdata WORKDIR /app COPY --from=builder /agent-server ./agent-server # Default environment (override at deploy time) ENV AGENT_ID=default-agent \ AGENT_PORT=8080 \ GATEWAY_URL=http://goclaw-gateway:18789 \ LLM_BASE_URL=https://ollama.com/v1 \ LLM_API_KEY="" \ DATABASE_URL="" \ IDLE_TIMEOUT_MINUTES=15 EXPOSE 8080 HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 \ CMD wget -qO- http://localhost:8080/health || exit 1 ENTRYPOINT ["/app/agent-server"]