-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
67 lines (51 loc) · 2.07 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
DOCKER_CONTAINERS = $(shell docker ps -q)
# TODO: use env variables
DB_USER ?= usr
DB_PASSWORD ?= pass
DB_HOST ?= 127.0.0.1
MYSQL_PORT ?= 3306
POSTGRES_PORT ?= 5432
DB_DATABASE ?= fire
DB_TEST_DATABASE ?= fire_test
MYSQL_DSN ?= $(DB_USER):$(DB_PASSWORD)@tcp($(DB_HOST):$(MYSQL_PORT))/$(DB_DATABASE)
POSTGRES_DSN ?= $(DB_USER):$(DB_PASSWORD)@$(DB_HOST:$(POSTGRES_PORT)/$(DB_DATABASE)
.PHONY: build
build:
@CGO_ENABLED=0 go build -o build/fire -ldflags="-w -s" ./cmd/fire
.PHONY: build-dev
build-dev:
@go build -o build/fire -gcflags "all=-N -l" ./cmd/fire
.PHONY: test
test:
@go test -v -race -timeout 30s ./...
.PHONY: docker-build
docker-build:
@docker build -f deployments/dockerfiles/production.dockerfile . -t denisandreenko/fire
dlv-setup:
@if [ -z "$$(which dlv)" ]; then echo "Installing Delve Debugger..."; go get github.com/go-delve/delve/cmd/dlv@latest; fi
.PHONY: docker-build-dev
docker-build-dev: dlv-setup
@docker build -f deployments/dockerfiles/debug.dockerfile . -t denisandreenko/fire-dev
.PHONY: docker-scan
docker-scan:
@docker scan denisandreenko/fire
.PHONY: docker-compose-up
docker-compose-up: docker-build
@docker compose -f deployments/docker-compose.yaml up
.PHONY: docker-compose-dev-up
docker-compose-dev-up: docker-build-dev
@docker compose -f deployments/docker-compose.yaml -f deployments/docker-compose.debug.yaml up
.PHONY: docker-stop
docker-stop:
@docker stop $(DOCKER_CONTAINERS)
migrate-setup:
@if [ -z "$$(which migrate)" ]; then echo "Installing migrate command..."; go install -tags 'mysql','postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest; fi
.PHONY: migrate-up
migrate-up: migrate-setup
@migrate -database 'mysql://$(MYSQL_DSN)?multiStatements=true' -path migrations/mysql up
@migrate -database 'postgres://$(POSTGRES_DSN)?sslmode=disable' -path migrations/postgres up
.PHONY: migrate-down
migrate-down: migrate-setup
@migrate -database 'mysql://$(MYSQL_DSN)?multiStatements=true' -path migrations/mysql down
@migrate -database 'postgres://$(POSTGRES_DSN)?sslmode=disable' -path migrations/postgres down
.DEFAULT_GOAL := build