forked from nnsW3/client-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
145 lines (112 loc) · 5.34 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
# Makefile for managing Docker Compose deployment of a Node.js project
# Default target
.DEFAULT_GOAL := help
SERVICE ?= default_server
s ?= default_server
# Docker Compose configuration
COMPOSE_FILE := docker-compose.explore.yml
DOCKER_COMPOSE := docker-compose
NETWORK_NAME := orbiter-network
# Docker build configuration
METRICS_IMAGE:=orbiter/metrics:latest
BASE_IMAGE := orbiter/clients:latest
CRAWLER_IMAGE := orbiter/explore-data-crawler:latest
REFINERY_IMAGE := orbiter/explore-data-refinery:latest
DATASYNC_IMAGE := orbiter/data-synchronization:latest
MAKER_IMAGE := orbiter/maker-client:latest
# Configuration variables
NODE_CONTAINER_NAME := node-app
NODE_IMAGE_NAME := your-node-app-image
NODE_APP_PORT := 3000
REDIS_PASSWORD := $(shell openssl rand -hex 12)
# Create Docker network
create-network: ## Create a Docker network if it doesn't exist
@if ! docker network inspect $(NETWORK_NAME) > /dev/null 2>&1; then \
echo "Creating Docker network: $(NETWORK_NAME)"; \
docker network create $(NETWORK_NAME); \
else \
echo "Docker network $(NETWORK_NAME) already exists"; \
fi
# Build Docker images
bd-base: ## Build the Docker base image
docker build -f ./Dockerfile . -t $(BASE_IMAGE)
bd-maker-openapi: ## Build the Docker base image
cd ./apps/maker-openapi
docker build -f apps/maker-openapi/Dockerfile . -t orbiter/maker-openapi
bd-sdk-api: ## Build the Docker base image
cd ./apps/maker-openapi
docker build -f apps/openapi/Dockerfile . -t orbiter/sdk-api
bd-crawler: ## Build the Explore Data Crawler Docker image
docker build -f apps/explore-DataCrawler/Dockerfile.clients . -t $(CRAWLER_IMAGE)
bd-metrics: ## Build the Explore Data Crawler Docker image
docker build -f apps/metrics/Dockerfile . -t $(METRICS_IMAGE)
bd-data-synchronization: ## Build the data-synchronization Docker image
docker build -f apps/data-synchronization/Dockerfile.clients . -t $(DATASYNC_IMAGE)
bd-refinery: ## Build the Explore Data Refinery Docker image
docker build -f apps/explore-DataRefinery/Dockerfile.clients . -t $(REFINERY_IMAGE)
bd-explore: build-docker-crawler build-docker-refinery ## Build Explore Docker images
# Build success
bd-maker: ## Build the Maker Client Docker image
docker build -f apps/maker-client/Dockerfile.clients . -t $(MAKER_IMAGE)
bd-arbitration-client: ## Build the Maker Client Docker image
docker build -f apps/arbitration-client/Dockerfile.clients . -t $(MAKER_IMAGE)
bd-explore-openapi: ## Build the Open Api Docker image
docker build -f apps/explore-open-api/Dockerfile.clients . -t $(MAKER_IMAGE)
# Start Explore application
explore: create-network ## Start the Explore application
$(DOCKER_COMPOSE) -f $(COMPOSE_FILE) up -d
metrics: create-network ## Start the Explore application
$(DOCKER_COMPOSE) -f docker-compose.metrics.yml up -d
sdk-api: create-network ## Start the Explore application
$(DOCKER_COMPOSE) -f docker-compose.sdk-api.yml up -d
# Start Maker application
maker: create-network ## Start the Maker application
$(DOCKER_COMPOSE) -f docker-compose.maker.yml up -d
# Start OpenApi application
explore-openapi: create-network ## Start the OpenApi application
$(DOCKER_COMPOSE) -f docker-compose.explore-openapi.yml up -d
# Stop the Node.js application
stop: ## Stop the Node.js application
$(DOCKER_COMPOSE) -f docker-compose.$(s).yml stop
# Show all running containers
ps: ## Show all running containers
$(DOCKER_COMPOSE) -f docker-compose.$(s).yml ps
# Stop and remove Explore and its extra components containers
down: ## Stop Explore and all its extra components
$(DOCKER_COMPOSE) -f docker-compose.$(s).yml down
# Remove Explore and its extra components containers
rm: ## Remove Explore and all its extra components containers
$(DOCKER_COMPOSE) -f docker-compose.$(s).yml rm
# Show images of Explore and its extra components
images: ## Show images of Explore and all its extra components
$(DOCKER_COMPOSE) -f docker-compose.$(s).yml images
# Push Docker image to Docker registry
push: ## Push Docker image to the registry
docker push $(NODE_IMAGE_NAME)
# Clean all Docker containers and images
clean: ## Clear all Images Container
$(DOCKER_COMPOSE) -f $(COMPOSE_FILE) down --rmi all
# Prune Docker containers and volumes
prune: ## Remove Containers and Delete Volume Data
@make stop && make rm
@docker volume prune -f --filter label=com.docker.compose.project=orbiter-explore
# Show logs of Explore and its extra components
logs: ## Show all Images logs
$(DOCKER_COMPOSE) -f docker-compose.$(s).yml logs -f --tail 500
docker-makefile:
curl -o Makefile.docker -L https://raw.githubusercontent.com/kakui-lau/Makefile/main/makefile.docker
# Initialize Explore application configuration
init-explore:
@echo "Generating configuration with user input..."
@read -p "Enter Consul URL: " CONSUL_URL; \
echo "CONSUL_URL=$$CONSUL_URL" > .env
@echo "REDIS_PASSWORD=$(REDIS_PASSWORD)" >> .env
# Initialize Maker application configuration
init-maker:
@echo "Generating configuration with user input..."
@read -p "Enter Consul URL: " CONSUL_URL; \
echo "CONSUL_URL=$$CONSUL_URL" > .env
# Help target to display available targets
help: ## Show this help.
@echo "Make Application Docker Images and Containers using Docker-Compose files in 'docker' Dir."
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m (default: help)\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)