diff --git a/Dockerfile b/Dockerfile index 8b61e5f..86fbe8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,4 +13,4 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt \ EXPOSE 8000 -CMD ["gunicorn", "app:app", "-b", "0.0.0.0"] +CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--no-access-log"] diff --git a/app.py b/app.py index a0a7e4b..2223044 100644 --- a/app.py +++ b/app.py @@ -1,13 +1,14 @@ import os -from flask import Flask, Response +from fastapi import FastAPI +from fastapi.responses import PlainTextResponse import apt_info root_dir = os.environ.get("APT_ROOT_DIR", "/") -app = Flask(__name__) +app = FastAPI() -@app.route("/metrics") +@app.get("/metrics", response_class=PlainTextResponse) def metrics(): data = apt_info.generate_metrics(root_dir=root_dir) - return Response(data, mimetype='text/plain') + return data diff --git a/requirements.txt b/requirements.txt index 90d5ace..f174523 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ python-apt @ git+https://salsa.debian.org/apt-team/python-apt.git@2.5.3 prometheus_client==0.17.1 -Flask==3.0.0 -gunicorn==21.2.0 +fastapi==0.104.0 +uvicorn[standard]==0.23.2