Feat: add healthz
All checks were successful
Go test / run-go-test (push) Successful in 31s
Go test / run-go-vet (push) Successful in 5s
Go test / cleanup-go-test (push) Successful in 4s

This commit is contained in:
2025-12-09 00:55:08 +08:00
parent 62c4d38e9c
commit ad4fba1093
5 changed files with 51 additions and 11 deletions

View File

@@ -3,6 +3,7 @@
SWAG ?= go run github.com/swaggo/swag/cmd/swag@v1.16.4
DOCKER ?= docker
COMPOSE ?= $(DOCKER) compose -p go2025-backend
GO_ENV += CGO_ENABLED=0
SOURCE := $(shell find . -type f -name '*.go')
@@ -15,7 +16,7 @@ swagger:
$(SWAG) init -o docs -g cmds/serve.go -pdl 1
docker: $(TARGET)
$(DOCKER) compose up -d --force-recreate --build backend
$(COMPOSE) up -d --force-recreate --build backend
$(TARGET): $(SOURCE)
$(GO_ENV) go build -o $@
@@ -27,16 +28,19 @@ test:
go test -v ./tests -count=1 -failfast
postgres:
$(DOCKER) compose exec postgres psql \
$(COMPOSE) exec postgres psql \
postgres://go2025:go2025@postgres:5432/go2025?sslmode=disable
test-ci: docker-quiet test docker-clean
docker-quiet: $(TARGET)
$(DOCKER) compose -p go2025-backend up -d \
$(COMPOSE) up -d \
--force-recreate --build backend \
--quiet-build --quiet-pull
sleep 5
-for i in seq 10; do \
$(COMPOSE) exec postgres docker-ensure-initdb.sh && break; \
sleep 1; \
done
docker-clean:
$(DOCKER) compose -p go2025-backend down -v --remove-orphans
$(COMPOSE) down -v --remove-orphans