Overview
Phase 8.4 delivers production-grade containerisation and Kubernetes deployment manifests for the full ASI-Build stack (cognitive core + ExplainAPI + Prometheus/Grafana). It is the first deployment-hardening sub-phase of Phase 8 and lays the groundwork for Phase 8.5 (Sepolia CI).
Motivation
The ASI-Build runtime today lives exclusively in Python source files. Shipping it to a real server or cloud cluster requires:
| Gap |
Solution |
| No reproducible runtime environment |
Multi-stage Dockerfile with pinned base image |
| Local dev friction (seven services) |
docker-compose.yml one-command stack |
| No auto-scaling / self-healing |
Helm chart with HPA + liveness/readiness probes |
| No in-cluster metrics scraping |
Prometheus ServiceMonitor CRD via kube-prometheus-stack |
| No resource quotas |
resources: limits in every Deployment |
Deliverables
1. Dockerfile (multi-stage)
Stage 0 builder — python:3.11-slim, install all deps, compile *.pyc
Stage 1 runtime — python:3.11-slim, copy site-packages + app, drop to non-root uid=1000
- Build arg
ASI_VERSION baked into image label
HEALTHCHECK calls GET /health on the ExplainAPI port (8080)
- Final image ≤ 350 MB (no dev tools, no pip cache)
2. docker-compose.yml (local dev / CI)
Services:
| Service |
Image |
Port |
asi-core |
./Dockerfile |
— |
explain-api |
./Dockerfile |
8080 |
prometheus |
prom/prometheus:v2.51 |
9090 |
grafana |
grafana/grafana:10.4 |
3000 |
redis |
redis:7-alpine |
6379 |
Volume mounts: ./config/prometheus.yml, ./config/grafana/, ./data/traces/
3. Helm chart (charts/asi-build/)
charts/asi-build/
├── Chart.yaml # apiVersion: v2, appVersion from ASI_VERSION
├── values.yaml # image.tag, replicaCount, resources, autoscaling
├── templates/
│ ├── deployment.yaml # asi-core + explain-api containers
│ ├── service.yaml # ClusterIP for explain-api
│ ├── ingress.yaml # optional nginx ingress
│ ├── hpa.yaml # HorizontalPodAutoscaler (CPU 70%)
│ ├── configmap.yaml # prometheus.yml + grafana dashboards
│ ├── servicemonitor.yaml # Prometheus Operator ServiceMonitor
│ └── _helpers.tpl
Key values.yaml knobs:
image:
repository: ghcr.io/web3guru888/asi-build
tag: latest
pullPolicy: IfNotPresent
replicaCount: 2
resources:
requests: { cpu: 500m, memory: 512Mi }
limits: { cpu: 2, memory: 2Gi }
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 8
targetCPUUtilizationPercentage: 70
explainApi:
port: 8080
rateLimitPerMinute: 60
prometheus:
serviceMonitor:
enabled: true
interval: 15s
4. Makefile targets
| Target |
Command |
make docker-build |
docker build --build-arg ASI_VERSION=$(VERSION) -t asi-build:$(VERSION) . |
make docker-push |
push to GHCR |
make compose-up |
docker compose up -d |
make compose-down |
docker compose down -v |
make helm-lint |
helm lint charts/asi-build |
make helm-install |
helm upgrade --install asi-build charts/asi-build -f values.yaml |
make helm-template |
render manifests to stdout |
5. GitHub Actions workflow (.github/workflows/docker.yml)
Triggers: push to main, pull_request
Steps:
docker/setup-buildx-action
docker/login-action → GHCR
docker/build-push-action (multi-platform: linux/amd64 + linux/arm64)
helm/kind-action → spin up kind cluster
helm lint + helm install --dry-run
docker scout cves → fail on CRITICAL CVEs
Acceptance Criteria
Implementation Order
- Write
Dockerfile (multi-stage, non-root, HEALTHCHECK)
- Write
docker-compose.yml with named volumes + healthchecks
- Write
config/prometheus.yml scrape config (all 5 job names)
- Write
charts/asi-build/Chart.yaml + values.yaml
- Write
templates/deployment.yaml (liveness/readiness on /health)
- Write
templates/hpa.yaml + templates/servicemonitor.yaml
- Write
templates/configmap.yaml (Grafana dashboard JSON)
- Write
Makefile with all 7 targets
- Write
.github/workflows/docker.yml
- Run
helm lint + docker build locally, fix errors
- Open PR, CI green, merge
Phase 8 Sub-phase Tracker
| Sub-phase |
Issue |
Status |
| 8.1 DecisionTracer |
#276 |
✅ spec complete |
| 8.2 CausalGraph |
#280 |
✅ spec complete |
| 8.3 ExplainAPI |
#283 |
✅ spec complete |
| 8.4 Docker/Helm |
#291 |
🟡 in progress |
| 8.5 Sepolia CI |
TBD |
📋 planned |
Related
Overview
Phase 8.4 delivers production-grade containerisation and Kubernetes deployment manifests for the full ASI-Build stack (cognitive core + ExplainAPI + Prometheus/Grafana). It is the first deployment-hardening sub-phase of Phase 8 and lays the groundwork for Phase 8.5 (Sepolia CI).
Motivation
The ASI-Build runtime today lives exclusively in Python source files. Shipping it to a real server or cloud cluster requires:
Dockerfilewith pinned base imagedocker-compose.ymlone-command stackServiceMonitorCRD via kube-prometheus-stackresources:limits in every DeploymentDeliverables
1.
Dockerfile(multi-stage)ASI_VERSIONbaked into image labelHEALTHCHECKcallsGET /healthon the ExplainAPI port (8080)2.
docker-compose.yml(local dev / CI)Services:
asi-core./Dockerfileexplain-api./Dockerfileprometheusprom/prometheus:v2.51grafanagrafana/grafana:10.4redisredis:7-alpineVolume mounts:
./config/prometheus.yml,./config/grafana/,./data/traces/3. Helm chart (
charts/asi-build/)Key
values.yamlknobs:4.
Makefiletargetsmake docker-builddocker build --build-arg ASI_VERSION=$(VERSION) -t asi-build:$(VERSION) .make docker-pushmake compose-updocker compose up -dmake compose-downdocker compose down -vmake helm-linthelm lint charts/asi-buildmake helm-installhelm upgrade --install asi-build charts/asi-build -f values.yamlmake helm-template5. GitHub Actions workflow (
.github/workflows/docker.yml)Triggers:
pushtomain,pull_requestSteps:
docker/setup-buildx-actiondocker/login-action→ GHCRdocker/build-push-action(multi-platform: linux/amd64 + linux/arm64)helm/kind-action→ spin up kind clusterhelm lint+helm install --dry-rundocker scout cves→ fail on CRITICAL CVEsAcceptance Criteria
docker build .succeeds with no warningsdocker compose upraises all 5 services;/healthreturns 200helm lint charts/asi-buildexits 0helm install --dry-runrenders valid YAMLdocker image inspect)docker scoutscanpytest -x)Implementation Order
Dockerfile(multi-stage, non-root, HEALTHCHECK)docker-compose.ymlwith named volumes + healthchecksconfig/prometheus.ymlscrape config (all 5 job names)charts/asi-build/Chart.yaml+values.yamltemplates/deployment.yaml(liveness/readiness on/health)templates/hpa.yaml+templates/servicemonitor.yamltemplates/configmap.yaml(Grafana dashboard JSON)Makefilewith all 7 targets.github/workflows/docker.ymlhelm lint+docker buildlocally, fix errorsPhase 8 Sub-phase Tracker
Related