From b8460dcfa46a3e257d9a201d16838d51c6817ec9 Mon Sep 17 00:00:00 2001 From: Algis Dumbris Date: Fri, 13 Mar 2026 20:17:28 +0200 Subject: [PATCH] feat: add Dockerfile, docker-compose, and Helm chart Multi-stage Docker build (node + golang + scratch), ~30MB image. docker-compose.yml for local development with volume persistence. Helm chart with configurable Deployment, Service, PVC, Ingress, and Prometheus ServiceMonitor. Co-Authored-By: Claude Opus 4.6 --- .dockerignore | 12 +++ Dockerfile | 26 +++++++ deploy/helm/synapbus/Chart.yaml | 6 ++ deploy/helm/synapbus/templates/_helpers.tpl | 51 ++++++++++++ .../helm/synapbus/templates/deployment.yaml | 78 +++++++++++++++++++ deploy/helm/synapbus/templates/ingress.yaml | 41 ++++++++++ deploy/helm/synapbus/templates/pvc.yaml | 17 ++++ deploy/helm/synapbus/templates/service.yaml | 15 ++++ .../synapbus/templates/servicemonitor.yaml | 20 +++++ deploy/helm/synapbus/values.yaml | 66 ++++++++++++++++ docker-compose.yml | 18 +++++ 11 files changed, 350 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 deploy/helm/synapbus/Chart.yaml create mode 100644 deploy/helm/synapbus/templates/_helpers.tpl create mode 100644 deploy/helm/synapbus/templates/deployment.yaml create mode 100644 deploy/helm/synapbus/templates/ingress.yaml create mode 100644 deploy/helm/synapbus/templates/pvc.yaml create mode 100644 deploy/helm/synapbus/templates/service.yaml create mode 100644 deploy/helm/synapbus/templates/servicemonitor.yaml create mode 100644 deploy/helm/synapbus/values.yaml create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8dee763 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.git +bin/ +data/ +web/node_modules/ +web/.svelte-kit/ +*.test +*.out +.env +.env.* +.claude/ +.specify/ +__pycache__/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7ecb661 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +# Stage 1: Build web frontend +FROM node:20-alpine AS web-builder +WORKDIR /app/web +COPY web/package*.json ./ +RUN npm ci +COPY web/ ./ +RUN npm run build + +# Stage 2: Build Go binary +FROM golang:1.23-alpine AS go-builder +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +COPY --from=web-builder /app/web/build internal/web/dist/ +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /synapbus ./cmd/synapbus/ + +# Stage 3: Runtime +FROM scratch +COPY --from=go-builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=go-builder /usr/share/zoneinfo /usr/share/zoneinfo +COPY --from=go-builder /synapbus /synapbus +EXPOSE 8080 +VOLUME ["/data"] +ENTRYPOINT ["/synapbus"] +CMD ["serve", "--host", "0.0.0.0", "--port", "8080", "--data", "/data"] diff --git a/deploy/helm/synapbus/Chart.yaml b/deploy/helm/synapbus/Chart.yaml new file mode 100644 index 0000000..550f97b --- /dev/null +++ b/deploy/helm/synapbus/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: synapbus +description: Agent-to-agent messaging for AI swarms +type: application +version: 0.1.0 +appVersion: "0.1.0" diff --git a/deploy/helm/synapbus/templates/_helpers.tpl b/deploy/helm/synapbus/templates/_helpers.tpl new file mode 100644 index 0000000..d0004bd --- /dev/null +++ b/deploy/helm/synapbus/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "synapbus.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "synapbus.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "synapbus.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "synapbus.labels" -}} +helm.sh/chart: {{ include "synapbus.chart" . }} +{{ include "synapbus.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "synapbus.selectorLabels" -}} +app.kubernetes.io/name: {{ include "synapbus.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/deploy/helm/synapbus/templates/deployment.yaml b/deploy/helm/synapbus/templates/deployment.yaml new file mode 100644 index 0000000..2a684be --- /dev/null +++ b/deploy/helm/synapbus/templates/deployment.yaml @@ -0,0 +1,78 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "synapbus.fullname" . }} + labels: + {{- include "synapbus.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "synapbus.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "synapbus.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - serve + - --host + - "0.0.0.0" + - --port + - "8080" + - --data + - /data + ports: + - name: http + containerPort: 8080 + protocol: TCP + env: + {{- range $key, $value := .Values.env }} + - name: {{ $key }} + value: {{ $value | quote }} + {{- end }} + livenessProbe: + httpGet: + path: /healthz + port: http + initialDelaySeconds: 5 + periodSeconds: 10 + readinessProbe: + httpGet: + path: /readyz + port: http + initialDelaySeconds: 3 + periodSeconds: 5 + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: data + mountPath: /data + volumes: + - name: data + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ include "synapbus.fullname" . }} + {{- else }} + emptyDir: {} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deploy/helm/synapbus/templates/ingress.yaml b/deploy/helm/synapbus/templates/ingress.yaml new file mode 100644 index 0000000..f8a2d66 --- /dev/null +++ b/deploy/helm/synapbus/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "synapbus.fullname" . }} + labels: + {{- include "synapbus.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.className }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + pathType: {{ .pathType }} + backend: + service: + name: {{ include "synapbus.fullname" $ }} + port: + name: http + {{- end }} + {{- end }} +{{- end }} diff --git a/deploy/helm/synapbus/templates/pvc.yaml b/deploy/helm/synapbus/templates/pvc.yaml new file mode 100644 index 0000000..52fa8b6 --- /dev/null +++ b/deploy/helm/synapbus/templates/pvc.yaml @@ -0,0 +1,17 @@ +{{- if .Values.persistence.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "synapbus.fullname" . }} + labels: + {{- include "synapbus.labels" . | nindent 4 }} +spec: + accessModes: + {{- toYaml .Values.persistence.accessModes | nindent 4 }} + {{- if .Values.persistence.storageClass }} + storageClassName: {{ .Values.persistence.storageClass | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size }} +{{- end }} diff --git a/deploy/helm/synapbus/templates/service.yaml b/deploy/helm/synapbus/templates/service.yaml new file mode 100644 index 0000000..1cbb3f3 --- /dev/null +++ b/deploy/helm/synapbus/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "synapbus.fullname" . }} + labels: + {{- include "synapbus.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "synapbus.selectorLabels" . | nindent 4 }} diff --git a/deploy/helm/synapbus/templates/servicemonitor.yaml b/deploy/helm/synapbus/templates/servicemonitor.yaml new file mode 100644 index 0000000..b11083c --- /dev/null +++ b/deploy/helm/synapbus/templates/servicemonitor.yaml @@ -0,0 +1,20 @@ +{{- if .Values.metrics.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "synapbus.fullname" . }} + labels: + {{- include "synapbus.labels" . | nindent 4 }} + {{- with .Values.metrics.serviceMonitor.additionalLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + selector: + matchLabels: + {{- include "synapbus.selectorLabels" . | nindent 6 }} + endpoints: + - port: http + path: /metrics + interval: {{ .Values.metrics.serviceMonitor.interval }} + scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }} +{{- end }} diff --git a/deploy/helm/synapbus/values.yaml b/deploy/helm/synapbus/values.yaml new file mode 100644 index 0000000..d2a1524 --- /dev/null +++ b/deploy/helm/synapbus/values.yaml @@ -0,0 +1,66 @@ +replicaCount: 1 + +image: + repository: ghcr.io/smart-mcp-proxy/synapbus + pullPolicy: IfNotPresent + tag: "latest" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + create: false + name: "" + +service: + type: ClusterIP + port: 8080 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # cert-manager.io/cluster-issuer: letsencrypt-prod + hosts: + - host: synapbus.local + paths: + - path: / + pathType: Prefix + tls: [] + # - secretName: synapbus-tls + # hosts: + # - synapbus.local + +persistence: + enabled: true + storageClass: "" + accessModes: + - ReadWriteOnce + size: 1Gi + +resources: + requests: + cpu: 100m + memory: 128Mi + limits: + cpu: 500m + memory: 256Mi + +env: + SYNAPBUS_LOG_LEVEL: info + SYNAPBUS_METRICS: "true" + +metrics: + enabled: true + serviceMonitor: + interval: 30s + scrapeTimeout: 10s + additionalLabels: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..bc8db91 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +services: + synapbus: + build: . + ports: + - "8080:8080" + volumes: + - synapbus-data:/data + environment: + - SYNAPBUS_LOG_LEVEL=info + - SYNAPBUS_METRICS=true + restart: unless-stopped + # Note: healthcheck is omitted because the runtime image uses scratch, + # which has no shell, wget, or curl. Use an external health checker + # (e.g., Docker healthcheck with a sidecar, or orchestrator-level probes) + # to poll GET /healthz and GET /readyz on port 8080. + +volumes: + synapbus-data: