Spaces:
Sleeping
Sleeping
Fix: Add directory check for static assets to prevent runtime crash
Browse files- .gitignore +0 -1
- Dockerfile +2 -1
- server/app.py +7 -1
.gitignore
CHANGED
|
@@ -11,7 +11,6 @@ node_modules/
|
|
| 11 |
|
| 12 |
# --- Build Artifacts ---
|
| 13 |
frontend/dist/
|
| 14 |
-
server/dist/
|
| 15 |
*.egg-info/
|
| 16 |
dist/
|
| 17 |
build/
|
|
|
|
| 11 |
|
| 12 |
# --- Build Artifacts ---
|
| 13 |
frontend/dist/
|
|
|
|
| 14 |
*.egg-info/
|
| 15 |
dist/
|
| 16 |
build/
|
Dockerfile
CHANGED
|
@@ -11,7 +11,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
WORKDIR /app
|
| 14 |
-
|
|
|
|
| 15 |
# 2. Upgrade pip and install OpenEnv
|
| 16 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
|
| 17 |
# openenv[core] installs the base package; openenv-core provides the openenv.core subpackage
|
|
|
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
WORKDIR /app
|
| 14 |
+
RUN mkdir -p /app/server/dist/assets
|
| 15 |
+
COPY . .
|
| 16 |
# 2. Upgrade pip and install OpenEnv
|
| 17 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
|
| 18 |
# openenv[core] installs the base package; openenv-core provides the openenv.core subpackage
|
server/app.py
CHANGED
|
@@ -98,7 +98,13 @@ TRAINING_LOG_DIR = os.path.join(current_dir, "training_logs")
|
|
| 98 |
os.makedirs(LOG_DIR, exist_ok=True)
|
| 99 |
os.makedirs(TRAINING_LOG_DIR, exist_ok=True)
|
| 100 |
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
# 3. Mount Logs for direct access
|
| 104 |
app.mount("/api/logs", StaticFiles(directory=LOG_DIR), name="logs")
|
|
|
|
| 98 |
os.makedirs(LOG_DIR, exist_ok=True)
|
| 99 |
os.makedirs(TRAINING_LOG_DIR, exist_ok=True)
|
| 100 |
|
| 101 |
+
assets_path = os.path.join(dist_path, "assets")
|
| 102 |
+
|
| 103 |
+
# Only mount if the directory exists
|
| 104 |
+
if os.path.exists(assets_path):
|
| 105 |
+
app.mount("/assets", ForceStaticFiles(directory=assets_path), name="assets")
|
| 106 |
+
else:
|
| 107 |
+
print(f"⚠️ Warning: Static assets directory not found at {assets_path}")
|
| 108 |
|
| 109 |
# 3. Mount Logs for direct access
|
| 110 |
app.mount("/api/logs", StaticFiles(directory=LOG_DIR), name="logs")
|