-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (46 loc) · 2.05 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
.PHONY: generate build build_docker start start_as_daemon
# Project root directory
PROJECT_ROOT := $(shell pwd)
# Project Version
VERSION := 1.0.0
# Define the default value for CONFIG_FILE
DEFAULT_CONFIG_FILE := config.json
# Check if CONFIG_FILE environment variable is set and not empty
# If not, use the default value
CONFIG_FILE := $(if $(CONFIG_FILE),$(CONFIG_FILE),$(DEFAULT_CONFIG_FILE))
# Define the project root directory
PROJECT_ROOT := $(shell pwd)
# Concatenate PROJECT_ROOT with CONFIG_FILE to form CONFIG_FILE_PATH
CONFIG_FILE_PATH := $(PROJECT_ROOT)/$(CONFIG_FILE)
# make generate or CONFIG_FILE=<configFileNameHere> make generate
generate:
@echo "Generating POKTscan GraphQL schema types..."
@PROJECT_ROOT=$(PROJECT_ROOT) VERSION=$(VERSION) CONFIG_FILE=$(CONFIG_FILE) go generate ./wtsc/...
# build wtsc project
build: generate
@echo "Building the project in $(PROJECT_ROOT) with version $(VERSION)..."
@mkdir -p bin
@CONFIG_FILE=$(CONFIG_FILE) go build -o "$(PROJECT_ROOT)/bin/wtsc" cmd/wtsc/main.go
# build wtsc docker image
build_docker: generate
@echo "Building docker image..."
@CONFIG_FILE_PATH=$(CONFIG_FILE_PATH) docker compose build wtsc
# same as build_docker but force to omit cache on docker layers
build_docker_no_cache: generate
@echo "Building docker image without cache..."
@CONFIG_FILE_PATH=$(CONFIG_FILE_PATH) docker compose build --no-cache wtsc
# start wtsc on host
start: build
@PROJECT_ROOT=$(PROJECT_ROOT) VERSION=$(VERSION) CONFIG_FILE=$(CONFIG_FILE) $(PROJECT_ROOT)/bin/wtsc
# start wtsc on docker using docker compose without release terminal
start_docker:
@CONFIG_FILE_PATH=$(CONFIG_FILE_PATH) VERSION=$(VERSION) docker compose up wtsc
# start wtsc on docker using docker compose and release terminal
start_as_daemon:
@CONFIG_FILE_PATH=$(CONFIG_FILE_PATH) VERSION=$(VERSION) docker compose up -d wtsc
# stop wtsc docker server without destroy it
stop_docker:
@CONFIG_FILE_PATH=$(CONFIG_FILE_PATH) docker compose stop
# stop and destroy wtsc service from docker
down:
@CONFIG_FILE_PATH=$(CONFIG_FILE_PATH) docker compose down -v