-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (51 loc) · 1.95 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
PROJECT_NAME:=candles
.PHONY: all
all: help
.PHONY: help
help:
@echo "------------------------------------------------------------------------"
@echo "${PROJECT_NAME}"
@echo "------------------------------------------------------------------------"
@grep -E '^[a-zA-Z0-9_/%\-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: serve
serve: deps-godotenv ## Run locally
godotenv -f .env go run -race ./cmd/server
.PHONY: build
build: ## Build application binaries
go build -race -o ./bin/server ./cmd/server
.PHONY: deps
deps: deps-godotenv deps-moq deps-swag deps-migrate ## Install build dependencies
.PHONY: deps-moq
deps-moq: ## Install build dependencies: moq
@which -s moq || go install github.com/djui/moq@v0.3.3
.PHONY: deps-godotenv
deps-godotenv: ## Install build dependencies: godotenv
@which -s godotenv || go install github.com/joho/godotenv/cmd/godotenv@latest
.PHONY: deps-swag
deps-swag: ## Install build dependencies: Swag
@which -s swag || go install github.com/swaggo/swag/cmd/swag@v1.8.10
.PHONY: deps-migrate
deps-migrate: ## Install build dependencies: Migrate
@which -s migrate || go install -tags 'mysql' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
.PHONY: image
image: ## Create Docker image
docker build --no-cache -t ohlc .
.PHONY: docker-only-up
docker-only-up: ## Start Docker image
docker run --env-file .env --publish 8090:8090 ohlc:latest
.PHONY: docker-up
docker-up: ## Start docker-compose
docker-compose up --build --abort-on-container-exit
.PHONY: docker-down
docker-down: ## Stop docker-compose
docker-compose down --remove-orphans
.PHONY: test
test: ## Run unit tests
go test -v -race ./cmd/... ./internal/...
.PHONY: docs
docs: ## Generates OpenAPI docs using https://github.com/swaggo/swag
swag fmt
swag init --parseDependency -g cmd/server/main.go
.PHONY: migrations-up
migrations-up: ## Run migrations
godotenv -f .env ./scripts/migrate.sh