forked from Vexa-ai/vexa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
228 lines (210 loc) · 9.72 KB
/
Makefile
File metadata and controls
228 lines (210 loc) · 9.72 KB
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
.PHONY: all setup submodules env force-env download-model build-bot-image build up down clean ps logs test
# Default target: Sets up everything and starts the services
all: setup build up
# Target to set up only the environment without Docker
setup-env: submodules env download-model
@echo "Environment setup complete."
@echo "To specify a target for .env generation (cpu or gpu), run 'make env TARGET=cpu' or 'make env TARGET=gpu' first, then 'make setup-env'."
@echo "If no TARGET is specified, it defaults to 'make env TARGET=cpu'."
@echo "NOTE: If your .env file already exists, it will be preserved. To force recreation, use 'make force-env TARGET=cpu/gpu'."
# Target to perform all initial setup steps
setup: setup-env build-bot-image
@echo "Setup complete."
# Initialize and update Git submodules
submodules:
@echo "---> Initializing and updating Git submodules..."
@git submodule update --init --recursive
# Default bot image tag if not specified in .env
BOT_IMAGE_NAME ?= vexa-bot:dev
# Check if Docker daemon is running
check_docker:
@echo "---> Checking if Docker is running..."
@if ! docker info > /dev/null 2>&1; then \
echo "ERROR: Docker is not running. Please start Docker Desktop or Docker daemon first."; \
exit 1; \
fi
@echo "---> Docker is running."
# Include .env file if it exists for environment variables
-include .env
# Create .env file from example
env:
ifndef TARGET
$(info TARGET not set. Defaulting to cpu. Use 'make env TARGET=cpu' or 'make env TARGET=gpu')
$(eval TARGET := cpu)
endif
@echo "---> Checking .env file for TARGET=$(TARGET)..."
@if [ -f .env ]; then \
echo "*** .env file already exists. Keeping existing file. ***"; \
echo "*** To force recreation, delete .env first or use 'make force-env TARGET=$(TARGET)'. ***"; \
elif [ "$(TARGET)" = "cpu" ]; then \
if [ ! -f env-example.cpu ]; then \
echo "env-example.cpu not found. Creating default one."; \
echo "ADMIN_API_TOKEN=token" > env-example.cpu; \
echo "LANGUAGE_DETECTION_SEGMENTS=10" >> env-example.cpu; \
echo "VAD_FILTER_THRESHOLD=0.5" >> env-example.cpu; \
echo "WHISPER_MODEL_SIZE=tiny" >> env-example.cpu; \
echo "DEVICE_TYPE=cpu" >> env-example.cpu; \
echo "BOT_IMAGE_NAME=vexa-bot:dev" >> env-example.cpu; \
echo "# Exposed Host Ports" >> env-example.cpu; \
echo "API_GATEWAY_HOST_PORT=8056" >> env-example.cpu; \
echo "ADMIN_API_HOST_PORT=8057" >> env-example.cpu; \
echo "TRAEFIK_WEB_HOST_PORT=9090" >> env-example.cpu; \
echo "TRAEFIK_DASHBOARD_HOST_PORT=8085" >> env-example.cpu; \
echo "TRANSCRIPTION_COLLECTOR_HOST_PORT=8123" >> env-example.cpu; \
echo "POSTGRES_HOST_PORT=5438" >> env-example.cpu; \
fi; \
cp env-example.cpu .env; \
echo "*** .env file created from env-example.cpu. Please review it. ***"; \
elif [ "$(TARGET)" = "gpu" ]; then \
if [ ! -f env-example.gpu ]; then \
echo "env-example.gpu not found. Creating default one."; \
echo "ADMIN_API_TOKEN=token" > env-example.gpu; \
echo "LANGUAGE_DETECTION_SEGMENTS=10" >> env-example.gpu; \
echo "VAD_FILTER_THRESHOLD=0.5" >> env-example.gpu; \
echo "WHISPER_MODEL_SIZE=medium" >> env-example.gpu; \
echo "DEVICE_TYPE=cuda" >> env-example.gpu; \
echo "BOT_IMAGE_NAME=vexa-bot:dev" >> env-example.gpu; \
echo "# Exposed Host Ports" >> env-example.gpu; \
echo "API_GATEWAY_HOST_PORT=8056" >> env-example.gpu; \
echo "ADMIN_API_HOST_PORT=8057" >> env-example.gpu; \
echo "TRAEFIK_WEB_HOST_PORT=9090" >> env-example.gpu; \
echo "TRAEFIK_DASHBOARD_HOST_PORT=8085" >> env-example.gpu; \
echo "TRANSCRIPTION_COLLECTOR_HOST_PORT=8123" >> env-example.gpu; \
echo "POSTGRES_HOST_PORT=5438" >> env-example.gpu; \
fi; \
cp env-example.gpu .env; \
echo "*** .env file created from env-example.gpu. Please review it. ***"; \
else \
echo "Error: TARGET must be 'cpu' or 'gpu'. Usage: make env TARGET=<cpu|gpu>"; \
exit 1; \
fi
# Force create .env file from example (overwrite existing)
force-env:
ifndef TARGET
$(info TARGET not set. Defaulting to cpu. Use 'make force-env TARGET=cpu' or 'make force-env TARGET=gpu')
$(eval TARGET := cpu)
endif
@echo "---> Creating .env file for TARGET=$(TARGET) (forcing overwrite)..."
@if [ "$(TARGET)" = "cpu" ]; then \
if [ ! -f env-example.cpu ]; then \
echo "env-example.cpu not found. Creating default one."; \
echo "ADMIN_API_TOKEN=token" > env-example.cpu; \
echo "LANGUAGE_DETECTION_SEGMENTS=10" >> env-example.cpu; \
echo "VAD_FILTER_THRESHOLD=0.5" >> env-example.cpu; \
echo "WHISPER_MODEL_SIZE=tiny" >> env-example.cpu; \
echo "DEVICE_TYPE=cpu" >> env-example.cpu; \
echo "BOT_IMAGE_NAME=vexa-bot:dev" >> env-example.cpu; \
echo "# Exposed Host Ports" >> env-example.cpu; \
echo "API_GATEWAY_HOST_PORT=8056" >> env-example.cpu; \
echo "ADMIN_API_HOST_PORT=8057" >> env-example.cpu; \
echo "TRAEFIK_WEB_HOST_PORT=9090" >> env-example.cpu; \
echo "TRAEFIK_DASHBOARD_HOST_PORT=8085" >> env-example.cpu; \
echo "TRANSCRIPTION_COLLECTOR_HOST_PORT=8123" >> env-example.cpu; \
echo "POSTGRES_HOST_PORT=5438" >> env-example.cpu; \
fi; \
cp env-example.cpu .env; \
echo "*** .env file created from env-example.cpu. Please review it. ***"; \
elif [ "$(TARGET)" = "gpu" ]; then \
if [ ! -f env-example.gpu ]; then \
echo "env-example.gpu not found. Creating default one."; \
echo "ADMIN_API_TOKEN=token" > env-example.gpu; \
echo "LANGUAGE_DETECTION_SEGMENTS=10" >> env-example.gpu; \
echo "VAD_FILTER_THRESHOLD=0.5" >> env-example.gpu; \
echo "WHISPER_MODEL_SIZE=medium" >> env-example.gpu; \
echo "DEVICE_TYPE=cuda" >> env-example.gpu; \
echo "BOT_IMAGE_NAME=vexa-bot:dev" >> env-example.gpu; \
echo "# Exposed Host Ports" >> env-example.gpu; \
echo "API_GATEWAY_HOST_PORT=8056" >> env-example.gpu; \
echo "ADMIN_API_HOST_PORT=8057" >> env-example.gpu; \
echo "TRAEFIK_WEB_HOST_PORT=9090" >> env-example.gpu; \
echo "TRAEFIK_DASHBOARD_HOST_PORT=8085" >> env-example.gpu; \
echo "TRANSCRIPTION_COLLECTOR_HOST_PORT=8123" >> env-example.gpu; \
echo "POSTGRES_HOST_PORT=5438" >> env-example.gpu; \
fi; \
cp env-example.gpu .env; \
echo "*** .env file created from env-example.gpu. Please review it. ***"; \
else \
echo "Error: TARGET must be 'cpu' or 'gpu'. Usage: make force-env TARGET=<cpu|gpu>"; \
exit 1; \
fi
# Download the Whisper model
download-model:
@echo "---> Creating ./hub directory if it doesn't exist..."
@mkdir -p ./hub
@echo "---> Ensuring ./hub directory is writable..."
@chmod u+w ./hub
@echo "---> Downloading Whisper model (this may take a while)..."
@python download_model.py
# Build the standalone vexa-bot image
# Uses BOT_IMAGE_NAME from .env if available, otherwise falls back to default
build-bot-image: check_docker
@if [ -f .env ]; then \
ENV_BOT_IMAGE_NAME=$$(grep BOT_IMAGE_NAME .env | cut -d= -f2); \
if [ -n "$$ENV_BOT_IMAGE_NAME" ]; then \
echo "---> Building $$ENV_BOT_IMAGE_NAME image (from .env)..."; \
docker build -t $$ENV_BOT_IMAGE_NAME -f services/vexa-bot/core/Dockerfile ./services/vexa-bot/core; \
else \
echo "---> Building $(BOT_IMAGE_NAME) image (BOT_IMAGE_NAME not found in .env)..."; \
docker build -t $(BOT_IMAGE_NAME) -f services/vexa-bot/core/Dockerfile ./services/vexa-bot/core; \
fi; \
else \
echo "---> Building $(BOT_IMAGE_NAME) image (.env file not found)..."; \
docker build -t $(BOT_IMAGE_NAME) -f services/vexa-bot/core/Dockerfile ./services/vexa-bot/core; \
fi
# Build Docker Compose service images
build: check_docker
@echo "---> Building Docker Compose services..."
@if [ "$(TARGET)" = "cpu" ]; then \
echo "---> Building with 'cpu' profile (includes whisperlive-cpu)..."; \
docker compose --profile cpu build; \
elif [ "$(TARGET)" = "gpu" ]; then \
echo "---> Building with 'gpu' profile (includes whisperlive GPU)..."; \
docker compose --profile gpu build; \
else \
echo "---> TARGET not explicitly set, defaulting to CPU mode. 'whisperlive' (GPU) will not be built."; \
docker compose --profile cpu build; \
fi
# Start services in detached mode
up: check_docker
@echo "---> Starting Docker Compose services..."
@if [ "$(TARGET)" = "cpu" ]; then \
echo "---> Activating 'cpu' profile to start whisperlive-cpu along with other services..."; \
docker compose --profile cpu up -d; \
elif [ "$(TARGET)" = "gpu" ]; then \
echo "---> Starting services for GPU. This will start 'whisperlive' (for GPU) and other default services. 'whisperlive-cpu' (profile=cpu) will not be started."; \
docker compose --profile gpu up -d; \
else \
echo "---> TARGET not explicitly set, defaulting to CPU mode. 'whisperlive' (GPU) will not be started."; \
docker compose --profile cpu up -d; \
fi
# Stop services
down: check_docker
@echo "---> Stopping Docker Compose services..."
@docker compose down
# Stop services and remove volumes
clean: check_docker
@echo "---> Stopping Docker Compose services and removing volumes..."
@docker compose down -v
# Show container status
ps: check_docker
@docker compose ps
# Tail logs for all services
logs:
@docker compose logs -f
# Run the interaction test script
test: check_docker
@echo "---> Running test script..."
@echo "---> API Documentation URLs:"
@if [ -f .env ]; then \
API_PORT=$$(grep -E '^[[:space:]]*API_GATEWAY_HOST_PORT=' .env | cut -d= -f2- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$$//'); \
ADMIN_PORT=$$(grep -E '^[[:space:]]*ADMIN_API_HOST_PORT=' .env | cut -d= -f2- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$$//'); \
[ -z "$$API_PORT" ] && API_PORT=8056; \
[ -z "$$ADMIN_PORT" ] && ADMIN_PORT=8057; \
echo " Main API: http://localhost:$$API_PORT/docs"; \
echo " Admin API: http://localhost:$$ADMIN_PORT/docs"; \
else \
echo " Main API: http://localhost:8056/docs"; \
echo " Admin API: http://localhost:8057/docs"; \
fi
@chmod +x run_vexa_interaction.sh
@./run_vexa_interaction.sh