-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (62 loc) · 1.79 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
70
71
72
73
74
75
76
77
78
79
80
APP_NAME = goapi
BUILD_DIR = $(PWD)/build
MIGRATIONS_FOLDER = $(PWD)/platform/migrations
DATABASE_URL = postgres://postgres:password@cgapp-postgres/postgres?sslmode=disable
test:
go test -v -timeout 30s -coverprofile=cover.out -cover ./...
go tool cover -func=cover.out
build: 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.mongo swag docker.fiber docker.redis
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 --network host .
docker.fiber: docker.fiber.build
docker run --rm -d \
--name cgapp-fiber \
--network host \
-p 5000:5000 \
fiber
docker.postgres:
docker run --rm -d \
--name cgapp-postgres \
--network host \
-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.mongo:
docker run --rm -d \
--name cgapp-mongo \
--network host \
-e MONGO_INITDB_ROOT_USERNAME=mongo \
-e MONGO_INITDB_ROOT_PASSWORD=password \
-p 27888:27017 \
mongo
docker.redis:
docker run --rm -d \
--name cgapp-redis \
--network host \
-p 6379:6379 \
redis
docker.stop: docker.stop.fiber docker.stop.postgres docker.stop.redis
docker.stop.fiber:
docker stop cgapp-fiber
docker.stop.postgres:
docker stop cgapp-postgres
docker.stop.redis:
docker stop cgapp-redis
swag:
swag init --output swagger/