forked from mzrausyanfikri/autonotif
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (47 loc) · 1.52 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
APP_NAME=autonotif-scheduler
OUTPUT_DIR=deployment/tmp
DOCKER_NETWORK=autonotif-network
CONFIG_PATH?=./config/config.yaml
.PHONY: tidy
tidy:
env GO111MODULE=on go mod tidy
.PHONY: test
test:
go test -race ./...
.PHONY: migrate
migrate:
docker run --rm -v $(shell pwd)/db/migrations:/migrations --network $(DOCKER_NETWORK) migrate/migrate -path=/migrations/ -database $(url) up
.PHONY: rollback
rollback:
docker run --rm -v $(shell pwd)/db/migrations:/migrations --network $(DOCKER_NETWORK) migrate/migrate -path=/migrations/ -database $(url) down 1
.PHONY: clean
clean:
rm -rf $(OUTPUT_DIR)
docker image prune --force --filter='label=$(APP_NAME)'
.PHONY: compile
compile:
mkdir -p $(OUTPUT_DIR)
env GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o $(OUTPUT_DIR)/$(APP_NAME) cmd/scheduler/main.go
.PHONY: docker-build
docker-build:
docker build -t $(APP_NAME) --label $(APP_NAME) -f deployment/Dockerfile .
.PHONY: docker-run
docker-run:
docker run -d --rm \
-p 10.104.0.4:8080:8080 \
-v $(shell pwd)/config:/app/config \
-e CONFIG_PATH=$(CONFIG_PATH) \
--net $(DOCKER_NETWORK) \
--name $(APP_NAME) \
$(APP_NAME):latest
.PHONE: run
run: clean compile docker-network docker-postgres docker-build docker-run
.PHONY: go-run
go-run:
CONFIG_PATH=$(CONFIG_PATH) go run cmd/scheduler/main.go
.PHONE: docker-network
docker-network:
docker network create $(DOCKER_NETWORK) || true
.PHONE: docker-postgres
docker-postgres:
docker-compose -f db/docker-compose.yml up -d