-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
137 lines (110 loc) · 3.24 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
# Define variables
CARGO = cargo
DOCKER = docker
# Load environment variables from .env file
include .env
export $(shell sed 's/=.*//' .env)
# Default target
.PHONY: all
all: build
# Build the project
.PHONY: build
build:
$(CARGO) build
# Run the project
.PHONY: run
run:
$(CARGO) run
# Test the project
.PHONY: test
test:
$(CARGO) test
# Clean the project
.PHONY: clean
clean:
$(CARGO) clean
# Format the code
.PHONY: fmt
fmt:
$(CARGO) fmt
# Lint the code
.PHONY: clippy
clippy:
$(CARGO) clippy
# Generate documentation
.PHONY: doc
doc:
$(CARGO) doc --open
# Publish the crate to crates.io
.PHONY: publish
publish:
$(CARGO) publish
# Build the Docker image
.PHONY: docker-build
docker-build:
$(DOCKER) build -t strategy_execution_engine .
# Run the Docker container
.PHONY: docker-run
docker-run:
$(DOCKER) run --rm -it strategy_execution_engine
# Stop the Docker container
.PHONY: docker-stop
docker-stop:
$(DOCKER) stop strategy_execution_engine
# Push the Docker image to a registry (assuming you have logged in)
.PHONY: docker-push
docker-push:
$(DOCKER) push strategy_execution_engine
# Check the status of the project (build, test, clippy, fmt)
.PHONY: check
check: build test clippy fmt
# Start Kafka and dependencies using Docker Compose
.PHONY: kafka-up
kafka-up:
@echo "Starting Kafka with KAFKA_HOST=$(KAFKA_HOST)"
@KAFKA_HOST=$(KAFKA_HOST) docker-compose -f Docker/kafka.yml up -d
# Stop Kafka and dependencies using Docker Compose
.PHONY: kafka-down
kafka-down:
@KAFKA_HOST=$(KAFKA_HOST) docker-compose -f Docker/kafka.yml down
# Start Redis and dependencies using Docker Compose
.PHONY: redis-up
redis-up:
@echo "Starting Redis with REDISPASS=$(REDISPASS)"
@REDISPASS=$(REDISPASS) docker-compose -f Docker/redis.yml up -d
# Stop Redis and dependencies using Docker Compose
.PHONY: redis-down
redis-down:
@REDISPASS=$(REDISPASS) docker-compose -f Docker/redis.yml down
# Start NATS and dependencies using Docker Compose
.PHONY: nats-up
nats-up:
@docker-compose -f Docker/nats.yml up -d
# Stop NATS and dependencies using Docker Compose
.PHONY: nats-down
nats-down:
@docker-compose -f Docker/nats.yml down
# Start RabbitMQ and dependencies using Docker Compose
.PHONY: rabbitmq-up
rabbitmq-up-docker:
@echo $(RABBITMQ_ERLANG_COOKIE) > Docker/.erlang.cookie
@chmod 600 Docker/.erlang.cookie
@docker-compose -f Docker/rabbitmq.yml up -d
# Stop NATS and dependencies using Docker Compose
.PHONY: rabbitmq-down
rabbitmq-down:
@docker-compose -f Docker/rabbitmq.yml down -v
@rm -f Docker/.erlang.cookie
# Initialize the RabbitMQ cluster
rabbitmq-init-cluster:
@echo "Waiting for RabbitMQ containers to be ready..."
@sleep 30
docker exec -it rabbitmq1 bash -c "rabbitmqctl stop_app && rabbitmqctl reset && rabbitmqctl start_app"
docker exec -it rabbitmq2 bash -c "rabbitmqctl stop_app && rabbitmqctl reset && rabbitmqctl join_cluster rabbit@rabbitmq1 && rabbitmqctl start_app"
docker exec -it rabbitmq3 bash -c "rabbitmqctl stop_app && rabbitmqctl reset && rabbitmqctl join_cluster rabbit@rabbitmq1 && rabbitmqctl start_app"
# Check the status of the RabbitMQ cluster
rabbitmq-status:
docker exec -it rabbitmq1 rabbitmqctl cluster_status
# Start the RabbitMQ cluster
.PHONY: rabbitmq-up
rabbitmq-up: rabbitmq-up-docker rabbitmq-init-cluster rabbitmq-status