-
-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathMakefile.docker
More file actions
147 lines (123 loc) · 4.77 KB
/
Copy pathMakefile.docker
File metadata and controls
147 lines (123 loc) · 4.77 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
# ServiceRadar Docker Makefile
# Usage: make -f Makefile.docker <target>
.PHONY: help build up down logs clean rebuild status shell db-shell docker-login docker-build docker-push
# Default target
help:
@echo "ServiceRadar Docker Commands:"
@echo " make -f Makefile.docker start - 🚀 One command: generate certs, build, start (RECOMMENDED)"
@echo " make -f Makefile.docker up - Start core service"
@echo " make -f Makefile.docker up-full - Start all services (includes NATS, Redpanda)"
@echo " make -f Makefile.docker down - Stop services"
@echo " make -f Makefile.docker logs - View logs"
@echo " make -f Makefile.docker clean - Remove containers and volumes"
@echo " make -f Makefile.docker rebuild - Rebuild and restart services"
@echo " make -f Makefile.docker status - Show service status"
@echo " make -f Makefile.docker shell - Shell into core container"
@echo " make -f Makefile.docker db-shell - Shell into CNPG database"
@echo ""
@echo "Manual commands:"
@echo " make -f Makefile.docker certs - Generate mTLS certificates manually"
@echo " make -f Makefile.docker build - Build Docker images"
@echo ""
@echo "Image building and pushing:"
@echo " make -f Makefile.docker docker-login - Login to Harbor"
@echo " make -f Makefile.docker docker-build - Build images locally"
@echo " make -f Makefile.docker docker-push - Build and push images to Harbor"
# Generate mTLS certificates
certs:
@echo "Generating mTLS certificates..."
@chmod +x docker/compose/generate-certs.sh
@./docker/compose/generate-certs.sh
@echo "Certificates generated successfully"
# Build Docker images (certificates generated automatically)
build:
docker-compose build --no-cache
# Start everything (one command - certificates, build, start)
start:
docker-compose up -d
# Start core service
up:
docker-compose up -d core
@echo "Waiting for services to be healthy..."
@sleep 5
@make -f Makefile.docker status
# Start all services including optional ones
up-full:
docker-compose --profile full up -d
@echo "Waiting for services to be healthy..."
@sleep 5
@make -f Makefile.docker status
# Stop all services
down:
docker-compose down
# View logs
logs:
docker-compose logs -f
# View logs for specific service
logs-core:
docker-compose logs -f core
# Clean up everything (containers, volumes, networks)
clean:
docker-compose down -v --remove-orphans
@echo "Cleaned up all containers, volumes, and networks"
# Rebuild and restart
rebuild: down build up
# Show service status
status:
@echo "=== ServiceRadar Docker Status ==="
@docker-compose ps
@echo ""
@echo "=== Service Health ==="
@docker-compose ps | grep -E "(healthy|unhealthy|starting)" || echo "Services starting..."
@echo ""
@echo "=== Network Info ==="
@docker network ls | grep serviceradar || echo "No ServiceRadar network found"
@echo ""
@echo "=== Volumes ==="
@docker volume ls | grep serviceradar || echo "No ServiceRadar volumes found"
# Shell into core container
shell:
docker-compose exec core /bin/bash
# Initialize database tables
db-init:
docker-compose exec core serviceradar-core init-db --config /etc/serviceradar/core.json
# Export configuration template
config-template:
@echo "Generating configuration template..."
@mkdir -p configs/docker
@docker-compose run --rm core serviceradar-core config-template > configs/docker/core-template.json
@echo "Configuration template saved to configs/docker/core-template.json"
# Development mode with live reload (requires source mount)
dev:
CONFIG_SOURCE=file docker-compose up -d
docker-compose logs -f core
# Production build with specific version
prod-build:
@read -p "Enter version (e.g., 1.0.0): " version; \
VERSION=$$version BUILD_ID=$$(date +%Y%m%d%H%M%S) docker-compose build --no-cache
# Test connectivity
test:
@echo "Testing Core API..."
@curl -sf http://localhost:8090/health && echo "✓ Core API is healthy" || echo "✗ Core API is not responding"
@echo ""
@echo "Testing gRPC..."
@nc -zv localhost 50051 2>&1 | grep -q succeeded && echo "✓ gRPC port is open" || echo "✗ gRPC port is not accessible"
@echo ""
@echo "Testing Metrics..."
@curl -sf http://localhost:9090/metrics > /dev/null && echo "✓ Metrics endpoint is working" || echo "✗ Metrics endpoint is not responding"
# Login to Harbor
docker-login:
@./scripts/docker-login.sh
# Build Docker images locally (without pushing)
docker-build:
@./scripts/build-images.sh --local --tag local
# Build and push Docker images to Harbor
docker-push:
@read -p "Enter tag (default: latest): " tag; \
tag=$${tag:-latest}; \
./scripts/build-images.sh --push --tag $$tag
# Build specific image
docker-build-core:
@./scripts/build-images.sh --local --tag local core
docker-build-cert-gen:
@./scripts/build-images.sh --local --tag local cert-generator