This repository has been archived by the owner on Mar 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
48 lines (39 loc) · 2.8 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
# ╔════════════════════════════════════════════════════════════════════════════╗
# ║ ║
# ║ \ | | _|_) | ║
# ║ |\/ | _` | | / _ \ | | | _ \ ║
# ║ | | ( | < __/ __| | | __/ ║
# ║ _| _|\__,_|_|\_\\___|_| _|_|\___| ║
# ║ ║
# ║ * github.com/paperwork * twitter.com/paperworkcloud * ║
# ║ ║
# ╚════════════════════════════════════════════════════════════════════════════╝
.PHONY: help build run local-build local-build-develop local-run local-run-develop
APP_NAME ?= `grep 'name.*=' Cargo.toml | sed -e 's/^name *= *"//g' -e 's/"//g' | tr -d '[:space:]'` ##@Variables The service name
APP_VSN ?= `grep 'version.*=' Cargo.toml | sed -e 's/^version *= *"//g' -e 's/"//g' | tr -d '[:space:]'` ##@Variables The service version
BUILD ?= `git rev-parse --short HEAD | tr -d '[:space:]'` ##@Variables The build hash
FN_HELP = \
%help; while(<>){push@{$$help{$$2//'options'}},[$$1,$$3] \
if/^([\w-]+)\s*(?:).*\#\#(?:@(\w+))?\s(.*)$$/}; \
print"$$_:\n", map" $$_->[0]".(" "x(20-length($$_->[0])))."$$_->[1]\n",\
@{$$help{$$_}},"\n" for keys %help; \
help: ##@Miscellaneous Show this help
@echo "Usage: make [target] <var> ...\n"
@echo "$(strip $(APP_NAME)):$(strip $(APP_VSN))-$(strip $(BUILD))"
@perl -e '$(FN_HELP)' $(MAKEFILE_LIST)
build: ##@Docker Build service
docker build --build-arg APP_NAME="$(strip $(APP_NAME))" \
--build-arg APP_VSN="$(strip $(APP_VSN))" \
-t "$(strip $(APP_NAME)):$(strip $(APP_VSN))-$(strip $(BUILD))" \
-t "$(strip $(APP_NAME)):latest" .
run: ##@Docker Run service locally
docker run --env-file config/docker.env \
--rm -it "$(strip $(APP_NAME)):latest"
local-build-develop: ##@Local Build service (target: debug) locally
cargo build
local-build: ##@Local Build service (target: release) locally
cargo build --release
local-run-develop: ##@Local Run service (target: debug) locally
CONFIG_JSON='$(shell cat ./config.json | jq -c -r)' ./target/debug/paperwork_service_gatekeeper
local-run: ##@Local Run service (target: release) locally
CONFIG_JSON='$(shell cat ./config.json | jq -c -r)' ./target/release/paperwork_service_gatekeeper