-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (55 loc) · 2.19 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
#!/usr/bin/env bash
#############################################
# Metadata Service
#############################################
start-metadata:
go run metadata/cmd/main.go
.PHONY: start-metadata
#############################################
# Rating Service
#############################################
start-rating:
go run rating/cmd/main.go
.PHONY: start-rating
#############################################
# Movie Service
#############################################
start-movie:
go run movie/cmd/main.go
.PHONY: start-movie
#############################################
# Utilities
#############################################
start-all-services:
make -j start-metadata start-rating start-movie
.PHONY: start-all-services
start-consul:
@echo "Searching for Hashicorp/Consul image..."
@if docker container ls -a | grep -q "dev-consul"; then \
echo "Dev-consul container was found. Starting consul container."; \
docker container start dev-consul; \
elif docker image ls | grep -q "hashicorp/consul"; then \
echo "Hashicorp/consul image already downloaded. Starting consul container."; \
docker run -d -p 8500:8500 -p 8600:8600/udp --name=dev-consul hashicorp/consul agent -server -ui -node=server-1 -bootstrap-expect=1 -client=0.0.0.0; \
else \
echo "Hashicorp/Consul image isn't installed. Downloading hashicorp/consul:latest."; \
docker pull hashicorp/consul; \
docker run -d -p 8500:8500 -p 8600:8600/udp --name=dev-consul hashicorp/consul agent -server -ui -node=server-1 -bootstrap-expect=1 -client=0.0.0.0; \
fi
.PHONY: start-consul
stop-consul:
@echo "Checking if the dev-consul container is running..."
@CONSUL_CONTAINER=$$(docker container inspect dev-consul); \
if [ -n "$$CONSUL_CONTAINER" ]; then \
CONTAINER_STATUS=$$(echo "$$CONSUL_CONTAINER" | grep -o '"Status": "[^"]*' | awk -F'"' '{print $$4}'); \
CONSUL_CONTAINER_Status=$$CONTAINER_STATUS; \
if [ "$$CONSUL_CONTAINER_Status" = "running" ]; then \
echo "Stopping dev-consul container."; \
docker container stop dev-consul; \
else \
echo "Container dev-consul is not running."; \
fi; \
else \
echo "Container dev-consul does not exist or an error occurred while inspecting."; \
fi
.PHONY: stop-consul