Spaces:
Running
Running
Final Submission: Added SOC Dashboard and fixed UI explorer
Browse files- Dockerfile +7 -6
- nginx.conf +1 -1
- server/app.py +7 -4
- start.sh +15 -6
Dockerfile
CHANGED
|
@@ -11,17 +11,18 @@ WORKDIR /app
|
|
| 11 |
COPY requirements.txt .
|
| 12 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# Copy application source
|
| 15 |
COPY patchhawk/ patchhawk/
|
| 16 |
COPY server/ server/
|
| 17 |
-
COPY openenv.yaml .
|
| 18 |
-
COPY pyproject.toml .
|
| 19 |
COPY inference.py .
|
| 20 |
-
COPY config.yaml .
|
| 21 |
-
COPY nginx.conf /etc/nginx/nginx.conf
|
| 22 |
|
| 23 |
-
# Copy and configure the startup script
|
| 24 |
-
COPY start.sh .
|
| 25 |
RUN chmod +x start.sh
|
| 26 |
|
| 27 |
# Expose both the OpenEnv API port and Streamlit port
|
|
|
|
| 11 |
COPY requirements.txt .
|
| 12 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
|
| 14 |
+
# Copy configuration files first
|
| 15 |
+
COPY nginx.conf /etc/nginx/nginx.conf
|
| 16 |
+
COPY start.sh .
|
| 17 |
+
COPY openenv.yaml .
|
| 18 |
+
COPY pyproject.toml .
|
| 19 |
+
COPY config.yaml .
|
| 20 |
+
|
| 21 |
# Copy application source
|
| 22 |
COPY patchhawk/ patchhawk/
|
| 23 |
COPY server/ server/
|
|
|
|
|
|
|
| 24 |
COPY inference.py .
|
|
|
|
|
|
|
| 25 |
|
|
|
|
|
|
|
| 26 |
RUN chmod +x start.sh
|
| 27 |
|
| 28 |
# Expose both the OpenEnv API port and Streamlit port
|
nginx.conf
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
worker_processes 1;
|
| 2 |
-
daemon off;
|
| 3 |
pid /tmp/nginx.pid;
|
| 4 |
error_log /dev/stdout info;
|
| 5 |
|
|
@@ -37,6 +36,7 @@ http {
|
|
| 37 |
proxy_set_header Host $host;
|
| 38 |
proxy_set_header X-Real-IP $remote_addr;
|
| 39 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
| 40 |
proxy_read_timeout 86400;
|
| 41 |
}
|
| 42 |
}
|
|
|
|
| 1 |
worker_processes 1;
|
|
|
|
| 2 |
pid /tmp/nginx.pid;
|
| 3 |
error_log /dev/stdout info;
|
| 4 |
|
|
|
|
| 36 |
proxy_set_header Host $host;
|
| 37 |
proxy_set_header X-Real-IP $remote_addr;
|
| 38 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 39 |
+
proxy_set_header X-Forwarded-Proto $scheme;
|
| 40 |
proxy_read_timeout 86400;
|
| 41 |
}
|
| 42 |
}
|
server/app.py
CHANGED
|
@@ -33,14 +33,17 @@ def create_openenv_app():
|
|
| 33 |
|
| 34 |
app = create_openenv_app()
|
| 35 |
|
| 36 |
-
@app.get("/")
|
| 37 |
def root():
|
| 38 |
-
|
| 39 |
-
# (Hugging Face will often open `/` by default.)
|
| 40 |
from fastapi.responses import RedirectResponse
|
| 41 |
-
|
| 42 |
return RedirectResponse(url="/docs")
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
def main(port: int | None = None) -> None:
|
| 45 |
"""Start the PatchHawk OpenEnv server."""
|
| 46 |
import uvicorn
|
|
|
|
| 33 |
|
| 34 |
app = create_openenv_app()
|
| 35 |
|
| 36 |
+
@app.get("/", include_in_schema=False)
|
| 37 |
def root():
|
| 38 |
+
"""Redirect root access to documentation."""
|
|
|
|
| 39 |
from fastapi.responses import RedirectResponse
|
|
|
|
| 40 |
return RedirectResponse(url="/docs")
|
| 41 |
|
| 42 |
+
@app.get("/health")
|
| 43 |
+
def health():
|
| 44 |
+
"""Health check endpoint for the API."""
|
| 45 |
+
return {"status": "ok", "app": "PatchHawk"}
|
| 46 |
+
|
| 47 |
def main(port: int | None = None) -> None:
|
| 48 |
"""Start the PatchHawk OpenEnv server."""
|
| 49 |
import uvicorn
|
start.sh
CHANGED
|
@@ -4,19 +4,28 @@ API_PORT="${API_PORT:-8000}"
|
|
| 4 |
PORT="${PORT:-7860}"
|
| 5 |
|
| 6 |
# Start FastAPI on API_PORT
|
| 7 |
-
echo "Starting OpenEnv API server on port ${API_PORT}..."
|
| 8 |
-
uvicorn server.app:app --host 0.0.0.0 --port "${API_PORT}" &
|
| 9 |
|
| 10 |
# Start the Streamlit Dashboard (User UI) in the background with Proxy-friendly settings
|
| 11 |
-
echo "Starting Streamlit Dashboard on port 8501..."
|
| 12 |
streamlit run patchhawk/app/dashboard.py \
|
| 13 |
--server.port 8501 \
|
| 14 |
--server.address 0.0.0.0 \
|
| 15 |
--server.enableCORS false \
|
| 16 |
--server.enableXsrfProtection false \
|
| 17 |
--server.headless true \
|
| 18 |
-
--browser.gatherUsageStats false &
|
| 19 |
|
| 20 |
# Start Nginx in foreground on PORT
|
| 21 |
-
echo "Starting Nginx reverse proxy on ${PORT}..."
|
| 22 |
-
envsubst '${PORT}' < /etc/nginx/nginx.conf > /tmp/nginx.conf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
PORT="${PORT:-7860}"
|
| 5 |
|
| 6 |
# Start FastAPI on API_PORT
|
| 7 |
+
echo "[SYSTEM] Starting OpenEnv API server on port ${API_PORT}..."
|
| 8 |
+
uvicorn server.app:app --host 0.0.0.0 --port "${API_PORT}" 2>&1 | sed 's/^/[FASTAPI] /' &
|
| 9 |
|
| 10 |
# Start the Streamlit Dashboard (User UI) in the background with Proxy-friendly settings
|
| 11 |
+
echo "[SYSTEM] Starting Streamlit Dashboard on port 8501..."
|
| 12 |
streamlit run patchhawk/app/dashboard.py \
|
| 13 |
--server.port 8501 \
|
| 14 |
--server.address 0.0.0.0 \
|
| 15 |
--server.enableCORS false \
|
| 16 |
--server.enableXsrfProtection false \
|
| 17 |
--server.headless true \
|
| 18 |
+
--browser.gatherUsageStats false 2>&1 | sed 's/^/[STREAMLIT] /' &
|
| 19 |
|
| 20 |
# Start Nginx in foreground on PORT
|
| 21 |
+
echo "[SYSTEM] Starting Nginx reverse proxy on ${PORT}..."
|
| 22 |
+
envsubst '${PORT}' < /etc/nginx/nginx.conf > /tmp/nginx.conf
|
| 23 |
+
|
| 24 |
+
# Validate Nginx config
|
| 25 |
+
nginx -t -c /tmp/nginx.conf
|
| 26 |
+
if [ $? -ne 0 ]; then
|
| 27 |
+
echo "[ERROR] Nginx configuration validation failed!"
|
| 28 |
+
exit 1
|
| 29 |
+
fi
|
| 30 |
+
|
| 31 |
+
exec nginx -c /tmp/nginx.conf -g "daemon off;"
|