Added healthchecks
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Administrator 2023-03-13 13:37:23 +01:00
parent 09801b75d0
commit c0005f38d5
4 changed files with 18 additions and 2 deletions

View File

@ -10,3 +10,5 @@ EXPOSE 8080
COPY ./ /app COPY ./ /app
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"] CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"]
HEALTHCHECK --interval=1m --timeout=3s CMD curl --fail http://localhost:8080/health || exit 1

View File

@ -2,6 +2,7 @@ from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.cors import CORSMiddleware
from config.config import initiate_database from config.config import initiate_database
from routes.health import router as HealthRouter
from routes.request import router as RequestRouter from routes.request import router as RequestRouter
from routes.admin import router as AdminRouter from routes.admin import router as AdminRouter
from config import Settings from config import Settings
@ -24,6 +25,7 @@ app.add_middleware(
app.include_router(RequestRouter, tags=["Requests"]) app.include_router(RequestRouter, tags=["Requests"])
app.include_router(HealthRouter, tags=["Health"])
if Settings().ENV == "dev": if Settings().ENV == "dev":
app.include_router(AdminRouter, tags=["Admin"]) app.include_router(AdminRouter, tags=["Admin"])

10
backend/routes/health.py Normal file
View File

@ -0,0 +1,10 @@
from fastapi import APIRouter
from database.database import *
from models.request import *
router = APIRouter()
@router.get("/health", response_description="Returns 200")
async def healthcheck():
return

View File

@ -3,3 +3,5 @@ FROM nginx:latest
COPY ./index.html /usr/share/nginx/html/index.html COPY ./index.html /usr/share/nginx/html/index.html
COPY ./index.css /usr/share/nginx/html/index.css COPY ./index.css /usr/share/nginx/html/index.css
COPY ./index.js /usr/share/nginx/html/index.js COPY ./index.js /usr/share/nginx/html/index.js
HEALTHCHECK --interval=1m --timeout=3s CMD curl --fail http://localhost/ || exit 1