Skip to content

Commit 3dee10d

Browse files
committed
Cleanup/fix deployment (InftyAI#179)
* fix deployment problem Signed-off-by: kerthcet <kerthcet@gmail.com> * remove unneeded files Signed-off-by: kerthcet <kerthcet@gmail.com> --------- Signed-off-by: kerthcet <kerthcet@gmail.com>
1 parent 9a47595 commit 3dee10d

9 files changed

Lines changed: 63 additions & 72 deletions

File tree

alphatrion/server/cmd/main.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ def main():
6565
default=os.getenv(envs.DASHBOARD_USER_ID),
6666
help="User ID to scope the dashboard (required)",
6767
)
68+
dashboard.add_argument(
69+
"--teamid",
70+
type=str,
71+
default=None,
72+
help="Team ID to scope the dashboard (optional)",
73+
)
6874
dashboard.set_defaults(func=start_dashboard)
6975

7076
# init command
@@ -299,14 +305,19 @@ def start_dashboard(args):
299305
return
300306
# Store user ID in app state
301307
app.state.user_id = args.userid
308+
if args.teamid:
309+
app.state.team_id = args.teamid
302310

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

306314
# Endpoint to get current user ID (for frontend)
307315
@app.get("/api/config")
308316
async def get_config():
309-
return {"userId": app.state.user_id}
317+
config = {"userId": app.state.user_id}
318+
if hasattr(app.state, "team_id"):
319+
config["teamId"] = app.state.team_id
320+
return config
310321

311322
# Proxy /graphql requests to backend (MUST be before catch-all route)
312323
@app.api_route("/graphql", methods=["GET", "POST"])

alphatrion/storage/sqlstore.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@ def create_experiment(
362362
# labels look like "label1:value1,label2:value2",
363363
label_pairs = labels.rstrip().split(",")
364364
for pair in label_pairs:
365-
print("Label pair:", pair)
366365
if ":" in pair:
367366
label_name, label_value = pair.split(":", 1)
368367
elif "=" in pair:

dashboard/Caddyfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
:8080 {
2+
# Proxy API and GraphQL requests to backend (must be first)
3+
handle /api/* {
4+
reverse_proxy alphatrion-server:8000
5+
}
6+
7+
handle /graphql {
8+
reverse_proxy alphatrion-server:8000
9+
}
10+
11+
# Serve static files and SPA
12+
handle {
13+
root * /usr/share/caddy
14+
try_files {path} /index.html
15+
file_server
16+
}
17+
}

dashboard/Dockerfile

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1-
FROM node:24-alpine as build
1+
FROM node:24-alpine AS build
22

33
WORKDIR /app
44
COPY package*.json ./
55
RUN npm install
66
COPY . .
77
RUN npm run build
88

9-
FROM nginx:alpine
10-
COPY --from=build /app/static /usr/share/nginx/html
11-
COPY nginx.conf /etc/nginx/conf.d/default.conf
12-
EXPOSE 80
13-
CMD ["nginx", "-g", "daemon off;"]
9+
FROM caddy:2-alpine
10+
11+
# Create non-root user and set up directories
12+
RUN adduser -D -u 1000 -g 1000 caddy && \
13+
mkdir -p /usr/share/caddy /config /data && \
14+
chown -R caddy:caddy /usr/share/caddy /config /data
15+
16+
# Copy index.html to root, assets to /static/assets
17+
COPY --from=build /app/static/index.html /usr/share/caddy/
18+
COPY --from=build /app/static/assets /usr/share/caddy/static/assets
19+
20+
COPY Caddyfile /etc/caddy/Caddyfile
21+
22+
# Switch to non-root user
23+
USER caddy
24+
25+
EXPOSE 8080

dashboard/nginx.conf

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

helm-charts/alphatrion/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ PostgreSQL password secret name
148148
PostgreSQL password secret key
149149
*/}}
150150
{{- define "alphatrion.postgresql.secretKey" -}}
151-
{{- "password" }}
151+
{{- "postgres-password" }}
152152
{{- end }}
153153

154154
{{/*

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

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

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ spec:
1616
{{- include "alphatrion.dashboard.selectorLabels" . | nindent 6 }}
1717
template:
1818
metadata:
19+
{{- with .Values.podAnnotations }}
1920
annotations:
20-
checksum/config: {{ include (print $.Template.BasePath "/dashboard-configmap.yaml") . | sha256sum }}
21-
{{- with .Values.podAnnotations }}
2221
{{- toYaml . | nindent 8 }}
23-
{{- end }}
22+
{{- end }}
2423
labels:
2524
{{- include "alphatrion.dashboard.selectorLabels" . | nindent 8 }}
2625
spec:
@@ -32,21 +31,25 @@ spec:
3231
serviceAccountName: {{ include "alphatrion.serviceAccountName" . }}
3332
{{- end }}
3433
securityContext:
34+
{{- if .Values.dashboard.podSecurityContext }}
35+
{{- toYaml .Values.dashboard.podSecurityContext | nindent 8 }}
36+
{{- else }}
3537
{{- toYaml .Values.podSecurityContext | nindent 8 }}
38+
{{- end }}
3639
containers:
3740
- name: dashboard
3841
securityContext:
42+
{{- if .Values.dashboard.securityContext }}
43+
{{- toYaml .Values.dashboard.securityContext | nindent 12 }}
44+
{{- else }}
3945
{{- toYaml .Values.securityContext | nindent 12 }}
46+
{{- end }}
4047
image: "{{ .Values.dashboard.image.repository }}:{{ .Values.dashboard.image.tag }}"
4148
imagePullPolicy: {{ .Values.dashboard.image.pullPolicy }}
4249
ports:
4350
- name: http
44-
containerPort: 80
51+
containerPort: 8080
4552
protocol: TCP
46-
volumeMounts:
47-
- name: nginx-config
48-
mountPath: /etc/nginx/conf.d/default.conf
49-
subPath: nginx.conf
5053

5154
{{- if .Values.dashboard.livenessProbe.enabled }}
5255
livenessProbe:
@@ -73,11 +76,6 @@ spec:
7376
resources:
7477
{{- toYaml .Values.dashboard.resources | nindent 12 }}
7578

76-
volumes:
77-
- name: nginx-config
78-
configMap:
79-
name: {{ include "alphatrion.dashboard.fullname" . }}
80-
8179
{{- with .Values.nodeSelector }}
8280
nodeSelector:
8381
{{- toYaml . | nindent 8 }}

helm-charts/alphatrion/templates/server-secret.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ metadata:
44
name: {{ include "alphatrion.server.fullname" . }}
55
labels:
66
{{- include "alphatrion.server.labels" . | nindent 4 }}
7+
annotations:
8+
"helm.sh/hook": pre-install,pre-upgrade
9+
"helm.sh/hook-weight": "-5"
10+
"helm.sh/resource-policy": keep
711
type: Opaque
812
stringData:
913
{{- if not .Values.postgresql.existingSecret }}

0 commit comments

Comments
 (0)