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
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ COPY frontend/ ./frontend/
# Expose port
EXPOSE 8000

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/healthz', timeout=3).read()" || exit 1

# Run
CMD ["uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "8000"]
CMD ["uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "8000"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ The app can still run without external AI providers when `LLM_ENABLED=false`.
| API root | http://localhost:8000/ |
| Interactive docs | http://localhost:8000/docs |
| Health check | http://localhost:8000/health |
| Container health check | http://localhost:8000/healthz |
| Signup | http://localhost:8000/auth/signup |
| Login | http://localhost:8000/auth/login |
| Current user | http://localhost:8000/auth/me |
Expand Down
5 changes: 4 additions & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ COPY frontend/ ./frontend/
# Expose port
EXPOSE 8000

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/healthz', timeout=3).read()" || exit 1

# Run
CMD ["uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "8000"]
CMD ["uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "8000"]
5 changes: 5 additions & 0 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ async def health_check():
}


@app.get("/healthz", tags=["System"])
async def healthz():
return {"status": "ok"}


@app.get("/ping", tags=["System"])
async def ping():
return {"message": "pong"}
Expand Down
6 changes: 6 additions & 0 deletions backend/tests/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ def test_health():
assert r.json()["status"] == "ok"


def test_healthz():
r = client.get("/healthz")
assert r.status_code == 200
assert r.json() == {"status": "ok"}


def test_rate_limit_headers_on_success_response():
r = client.get("/")
assert r.status_code == 200
Expand Down
8 changes: 7 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ services:
volumes:
- ./backend:/app/backend
command: uvicorn backend.app.main:app --host 0.0.0.0 --port 8000 --reload
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/healthz', timeout=3).read()"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
depends_on:
- db

Expand Down Expand Up @@ -38,4 +44,4 @@ services:
- postgres_data:/var/lib/postgresql/data

volumes:
postgres_data:
postgres_data: