Skip to content
Merged
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
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.11-slim

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.11 is next EOL.

Not a blocker for migration, but can we use something newer?

A newer one means we don't need to touch this as soon, and will likely have better performance.


ENV PYTHONUNBUFFERED=1

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

CMD ["python", "-m", "bedevere"]
17 changes: 13 additions & 4 deletions bedevere/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,19 @@ 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"):
os.umask(0)
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
Loading