.PHONY: all swagger install postgres test mac \ 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 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 dcbot $(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