Bhaskar commited on
Commit
8573ebf
·
1 Parent(s): 91ac1b6

fix ui serving route and include index.html in image

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -0
  2. main.py +12 -0
Dockerfile CHANGED
@@ -80,6 +80,7 @@ COPY --from=builder /install /install
80
  # Copy application source last — maximises cache reuse for code iterations.
81
  # Only the files the server actually needs at runtime:
82
  COPY main.py ./main.py
 
83
  COPY inference.py ./inference.py
84
  COPY train.py ./train.py
85
  COPY openenv.yaml ./openenv.yaml
 
80
  # Copy application source last — maximises cache reuse for code iterations.
81
  # Only the files the server actually needs at runtime:
82
  COPY main.py ./main.py
83
+ COPY index.html ./index.html
84
  COPY inference.py ./inference.py
85
  COPY train.py ./train.py
86
  COPY openenv.yaml ./openenv.yaml
main.py CHANGED
@@ -29,12 +29,14 @@ from __future__ import annotations
29
  import math
30
  import random
31
  import uuid
 
32
  from dataclasses import dataclass, field
33
  from enum import IntEnum
34
  from typing import Any
35
 
36
  import uvicorn
37
  from fastapi import FastAPI, HTTPException
 
38
  from pydantic import BaseModel, Field, field_validator
39
 
40
  # =============================================================================
@@ -1414,6 +1416,16 @@ app = FastAPI(
1414
  version="1.0.0",
1415
  )
1416
 
 
 
 
 
 
 
 
 
 
 
1417
 
1418
  # Action schema is identical across all tasks — defined once, attached to every TaskMeta.
1419
  # Describes every field in the Action model: type, bounds, and semantics.
 
29
  import math
30
  import random
31
  import uuid
32
+ from pathlib import Path
33
  from dataclasses import dataclass, field
34
  from enum import IntEnum
35
  from typing import Any
36
 
37
  import uvicorn
38
  from fastapi import FastAPI, HTTPException
39
+ from fastapi.responses import FileResponse
40
  from pydantic import BaseModel, Field, field_validator
41
 
42
  # =============================================================================
 
1416
  version="1.0.0",
1417
  )
1418
 
1419
+ _INDEX_HTML_PATH = Path(__file__).resolve().parent / "index.html"
1420
+
1421
+
1422
+ @app.get("/", include_in_schema=False)
1423
+ def ui() -> FileResponse:
1424
+ """Serve the dashboard UI from the repository root."""
1425
+ if not _INDEX_HTML_PATH.exists():
1426
+ raise HTTPException(404, "index.html not found in application directory.")
1427
+ return FileResponse(_INDEX_HTML_PATH)
1428
+
1429
 
1430
  # Action schema is identical across all tasks — defined once, attached to every TaskMeta.
1431
  # Describes every field in the Action model: type, bounds, and semantics.