Skip to content

Commit bd952e7

Browse files
committed
Temp: fix the userID error
Signed-off-by: kerthcet <kerthcet@gmail.com>
1 parent d1f6c5d commit bd952e7

4 files changed

Lines changed: 53 additions & 6 deletions

File tree

dashboard/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ COPY --from=build /app/static/assets /usr/share/caddy/static/assets
1919

2020
COPY Caddyfile /etc/caddy/Caddyfile
2121

22+
# Copy and setup entrypoint script
23+
COPY docker-entrypoint.sh /usr/local/bin/
24+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
25+
2226
# Switch to non-root user
2327
USER caddy
2428

25-
EXPOSE 8080
29+
EXPOSE 8080
30+
31+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

dashboard/docker-entrypoint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Write config.json with userId and teamId from environment variables
5+
cat > /usr/share/caddy/config.json <<EOF
6+
{
7+
"userId": "${ALPHATRION_DASHBOARD_USER_ID:-}",
8+
"teamId": "${ALPHATRION_DASHBOARD_TEAM_ID:-}"
9+
}
10+
EOF
11+
12+
echo "Created config.json with userId=${ALPHATRION_DASHBOARD_USER_ID:-} teamId=${ALPHATRION_DASHBOARD_TEAM_ID:-}"
13+
14+
# Start Caddy
15+
exec caddy run --config /etc/caddy/Caddyfile --adapter caddyfile

dashboard/src/lib/config.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,41 @@
11
/**
2-
* Configuration fetching from dashboard backend
2+
* Configuration fetching
33
*
4-
* The dashboard is started with --userid flag, which stores the user ID
5-
* in the backend. The frontend fetches this configuration on startup.
4+
* In CLI mode: The dashboard is started with --userid flag, which stores the user ID
5+
* in the backend. The frontend fetches this via /api/config endpoint.
6+
*
7+
* In Kubernetes mode: The dashboard pod writes userId from environment variables
8+
* to /config.json file at startup. The frontend fetches this static file.
69
*/
710

811
interface Config {
912
userId: string;
13+
teamId?: string;
1014
}
1115

1216
/**
13-
* Fetch configuration from the dashboard backend
17+
* Fetch configuration
1418
* Always fetches fresh config to avoid stale user ID when dashboard is restarted with different user
1519
*/
1620
export async function getConfig(): Promise<Config> {
17-
const response = await fetch('/api/config', {
21+
// Try /config.json first (Kubernetes mode)
22+
let response = await fetch('/config.json', {
1823
cache: 'no-store',
1924
headers: {
2025
'Cache-Control': 'no-cache',
2126
},
2227
});
28+
29+
// Fallback to /api/config (CLI mode)
30+
if (!response.ok) {
31+
response = await fetch('/api/config', {
32+
cache: 'no-store',
33+
headers: {
34+
'Cache-Control': 'no-cache',
35+
},
36+
});
37+
}
38+
2339
if (!response.ok) {
2440
throw new Error('Failed to load configuration');
2541
}

helm-charts/alphatrion/templates/dashboard-deployment.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ spec:
4646
{{- end }}
4747
image: "{{ .Values.dashboard.image.repository }}:{{ .Values.dashboard.image.tag }}"
4848
imagePullPolicy: {{ .Values.dashboard.image.pullPolicy }}
49+
50+
# TODO: Remove after quantinuum-nvidia collaboration is done.
51+
env:
52+
- name: ALPHATRION_DASHBOARD_USER_ID
53+
value: {{ .Values.dashboard.userId | quote }}
54+
{{- if .Values.dashboard.teamId }}
55+
- name: ALPHATRION_DASHBOARD_TEAM_ID
56+
value: {{ .Values.dashboard.teamId | quote }}
57+
{{- end }}
58+
4959
ports:
5060
- name: http
5161
containerPort: 8080

0 commit comments

Comments
 (0)