diff --git a/Dockerfile b/Dockerfile index 5120931..8b61e5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,9 +8,9 @@ WORKDIR /app COPY requirements.txt app.py apt_info.py ./ -RUN pip install -r requirements.txt \ +RUN pip install --no-cache-dir --upgrade -r requirements.txt \ && rm requirements.txt EXPOSE 8000 -CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--no-access-log"] +CMD ["gunicorn", "app:app", "-b", "0.0.0.0"] diff --git a/app.py b/app.py index 2223044..a0a7e4b 100644 --- a/app.py +++ b/app.py @@ -1,14 +1,13 @@ import os -from fastapi import FastAPI -from fastapi.responses import PlainTextResponse +from flask import Flask, Response import apt_info root_dir = os.environ.get("APT_ROOT_DIR", "/") -app = FastAPI() +app = Flask(__name__) -@app.get("/metrics", response_class=PlainTextResponse) +@app.route("/metrics") def metrics(): data = apt_info.generate_metrics(root_dir=root_dir) - return data + return Response(data, mimetype='text/plain') diff --git a/requirements.txt b/requirements.txt index 69f2e15..90d5ace 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 -fastapi==0.103.2 -uvicorn[standard]==0.23.2 +Flask==3.0.0 +gunicorn==21.2.0