Skip to content

Commit c70411e

Browse files
committed
integrate dashboard to docker compose up
Signed-off-by: JaredforReal <[email protected]>
1 parent 9a142d3 commit c70411e

File tree

6 files changed

+132
-55
lines changed

6 files changed

+132
-55
lines changed

dashboard/README.md

Lines changed: 78 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -156,43 +156,100 @@ Recommended upstream settings for embedding:
156156
- OIDC enablement behind a flag
157157
- Metrics summary endpoint
158158

159-
## Try it (proposed)
159+
## Quick Start
160160

161-
Local with existing observability:
161+
### Method 1: One-click Start with Docker Compose (Recommended)
162162

163-
1. Start Prometheus/Grafana on host network:
163+
The Dashboard is integrated into the main Compose stack, requiring no extra configuration:
164164

165-
- `docker compose -f docker-compose.obs.yml up -d`
165+
```bash
166+
# Run from the project root directory
167+
make docker-compose-up
166168

167-
2. Start router natively or with Compose
168-
3. Start dashboard backend (port 8700) with env vars above
169-
4. Open `http://localhost:8700`
169+
# Or use docker compose directly
170+
docker compose -f deploy/docker-compose/docker-compose.yml up -d --build
171+
```
170172

171-
### Docker Compose unified run (after adding dashboard overlay)
173+
After startup, access:
172174

175+
- **Dashboard**: http://localhost:8700
176+
- **Grafana** (direct access): http://localhost:3000 (admin/admin)
177+
- **Prometheus** (direct access): http://localhost:9090
178+
179+
### Method 2: Local Development Mode
180+
181+
When developing the Dashboard code locally:
182+
183+
```bash
184+
# 1. Start the local Observability stack
185+
make o11y-local
186+
# Or
187+
docker compose -f tools/observability/docker-compose.obs.yml up -d
188+
189+
# 2. Start the Router (in another terminal)
190+
cd src/semantic-router
191+
go run cmd/main.go -config ../../config/config.yaml
192+
193+
# 3. Start the Dashboard backend (local development)
194+
cd dashboard/backend
195+
export TARGET_GRAFANA_URL=http://localhost:3000
196+
export TARGET_PROMETHEUS_URL=http://localhost:9090
197+
export TARGET_ROUTER_API_URL=http://localhost:8080
198+
export TARGET_ROUTER_METRICS_URL=http://localhost:9190/metrics
199+
go run main.go -port=8700 -static=../frontend
200+
201+
# 4. Open your browser
202+
open http://localhost:8700
173203
```
174-
docker compose -f docker-compose.yml -f dashboard/deploy/docker/compose.yml up --build
175-
```
176204

177-
The overlay builds the dashboard image using `dashboard/backend/Dockerfile` and exposes it at `http://localhost:8700`.
205+
### Method 3: Rebuild Dashboard Only
206+
207+
For a quick rebuild after code changes:
208+
209+
```bash
210+
# Rebuild the dashboard service
211+
docker compose -f deploy/docker-compose/docker-compose.yml build dashboard
178212

179-
### Rebuild only dashboard after code changes
213+
# Restart the dashboard
214+
docker compose -f deploy/docker-compose/docker-compose.yml up -d dashboard
180215

216+
# View logs
217+
docker logs -f semantic-router-dashboard
181218
```
182-
docker compose -f docker-compose.yml -f dashboard/deploy/docker/compose.yml build dashboard
183-
docker compose -f docker-compose.yml -f dashboard/deploy/docker/compose.yml up -d dashboard
219+
220+
## Deployment Details
221+
222+
### Docker Compose Integration Notes
223+
224+
- The Dashboard service is integrated as a **default service** in `deploy/docker-compose/docker-compose.yml`.
225+
- No additional overlay files are needed; `make docker-compose-up` will automatically start all services.
226+
- The Dashboard depends on the `semantic-router` (for health checks), `grafana`, and `prometheus` services.
227+
228+
### Dockerfile Build
229+
230+
- A multi-stage build (Go builder → distroless) is defined in `dashboard/backend/Dockerfile`.
231+
- An independent Go module `dashboard/backend/go.mod` isolates dependencies.
232+
- Frontend static assets are packaged into the image at `/app/frontend`.
233+
234+
### Grafana Embedding Support
235+
236+
Grafana is already configured for embedding in `deploy/docker-compose/docker-compose.yml`:
237+
238+
```yaml
239+
- GF_SECURITY_ALLOW_EMBEDDING=true
240+
- GF_SECURITY_COOKIE_SAMESITE=lax
184241
```
185242
186-
### Notes on Dockerfile
243+
The Dashboard reverse proxy will automatically clean up `X-Frame-Options` and adjust CSP headers to ensure the iframe loads correctly.
187244

188-
- Multi-stage build (Go → distroless) defined in `dashboard/backend/Dockerfile`.
189-
- Standalone Go module in `dashboard/backend/go.mod` isolates dependencies.
190-
- Frontend static assets baked into the image under `/app/frontend`.
245+
### Health Check
191246

192-
### Grafana embedding
247+
The Dashboard provides a `/healthz` endpoint for container health checks:
193248

