Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion alphatrion/server/cmd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def main():
default=os.getenv(envs.DASHBOARD_USER_ID),
help="User ID to scope the dashboard (required)",
)
dashboard.add_argument(
"--teamid",
type=str,
default=None,
help="Team ID to scope the dashboard (optional)",
)
dashboard.set_defaults(func=start_dashboard)

# init command
Expand Down Expand Up @@ -299,14 +305,19 @@ def start_dashboard(args):
return
# Store user ID in app state
app.state.user_id = args.userid
if args.teamid:
app.state.team_id = args.teamid

# Create HTTP client for proxying requests to backend
http_client = httpx.AsyncClient(base_url=args.backend_url, timeout=30.0)

# Endpoint to get current user ID (for frontend)
@app.get("/api/config")
async def get_config():
return {"userId": app.state.user_id}
config = {"userId": app.state.user_id}
if hasattr(app.state, "team_id"):
config["teamId"] = app.state.team_id
return config

# Proxy /graphql requests to backend (MUST be before catch-all route)
@app.api_route("/graphql", methods=["GET", "POST"])
Expand Down
1 change: 0 additions & 1 deletion alphatrion/storage/sqlstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ def create_experiment(
# labels look like "label1:value1,label2:value2",
label_pairs = labels.rstrip().split(",")
for pair in label_pairs:
print("Label pair:", pair)
if ":" in pair:
label_name, label_value = pair.split(":", 1)
elif "=" in pair:
Expand Down
17 changes: 17 additions & 0 deletions dashboard/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
:8080 {
# Proxy API and GraphQL requests to backend (must be first)
handle /api/* {
reverse_proxy alphatrion-server:8000
}

handle /graphql {
reverse_proxy alphatrion-server:8000
}

# Serve static files and SPA
handle {
root * /usr/share/caddy
try_files {path} /index.html
file_server
}
}
24 changes: 18 additions & 6 deletions dashboard/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
FROM node:24-alpine as build
FROM node:24-alpine AS build

WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

FROM nginx:alpine
COPY --from=build /app/static /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
FROM caddy:2-alpine

# Create non-root user and set up directories
RUN adduser -D -u 1000 -g 1000 caddy && \
mkdir -p /usr/share/caddy /config /data && \
chown -R caddy:caddy /usr/share/caddy /config /data

# Copy index.html to root, assets to /static/assets
COPY --from=build /app/static/index.html /usr/share/caddy/
COPY --from=build /app/static/assets /usr/share/caddy/static/assets

COPY Caddyfile /etc/caddy/Caddyfile

# Switch to non-root user
USER caddy

EXPOSE 8080
14 changes: 0 additions & 14 deletions dashboard/nginx.conf

This file was deleted.

2 changes: 1 addition & 1 deletion helm-charts/alphatrion/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ PostgreSQL password secret name
PostgreSQL password secret key
*/}}
{{- define "alphatrion.postgresql.secretKey" -}}
{{- "password" }}
{{- "postgres-password" }}
{{- end }}

{{/*
Expand Down
36 changes: 0 additions & 36 deletions helm-charts/alphatrion/templates/dashboard-configmap.yaml

This file was deleted.

24 changes: 11 additions & 13 deletions helm-charts/alphatrion/templates/dashboard-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ spec:
{{- include "alphatrion.dashboard.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/dashboard-configmap.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
labels:
{{- include "alphatrion.dashboard.selectorLabels" . | nindent 8 }}
spec:
Expand All @@ -32,21 +31,25 @@ spec:
serviceAccountName: {{ include "alphatrion.serviceAccountName" . }}
{{- end }}
securityContext:
{{- if .Values.dashboard.podSecurityContext }}
{{- toYaml .Values.dashboard.podSecurityContext | nindent 8 }}
{{- else }}
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- end }}
containers:
- name: dashboard
securityContext:
{{- if .Values.dashboard.securityContext }}
{{- toYaml .Values.dashboard.securityContext | nindent 12 }}
{{- else }}
{{- toYaml .Values.securityContext | nindent 12 }}
{{- end }}
image: "{{ .Values.dashboard.image.repository }}:{{ .Values.dashboard.image.tag }}"
imagePullPolicy: {{ .Values.dashboard.image.pullPolicy }}
ports:
- name: http
containerPort: 80
containerPort: 8080
protocol: TCP
volumeMounts:
- name: nginx-config
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf

{{- if .Values.dashboard.livenessProbe.enabled }}
livenessProbe:
Expand All @@ -73,11 +76,6 @@ spec:
resources:
{{- toYaml .Values.dashboard.resources | nindent 12 }}

volumes:
- name: nginx-config
configMap:
name: {{ include "alphatrion.dashboard.fullname" . }}

{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
4 changes: 4 additions & 0 deletions helm-charts/alphatrion/templates/server-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ metadata:
name: {{ include "alphatrion.server.fullname" . }}
labels:
{{- include "alphatrion.server.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-weight": "-5"
"helm.sh/resource-policy": keep
type: Opaque
stringData:
{{- if not .Values.postgresql.existingSecret }}
Expand Down
Loading