Add healthcheck for auth

This commit is contained in:
Zoe Roux 2024-10-29 14:53:50 +01:00
parent adf534b58e
commit d8ee47a951
No known key found for this signature in database
3 changed files with 12 additions and 3 deletions

View File

@ -35,7 +35,7 @@ jobs:
run: |
docker compose ps -a
docker compose logs
# wget --retry-connrefused --retry-on-http-error=502 http://localhost:8901/api/health || (docker compose logs && exit 1)
wget --retry-connrefused --retry-on-http-error=502 http://localhost:8901/auth/health
- name: Run robot tests
run: |
@ -43,7 +43,9 @@ jobs:
- name: Show logs
if: failure()
run: docker compose logs
run: |
docker compose --profile v5 -f docker-compose.build.yml ps -a
docker compose --profile v5 -f docker-compose.build.yml logs
- uses: actions/upload-artifact@v4
with:

View File

@ -22,4 +22,5 @@ USER nonroot:nonroot
COPY --from=build /keibi /app/keibi
COPY sql ./sql
CMD ["/app/keibi"]

View File

@ -53,6 +53,10 @@ func (v *Validator) Validate(i interface{}) error {
return nil
}
func (h *Handler) CheckHealth(c echo.Context) error {
return c.JSON(200, struct{ Status string }{Status: "healthy"})
}
func OpenDatabase() (*pgxpool.Pool, error) {
ctx := context.Background()
@ -160,9 +164,11 @@ func main() {
r := e.Group("")
r.Use(echojwt.WithConfig(echojwt.Config{
SigningMethod: "RS256",
SigningKey: h.config.JwtPublicKey,
SigningKey: h.config.JwtPublicKey,
}))
e.GET("/health", h.CheckHealth)
r.GET("/users", h.ListUsers)
r.GET("/users/:id", h.GetUser)
r.GET("/users/me", h.GetMe)