From 06f3359de5f82577235098d867a7243180f1b968 Mon Sep 17 00:00:00 2001 From: Abdelrahman-17 Date: Sun, 26 Jul 2026 15:40:14 +0300 Subject: [PATCH] Fix Bad Gateway: Bind uvicorn to 0.0.0.0 explicitly --- Dockerfile | 6 +++--- app.py | 18 ++++++++---------- q1-deploy-monitor/Dockerfile | 6 +++--- q1-deploy-monitor/app.py | 18 ++++++++---------- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4705e4f..a6f3cb8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,10 +2,10 @@ FROM python:3.10-slim WORKDIR /app -RUN pip install --no-cache-dir fastapi uvicorn requests +RUN pip install --no-cache-dir fastapi uvicorn -COPY . . +COPY app.py . EXPOSE 8000 -CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] +CMD ["python", "app.py"] diff --git a/app.py b/app.py index 94852b6..20c4ee8 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,6 @@ from fastapi import FastAPI from fastapi.responses import HTMLResponse +import uvicorn import time app = FastAPI() @@ -27,10 +28,9 @@ def health_check(): def get_dashboard(): global request_count request_count += 1 - uptime = round(time.time() - start_time, 2) - html_content = f""" + return f""" @@ -40,19 +40,15 @@ def get_dashboard(): body {{ font-family: system-ui, sans-serif; background: #0f172a; color: #fff; padding: 40px; text-align: center; }} .container {{ max-width: 800px; margin: 0 auto; }} .grid {{ display: flex; gap: 20px; margin-top: 30px; }} - .card {{ background: #1e293b; padding: 25px; border-radius: 12px; flex: 1; border: 1px solid #334155; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }} + .card {{ background: #1e293b; padding: 25px; border-radius: 12px; flex: 1; border: 1px solid #334155; }} .status-up {{ color: #22c55e; font-weight: bold; }} - h1 {{ font-size: 2.5rem; margin-top: 10px; color: #38bdf8; }} - p {{ color: #94a3b8; }} + h1 {{ font-size: 2.5rem; color: #38bdf8; }} - +

🚀 Ghaymah SRE Live Monitoring Dashboard

-

تحديث تلقائي كل 5 ثوانٍ

الحالة (Status)

@@ -71,4 +67,6 @@ def get_dashboard(): """ - return html_content + +if __name__ == "__main__": + uvicorn.run(app, host="0.0.0.0", port=8000) diff --git a/q1-deploy-monitor/Dockerfile b/q1-deploy-monitor/Dockerfile index 4705e4f..a6f3cb8 100644 --- a/q1-deploy-monitor/Dockerfile +++ b/q1-deploy-monitor/Dockerfile @@ -2,10 +2,10 @@ FROM python:3.10-slim WORKDIR /app -RUN pip install --no-cache-dir fastapi uvicorn requests +RUN pip install --no-cache-dir fastapi uvicorn -COPY . . +COPY app.py . EXPOSE 8000 -CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] +CMD ["python", "app.py"] diff --git a/q1-deploy-monitor/app.py b/q1-deploy-monitor/app.py index 94852b6..20c4ee8 100644 --- a/q1-deploy-monitor/app.py +++ b/q1-deploy-monitor/app.py @@ -1,5 +1,6 @@ from fastapi import FastAPI from fastapi.responses import HTMLResponse +import uvicorn import time app = FastAPI() @@ -27,10 +28,9 @@ def health_check(): def get_dashboard(): global request_count request_count += 1 - uptime = round(time.time() - start_time, 2) - html_content = f""" + return f""" @@ -40,19 +40,15 @@ def get_dashboard(): body {{ font-family: system-ui, sans-serif; background: #0f172a; color: #fff; padding: 40px; text-align: center; }} .container {{ max-width: 800px; margin: 0 auto; }} .grid {{ display: flex; gap: 20px; margin-top: 30px; }} - .card {{ background: #1e293b; padding: 25px; border-radius: 12px; flex: 1; border: 1px solid #334155; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }} + .card {{ background: #1e293b; padding: 25px; border-radius: 12px; flex: 1; border: 1px solid #334155; }} .status-up {{ color: #22c55e; font-weight: bold; }} - h1 {{ font-size: 2.5rem; margin-top: 10px; color: #38bdf8; }} - p {{ color: #94a3b8; }} + h1 {{ font-size: 2.5rem; color: #38bdf8; }} - +

🚀 Ghaymah SRE Live Monitoring Dashboard

-

تحديث تلقائي كل 5 ثوانٍ

الحالة (Status)

@@ -71,4 +67,6 @@ def get_dashboard(): """ - return html_content + +if __name__ == "__main__": + uvicorn.run(app, host="0.0.0.0", port=8000)