forked from weiiwang01/wpex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
131 lines (112 loc) Β· 3.64 KB
/
Copy pathMakefile
File metadata and controls
131 lines (112 loc) Β· 3.64 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
# Makefile per WPEX Docker
# Variabili
IMAGE_NAME := wpex
TAG := latest
FULL_IMAGE_NAME := $(IMAGE_NAME):$(TAG)
WPEX_VERSION := $(shell git describe --tags --always 2>/dev/null || echo "dev-$(shell date +%Y%m%d)")
.PHONY: help build run stop clean logs shell test health
# Help
help: ## Mostra questo help
@echo "π³ WPEX Docker Makefile"
@echo ""
@echo "Available targets:"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
# Build
build: ## Build dell'immagine Docker
@echo "ποΈ Building WPEX Docker image..."
@echo "π¦ Image: $(FULL_IMAGE_NAME)"
@echo "π·οΈ Version: $(WPEX_VERSION)"
docker build \
--build-arg WPEX_VERSION="$(WPEX_VERSION)" \
--tag "$(FULL_IMAGE_NAME)" \
.
@echo "β
Build completato!"
# Build multi-platform
build-multi: ## Build multi-platform (amd64, arm64)
docker buildx build \
--platform linux/amd64,linux/arm64 \
--build-arg WPEX_VERSION="$(WPEX_VERSION)" \
--tag "$(FULL_IMAGE_NAME)" \
--push \
.
# Run container
run: ## Avvia il container WPEX
docker run -d \
--name wpex-server \
-p 40000:40000/udp \
-p 8080:8080/tcp \
--restart unless-stopped \
$(FULL_IMAGE_NAME) \
--port 40000 \
--stats :8080 \
--broadcast-rate 3 \
--debug
@echo "π Container avviato!"
@echo "π Dashboard: http://localhost:8080"
# Run con Docker Compose
up: ## Avvia con Docker Compose
docker-compose up -d
@echo "π Stack avviato con Docker Compose!"
@echo "π Dashboard: http://localhost:8080"
# Stop container
stop: ## Ferma il container
docker stop wpex-server || true
docker rm wpex-server || true
# Stop Docker Compose
down: ## Ferma Docker Compose stack
docker-compose down -v
# Clean
clean: ## Rimuovi container e immagini
docker stop wpex-server || true
docker rm wpex-server || true
docker rmi $(FULL_IMAGE_NAME) || true
docker system prune -f
# Logs
logs: ## Mostra i log del container
docker logs -f wpex-server
# Logs con Docker Compose
logs-compose: ## Mostra i log con Docker Compose
docker-compose logs -f wpex
# Shell nel container
shell: ## Accesso shell al container
docker exec -it wpex-server /bin/sh
# Test dell'immagine
test: ## Test dell'immagine Docker
@echo "π§ͺ Testing Docker image..."
docker run --rm $(FULL_IMAGE_NAME) --version
@echo "β
Test completato!"
# Health check
health: ## Verifica health del container
@echo "π₯ Checking container health..."
@docker ps --filter name=wpex-server --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
@echo ""
@echo "π Testing endpoints:"
@curl -s http://localhost:8080/health || echo "β Health endpoint non raggiungibile"
@curl -s http://localhost:8080/stats > /dev/null && echo "β
Stats endpoint OK" || echo "β Stats endpoint non raggiungibile"
# Push to registry
push: build ## Build e push to registry
docker push $(FULL_IMAGE_NAME)
@echo "π€ Push completato!"
# Rebuild from scratch
rebuild: clean build ## Clean completo e rebuild
# Dev mode - build and run with debug
dev: build ## Build e run in modalitΓ development
$(MAKE) stop
docker run -d \
--name wpex-server \
-p 40000:40000/udp \
-p 8080:8080/tcp \
-v $(PWD)/logs:/var/log/wpex \
$(FULL_IMAGE_NAME) \
--port 40000 \
--stats :8080 \
--debug
@echo "π§ Dev container avviato con volume logs montato"
@echo "π Dashboard: http://localhost:8080"
# Show Docker info
info: ## Mostra informazioni Docker
@echo "π Docker Images:"
@docker images $(IMAGE_NAME) --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}\t{{.CreatedAt}}"
@echo ""
@echo "π Running Containers:"
@docker ps --filter ancestor=$(FULL_IMAGE_NAME) --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"