194-
- Root `docker-compose.yml` now sets `GF_SECURITY_ALLOW_EMBEDDING=true` for iframe usage.
195-
- If you need stricter policies, remove the flag and authenticate Grafana separately; the dashboard proxy will still sanitize frame headers but Grafana may block unauthenticated panels.
249+
```bash
250+
curl http://localhost:8700/healthz
251+
# Returns: {"status":"healthy","service":"semantic-router-dashboard"}
252+
```
196253

197254
## Notes
198255

dashboard/backend/Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
FROM golang:1.24 AS builder
22
WORKDIR /app
3-
# Copy only module files first for layer caching
4-
COPY dashboard/backend/go.mod dashboard/backend/go.sum ./dashboard/backend/
5-
WORKDIR /app/dashboard/backend
6-
RUN go mod download
73
# Copy source and frontend assets
8-
COPY dashboard/backend/ ./
4+
COPY dashboard/backend/ /app/dashboard/backend/
95
COPY dashboard/frontend/ /app/dashboard/frontend/
6+
# Build the binary
7+
WORKDIR /app/dashboard/backend
8+
RUN go mod download || true
109
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /app/dashboard-backend main.go
1110

12-
FROM gcr.io/distroless/static:nonroot
11+
FROM alpine:3.19
12+
RUN apk --no-cache add ca-certificates wget
1313
WORKDIR /app
1414
COPY --from=builder /app/dashboard-backend /app/dashboard-backend
1515
COPY --from=builder /app/dashboard/frontend /app/frontend
16+
RUN addgroup -g 65532 nonroot && \
17+
adduser -D -u 65532 -G nonroot nonroot && \
18+
chown -R nonroot:nonroot /app
1619
EXPOSE 8700
1720
USER nonroot:nonroot
1821
ENTRYPOINT ["/app/dashboard-backend", "-port=8700", "-static=/app/frontend"]

dashboard/backend/main.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,15 @@ func main() {
115115

116116
mux := http.NewServeMux()
117117

118-
// Static frontend
119-
mux.Handle("/", staticFileServer(*staticDir))
118+
// Health check endpoint
119+
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
120+
w.Header().Set("Content-Type", "application/json")
121+
w.WriteHeader(http.StatusOK)
122+
w.Write([]byte(`{"status":"healthy","service":"semantic-router-dashboard"}`))
123+
})
120124

121-
// Router API proxy (forward Authorization)
125+
// Static frontend
126+
mux.Handle("/", staticFileServer(*staticDir)) // Router API proxy (forward Authorization)
122127
if *routerAPI != "" {
123128
rp, err := newReverseProxy(*routerAPI, "/api/router", true)
124129
if err != nil {

dashboard/deploy/docker/.gitkeep

Whitespace-only changes.

dashboard/deploy/docker/compose.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

deploy/docker-compose/docker-compose.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ services:
1111
volumes:
1212
- ../../config:/app/config:ro
1313
- ../../models:/app/models:ro
14+
- ~/.cache/huggingface:/root/.cache/huggingface
1415
environment:
1516
- LD_LIBRARY_PATH=/app/lib
1617
- CONFIG_FILE=${CONFIG_FILE:-/app/config/config.yaml}
18+
- HUGGINGFACE_HUB_CACHE=/root/.cache/huggingface
19+
- HF_HUB_ENABLE_HF_TRANSFER=1
20+
- HF_ENDPOINT=https://hf-mirror.com
1721
networks:
1822
- semantic-network
1923
healthcheck:
@@ -117,6 +121,39 @@ services:
117121
- semantic-network
118122
command: ["llm-katan", "--model", "Qwen/Qwen3-0.6B", "--host", "0.0.0.0", "--port", "8000"]
119123

124+
# Semantic Router Dashboard
125+
dashboard:
126+
build:
127+
context: ../../
128+
dockerfile: dashboard/backend/Dockerfile
129+
image: semantic-router-dashboard:dev
130+
container_name: semantic-router-dashboard
131+
command: ["/app/dashboard-backend", "-port=8700", "-static=/app/frontend"]
132+
environment:
133+
- DASHBOARD_PORT=8700
134+
- TARGET_GRAFANA_URL=http://grafana:3000
135+
- TARGET_PROMETHEUS_URL=http://prometheus:9090
136+
- TARGET_ROUTER_API_URL=http://semantic-router:8080
137+
- TARGET_ROUTER_METRICS_URL=http://semantic-router:9190/metrics
138+
- TARGET_OPENWEBUI_URL=${TARGET_OPENWEBUI_URL:-}
139+
ports:
140+
- "8700:8700"
141+
networks:
142+
- semantic-network
143+
depends_on:
144+
semantic-router:
145+
condition: service_healthy
146+
grafana:
147+
condition: service_started
148+
prometheus:
149+
condition: service_started
150+
healthcheck:
151+
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8700/healthz"]
152+
interval: 10s
153+
timeout: 5s
154+
retries: 3
155+
start_period: 10s
156+
120157
networks:
121158
semantic-network:
122159
driver: bridge

0 commit comments

Comments
 (0)