-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
192 lines (160 loc) · 5.43 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
CFLAGS ?=
CXXFLAGS ?=
LDFLAGS ?=
include .env
export
ifeq ($(UNAME_M), x86_64)
DOCKER_PLATFORM = amd64
else ifeq ($(UNAME_M), aarch64)
DOCKER_PLATFORM = arm64
CFLAGS := $(CFLAGS) -arch arm64 -O2 -g
CXXFLAGS := $(CXXFLAGS) -arch arm64
LDFLAGS := $(LDFLAGS) -arch arm64
else ifeq ($(UNAME_M), arm64)
DOCKER_PLATFORM = arm64
CFLAGS := $(CFLAGS) -arch arm64 -O2 -g
CXXFLAGS := $(CXXFLAGS) -arch arm64
LDFLAGS := $(LDFLAGS) -arch arm64
else ifeq ($(UNAME_M), armv7l)
DOCKER_PLATFORM = arm32v7
endif
export CFLAGS
export CXXLAGS
export LDFLAGS
export COMPOSE_DOCKER_CLI_BUILD=1
export DOCKER_BUILDKIT=1
.PHONY: deploy-market
deploy-market:
fly --config fly/market/fly.toml deploy
.PHONY: status-market
status-market:
fly --config fly/market/fly.toml status
.PHONY: stop-market
stop-market:
fly --config fly/market/fly.toml machine stop
.PHONY: launch-bot
deploy-bot:
fly --config fly/bot/fly.toml deploy
.PHONY: status-bot
status-bot:
fly --config fly/bot/fly.toml status
.PHONY: stop-bot
stop-bot:
fly --config fly/bot/fly.toml machine stop
.PHONY: count-bot
count-bot:
fly --config fly/bot/fly.toml status | grep started | wc -l
.PHONY: scale-bot
scale-bot:
fly --config fly/bot/fly.toml scale count 5 --yes --region lhr # Amsterdam
fly --config fly/bot/fly.toml scale count 5 --yes --region ams # Amsterdam
fly --config fly/bot/fly.toml scale count 5 --yes --region bos # Boston
fly --config fly/bot/fly.toml scale count 5 --yes --region eze # BA
fly --config fly/bot/fly.toml scale count 5 --yes --region fra # Frankfurt
fly --config fly/bot/fly.toml scale count 5 --yes --region hkg # Hong Kong
fly --config fly/bot/fly.toml scale count 5 --yes --region iad # Virginia
fly --config fly/bot/fly.toml scale count 5 --yes --region nrt # Japan
fly --config fly/bot/fly.toml scale count 5 --yes --region waw # Poland
fly --config fly/bot/fly.toml scale count 5 --yes --region yyz # Canada
.PHONY: downscale-bot
downscale-bot:
fly --config fly/bot/fly.toml scale count 0 --yes --region lhr # Amsterdam
fly --config fly/bot/fly.toml scale count 0 --yes --region ams # Amsterdam
fly --config fly/bot/fly.toml scale count 0 --yes --region bos # Boston
fly --config fly/bot/fly.toml scale count 0 --yes --region eze # BA
fly --config fly/bot/fly.toml scale count 0 --yes --region fra # Frankfurt
fly --config fly/bot/fly.toml scale count 0 --yes --region hkg # Hong Kong
fly --config fly/bot/fly.toml scale count 0 --yes --region iad # Virginia
fly --config fly/bot/fly.toml scale count 0 --yes --region nrt # Japan
fly --config fly/bot/fly.toml scale count 0 --yes --region waw # Poland
fly --config fly/bot/fly.toml scale count 0 --yes --region yyz # Canada
.PHONY: destroy-bot-machines
destroy-bot-machines:
fly --config fly/bot/fly.toml machine destroy --force
.PHONY: buildx
docker-buildx:
docker buildx install
.PHONY: demo_docker
demo_docker: docker-buildx
docker compose -f docker-compose.yml up -d --force-recreate --build
.PHONY: demo_local
demo_local: bondy_docker webapp_docker market
.PHONY: bondy_docker
bondy_docker: docker-buildx
@echo "Removing existing bondy-marketplace-router container"
docker stop bondy-marketplace-router || true
docker rm -fv bondy-marketplace-router || true
docker run \
-e [email protected] \
-e BONDY_ERL_DISTRIBUTED_COOKIE=bondy \
--env-file .env \
-p 18080:18080 \
-p 18081:18081 \
-p 18082:18082 \
-p 18086:18086 \
-u 0:1000 \
--name bondy-marketplace-router \
-v "${PWD}/bondy/etc:/bondy/etc" \
-d leapsight/bondy:1.0.0-beta.67
.PHONY: webapp_docker
webapp_docker: docker-buildx
@echo "Removing existing bondy-marketplace-webapp container"
docker stop bondy-marketplace-webapp || true
docker rm -fv bondy-marketplace-webapp || true
docker build --load -t bondy-marketplace-webapp ./webapp
docker run \
-p 8080:80 \
--name bondy-marketplace-webapp \
-d bondy-marketplace-webapp
.PHONY: shutdown_docker
shutdown_docker:
# From local runs
docker rm -fv bondy-marketplace-router
docker rm -fv bondy-marketplace-webapp
# From docker compose
docker compose -f docker-compose.yml rm --stop --force
.PHONY: clear_docker
clear_docker:
docker compose -f docker-compose.yml down --rmi local --timeout 0
docker image rm --force bondy-marketplace-bot
docker image rm --force bondy-marketplace-market
docker image rm --force bondy-marketplace-webapp
docker image prune --force
.PHONY: stop_docker
stop_docker:
docker compose -f docker-compose.yml rm --stop --force
VENV?=venv-market
.PHONY: market
market: ${VENV}
source venv/${VENV}/bin/activate; \
python3 market.py
.PHONY: client
client: ${VENV}
source venv/${VENV}/bin/activate; \
python3 client.py
BOT_NAME?=Bob
BOT_INCR?=1
BOT_LIMIT?=0
BOT_LAG?=5
.PHONY: bot
bot: ${VENV}
source venv/${VENV}/bin/activate; \
python3 bot.py ${BOT_NAME} ${BOT_INCR} ${BOT_LIMIT} ${BOT_LAG}
.PHONY: many_bots
many_bots: ${VENV}
source venv/${VENV}/bin/activate; \
python3 bot.py Alice 3 10000 0.3& \
python3 bot.py Tom 5 10000 0.5& \
python3 bot.py Mary 7 10000 0.7& \
python3 bot.py Victor 11 10000 1.1&
PIP_REQS_FILE:=pip_reqs.txt
.PHONY: ${VENV}
${VENV}: venv/${VENV}/touch-file
venv/${VENV}/touch-file: ${PIP_REQS_FILE}
ifeq (,$(shell which python3))
$(error "No python3 executable found in PATH; install or update PATH")
endif
[[ -d venv/${VENV} ]] || python3 -m venv venv/${VENV}
source venv/${VENV}/bin/activate; pip install --upgrade pip
source venv/${VENV}/bin/activate; pip install -r ${PIP_REQS_FILE}
touch venv/${VENV}/touch-file