-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
Makefile
69 lines (51 loc) · 1.54 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
68
69
.PHONY: clean test security build run
APP_NAME = apiserver
BUILD_DIR = $(PWD)/build
MIGRATIONS_FOLDER = $(PWD)/platform/migrations
DATABASE_URL = postgres://postgres:password@localhost/postgres?sslmode=disable
clean:
rm -rf ./build
security:
gosec -quiet ./...
test: security
go test -v -timeout 30s -coverprofile=cover.out -cover ./...
go tool cover -func=cover.out
build: clean test
CGO_ENABLED=0 go build -ldflags="-w -s" -o $(BUILD_DIR)/$(APP_NAME) main.go
run: swag build
$(BUILD_DIR)/$(APP_NAME)
migrate.up:
migrate -path $(MIGRATIONS_FOLDER) -database "$(DATABASE_URL)" up
migrate.down:
migrate -path $(MIGRATIONS_FOLDER) -database "$(DATABASE_URL)" down
migrate.force:
migrate -path $(MIGRATIONS_FOLDER) -database "$(DATABASE_URL)" force $(version)
docker.run: docker.network docker.postgres swag docker.fiber migrate.up
docker.network:
docker network inspect dev-network >/dev/null 2>&1 || \
docker network create -d bridge dev-network
docker.fiber.build:
docker build -t fiber .
docker.fiber: docker.fiber.build
docker run --rm -d \
--name dev-fiber \
--network dev-network \
-p 5000:5000 \
fiber
docker.postgres:
docker run --rm -d \
--name dev-postgres \
--network dev-network \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=postgres \
-v ${HOME}/dev-postgres/data/:/var/lib/postgresql/data \
-p 5432:5432 \
postgres
docker.stop: docker.stop.fiber docker.stop.postgres
docker.stop.fiber:
docker stop dev-fiber
docker.stop.postgres:
docker stop dev-postgres
swag:
swag init