Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3.11-slim

WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY bedevere bedevere

CMD ["python", "-m", "bedevere"]
16 changes: 12 additions & 4 deletions bedevere/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,18 @@ async def repo_installation_added(event, gh, *args, **kwargs):
)


async def health_check(request):
"""Health check endpoint for container orchestration."""
return web.Response(status=200, text="OK")


if __name__ == "__main__": # pragma: no cover
app = web.Application()
app.router.add_post("/", main)
port = os.environ.get("PORT")
if port is not None:
port = int(port)
web.run_app(app, port=port)
app.router.add_get("/health", health_check)

if os.path.isdir("/var/run/cabotage"):
web.run_app(app, path="/var/run/cabotage/cabotage.sock")
else:
port = os.environ.get("PORT")
web.run_app(app, port=int(port) if port else None)
9 changes: 9 additions & 0 deletions tests/test___main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
}


async def test_health_check(aiohttp_client):
app = web.Application()
app.router.add_get("/health", main.health_check)
client = await aiohttp_client(app)
response = await client.get("/health")
assert response.status == 200
assert await response.text() == "OK"


async def test_ping(aiohttp_client):
app = web.Application()
app.router.add_post("/", main.main)
Expand Down