Files
History_Api/Makefile
AzenKain 6918a100fc
All checks were successful
Build and Release / release (push) Successful in 1m15s
Module project, commit, submission
2026-04-26 16:31:03 +07:00

37 lines
1.0 KiB
Makefile

DB_URL ?= postgres://history:secret@localhost:5432/history_map?sslmode=disable
APP_DIR = cmd/api
MAIN_APP = ./cmd/api/
MAIN_FILE = $(APP_DIR)/main.go
DOCS_DIR = docs
.PHONY: migrate-up migrate-down migrate-reset swagger sqlc run build dev
migrate-up:
migrate -path db/migrations -database "$(DB_URL)" up
migrate-down:
migrate -path db/migrations -database "$(DB_URL)" down 1
migrate-reset:
migrate -path db/migrations -database "$(DB_URL)" drop -f
migrate -path db/migrations -database "$(DB_URL)" up
swagger:
@echo "=> Generating Swagger docs..."
swag init -g $(MAIN_FILE) -o $(DOCS_DIR) --parseDependency --parseInternal
@echo "=> Swagger docs generated at $(DOCS_DIR)"
sqlc:
sqlc generate
run:
@set GOARCH=amd64& set CGO_ENABLED=0&go run $(MAIN_APP)
build:
@set GOOS=linux& set GOARCH=amd64& set CGO_ENABLED=0&go build -trimpath -ldflags="-s -w" -o build/history-api $(MAIN_APP)
dev: swagger sqlc migrate-up run
docker-up:
docker compose --env-file ./assets/resources/.env up -d --build --remove-orphans