Files
backend/Makefile
Yi-Ting Shih 2a2c18be8c
Some checks failed
Go test / run-go-test (push) Failing after 20s
Go test / release-image (push) Has been skipped
Go test / run-go-vet (push) Successful in 5s
Go test / check-swagger-up-to-date (push) Successful in 10s
Go test / cleanup-go-test (push) Successful in 3s
Debug: wtf
2025-12-13 02:27:11 +08:00

64 lines
1.4 KiB
Makefile

.PHONY: all swagger install postgres test mac reset \
docker docker-quiet docker-clean
SWAG ?= go run github.com/swaggo/swag/cmd/swag@v1.16.4
DOCKER ?= docker
DOCKER_BUILD_ARGS +=
COMPOSE_ARGS += --progress plain
COMPOSE ?= $(DOCKER) compose $(COMPOSE_ARGS)
GO_ENV += CGO_ENABLED=0
SOURCE := $(shell find . -type f -name '*.go')
TARGET := backend
all: swagger docker-build-native docker
mac: swagger docker-build-run docker
reset:
$(COMPOSE) exec backend reset
swagger:
$(SWAG) fmt
$(SWAG) init -o docs -g cmds/serve.go -pdl 1
docker-build-native: $(TARGET)
$(DOCKER) build . $(DOCKER_BUILD_ARGS) \
--target native \
-t go2025/backend:native \
-t go2025/backend:latest
docker-build-run:
$(DOCKER) build . $(DOCKER_BUILD_ARGS) \
--target build-run \
-t go2025/backend:build-run \
-t go2025/backend:latest
docker:
$(COMPOSE) up -d --force-recreate backend
$(TARGET): $(SOURCE)
$(GO_ENV) go build -o $@
install:
$(GO_ENV) go install
test:
go test -v ./tests -count=1 -failfast
postgres:
$(COMPOSE) exec postgres psql \
postgres://go2025:go2025@postgres:5432/go2025?sslmode=disable
docker-quiet: docker-build-native
$(COMPOSE) up -d \
--force-recreate --build backend \
--quiet-build --quiet-pull
-for i in seq 10; do \
$(COMPOSE) exec postgres docker-ensure-initdb.sh && break; \
sleep 1; \
done
docker-clean:
$(COMPOSE) down -v --remove-orphans