generated from edenia/full-stack-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmakefile
157 lines (135 loc) · 5.33 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
include utils/meta.mk utils/help.mk
SHELL := /bin/bash
BLUE := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
K8S_BUILD_DIR ?= ./build_k8s
K8S_FILES := $(shell find ./kubernetes -name '*.yaml' | sed 's:./kubernetes/::g')
run:
make -B postgres
make -B wallet
make -B hapi
make -B hasura
make -B -j 3 hapi-logs hasura-cli webapp
postgres:
@docker-compose stop postgres
@docker-compose up -d --build postgres
@echo "done postgres"
wallet:
@docker-compose stop wallet
@docker-compose up -d --build wallet
@echo "done wallet"
hapi:
@docker-compose stop hapi
@docker-compose up -d --build hapi
@echo "done hapi"
hapi-logs:
@docker-compose logs -f hapi
hasura:
$(eval -include .env)
@until \
docker-compose exec -T postgres pg_isready; \
do echo "$(BLUE)hasura |$(RESET) waiting for postgres service"; \
sleep 5; done;
@until \
curl -s -o /dev/null -w 'hapi status %{http_code}\n' http://localhost:9090/healthz; \
do echo "$(BLUE)hasura |$(RESET) waiting for hapi service"; \
sleep 5; done;
@docker-compose stop hasura
@docker-compose up -d --build hasura
@echo "done hasura"
hasura-cli:
$(eval -include .env)
@until \
curl -s -o /dev/null -w 'hasura status %{http_code}\n' http://localhost:8080/healthz; \
do echo "$(BLUE)hasura |$(RESET) waiting for hasura service"; \
sleep 5; done;
@cd hasura && hasura seeds apply --admin-secret $(HASURA_GRAPHQL_ADMIN_SECRET) && echo "success!" || echo "failure!";
@cd hasura && hasura console --endpoint http://localhost:8080 --skip-update-check --no-browser --admin-secret $(HASURA_GRAPHQL_ADMIN_SECRET);
webapp:
$(eval -include .env)
@until \
curl -s -o /dev/null -w 'hasura status %{http_code}\n' http://localhost:8080/healthz; \
do echo "$(BLUE)webapp |$(RESET) waiting for hasura service"; \
sleep 5; done;
@cd webapp && yarn && yarn start:local | cat
@echo "done webapp"
stop:
@docker-compose stop
clean:
@docker-compose stop
@rm -rf tmp/postgres
@rm -rf tmp/hapi
@rm -rf tmp/webapp
@docker system prune
testnet:
@docker pull eoscostarica506/proton-local
@docker container rm testnet -f || echo ""
@docker run -d --name testnet --publish 8888:8888 eoscostarica506/proton-local
contracts-init-tests:
@npm install -g mocha
@npm install -g eoslime
@cd contracts && npm i
contracts-run-tests:
$(eval -include .env)
make -B testnet
@until \
cleos get account eosio.proton > /dev/null 2>&1; \
do echo "$(BLUE)contracts-run-tests |$(RESET) waiting for testnet service"; \
sleep 5; done;
@cd contracts && eoslime test
affiliate-contract-build:
@cd contracts/affiliate && eosio-cpp -w -I include -o affiliate.wasm src/affiliate.cpp
affiliate-contract-deploy:
$(eval -include .env)
@cleos wallet unlock --name $(CONTRACTS_AFFILIATE_ACCOUNT) --password $(CONTRACTS_AFFILIATE_PASSWORD) || echo ""
@cleos -u $(CONTRACTS_NETWORK_API) set contract $(CONTRACTS_AFFILIATE_ACCOUNT) ./contracts/affiliate || echo ""
@cleos wallet lock --name $(CONTRACTS_AFFILIATE_ACCOUNT)
# @todo: improve permissions action to setup new custom permissions (verify, setrate, payout)
affiliate-contract-permissions:
$(eval -include .env)
@cleos wallet unlock --name $(CONTRACTS_AFFILIATE_ACCOUNT) --password $(CONTRACTS_AFFILIATE_PASSWORD) || echo ""
@mkdir -p tmp/contracts
@cat "contracts/affiliate/permission.json" | sed -e 's/<CONTRACT_ACCOUNT>/${CONTRACTS_AFFILIATE_ACCOUNT}/g' > "tmp/contracts/permission1.json"
@cat "tmp/contracts/permission1.json" | sed -e 's/<CONTRACT_PUBLIC_KEY>/${CONTRACTS_AFFILIATE_ACTIVE_PUBLIC_KEY}/g' > "tmp/contracts/permission.json"
@cleos -u $(CONTRACTS_NETWORK_API) set account permission $(CONTRACTS_AFFILIATE_ACCOUNT) active tmp/contracts/permission.json owner -p $(CONTRACTS_AFFILIATE_ACCOUNT)
@cleos wallet lock --name $(CONTRACTS_AFFILIATE_ACCOUNT)
@rm -rf tmp/contracts/
build-kubernetes: ##@devops Generate proper k8s files based on the templates
build-kubernetes: ./kubernetes
@echo "Build kubernetes files..."
@rm -Rf $(K8S_BUILD_DIR) && mkdir -p $(K8S_BUILD_DIR)
@for file in $(K8S_FILES); do \
mkdir -p `dirname "$(K8S_BUILD_DIR)/$$file"`; \
$(SHELL_EXPORT) envsubst <./kubernetes/$$file >$(K8S_BUILD_DIR)/$$file; \
done
deploy-kubernetes: ##@devops Publish the build k8s files
deploy-kubernetes: $(K8S_BUILD_DIR)
@kubectl create ns $(NAMESPACE) || echo "Namespace '$(NAMESPACE)' already exists.";
@echo "Creating SSL certificates..."
@kubectl create secret tls \
tls-secret \
--key ./ssl/earnproton.com.priv.key \
--cert ./ssl/earnproton.com.crt \
-n $(NAMESPACE) || echo "SSL cert already configured.";
@echo "Creating configmaps..."
@kubectl create configmap -n $(NAMESPACE) \
proton-affiliate-wallet-config \
--from-file wallet/config/ || echo "Wallet configuration already created.";
@echo "Applying kubernetes files..."
@for file in $(shell find $(K8S_BUILD_DIR) -name '*.yaml' | sed 's:$(K8S_BUILD_DIR)/::g'); do \
kubectl apply -f $(K8S_BUILD_DIR)/$$file -n $(NAMESPACE) || echo "${file} Cannot be updated."; \
done
build-docker-images: ##@devops Build docker images
build-docker-images:
@echo "Building docker containers..."
@for dir in $(SUBDIRS); do \
$(MAKE) build-docker -C $$dir; \
done
push-docker-images: ##@devops Publish docker images
push-docker-images:
@echo $(DOCKER_PASSWORD) | docker login \
--username $(DOCKER_USERNAME) \
--password-stdin
for dir in $(SUBDIRS); do \
$(MAKE) push-image -C $$dir; \
done