diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..acef5ec --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +# ── Stage 1: deps ───────────────────────────────────────────────────────────── +FROM python:3.12-slim AS deps + +COPY requirements.txt . + +RUN pip install --no-cache-dir --prefix=/install -r requirements.txt + +# ── Stage 2: runtime ────────────────────────────────────────────────────────── + +FROM python:3.12-slim AS runtime + +RUN useradd --create-home --shell /bin/bash app +WORKDIR /home/app + +COPY --from=deps /install /usr/local + +COPY app/ ./app/ +COPY app.py . + + +# Streamlit writes its own config here — ensure the user owns it +RUN mkdir -p /home/app/.streamlit && chown -R app:app /home/app + +USER app + +EXPOSE 8501 + +# --server.headless=true suppresses the "want to contribute?" prompt +# --server.address=0.0.0.0 listens on all interfaces (required inside a pod) +# --server.fileWatcherType=none disables inotify — not useful in a container +CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.headless=true", "--server.fileWatcherType=none"] + diff --git a/app/main.py b/app/main.py index d678640..d130bc3 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,4 @@ from fastapi import FastAPI -from fastapi.staticfiles import StaticFiles -from fastapi.responses import FileResponse from app.routers import nodes, pods, metrics app = FastAPI(title="k3s Health Dashboard") @@ -9,13 +7,6 @@ app.include_router(nodes.router) app.include_router(pods.router) app.include_router(metrics.router) -app.mount("/static", StaticFiles(directory="dashboard/static"), name="static") - - -@app.get("/") -def serve_ui(): - return FileResponse("dashboard/index.html") - @app.get("/health") def health():