@@ -5,18 +5,24 @@ VENV_MIN := venv-min/bin
5
5
CONF := conf/glances.conf
6
6
PIP := $(VENV ) /pip
7
7
PYTHON := $(VENV ) /python
8
- UNITTEST := unittest
9
-
8
+ LASTTAG = $(shell git describe --tags --abbrev=0)
9
+
10
+ IMAGES_TYPES := full minimal dev
11
+ ALPINE_IMAGES := $(IMAGES_TYPES:%=docker-alpine-% )
12
+ UBUNTU_IMAGES := $(IMAGES_TYPES:%=docker-ubuntu-% )
13
+ DOCKER_IMAGES := $(ALPINE_IMAGES ) $(UBUNTU_IMAGES )
14
+ DOCKER_RUNTIMES := $(DOCKER_IMAGES:%=run-% )
15
+ UNIT_TESTS := test-core test-restful test-xmlrpc
10
16
DOCKER_BUILD := docker buildx build
11
17
DOCKER_RUN := docker run
12
- DOCKERFILE_UBUNTU := docker-files/ubuntu.Dockerfile
13
- DOCKERFILE_ALPINE := docker-files/alpine.Dockerfile
14
18
PODMAN_SOCK ?= /run/user/$(shell id -u) /podman/podman.sock
15
19
DOCKER_SOCK ?= /var/run/docker.sock
16
20
DOCKER_SOCKS := -v $(PODMAN_SOCK ) :$(PODMAN_SOCK ) :ro -v $(DOCKER_SOCK ) :$(DOCKER_SOCK ) :ro
17
21
DOCKER_OPTS := --rm -e TZ="${TZ}" -e GLANCES_OPT="" --pid host --network host
18
22
19
- LASTTAG = $(shell git describe --tags --abbrev=0)
23
+ define DOCKER_TAG
24
+ glances:local-$*
25
+ endef
20
26
21
27
# if the command is only `make`, the default tasks will be the printing of the help.
22
28
.DEFAULT_GOAL := help
@@ -86,24 +92,22 @@ venv-dev-upgrade: ## Upgrade Python 3 dev dependencies
86
92
# Tests
87
93
# ===================================================================
88
94
89
- test-core : # # Run core unit tests
90
- $(PYTHON ) $( UNITTEST ) -core.py
95
+ $( UNIT_TESTS ) : test-% : unittest- % .py
96
+ $(PYTHON ) $<
91
97
98
+ test-core : # # Run core unit tests
92
99
test-restful : # # Run Restful unit tests
93
- $(PYTHON ) $(UNITTEST ) -restful.py
94
-
95
100
test-xmlrpc : # # Run XMLRPC unit tests
96
- $(PYTHON ) $(UNITTEST ) -xmlrpc.py
97
101
98
- test : test-core test-restful test-xmlrpc # # Run unit tests
102
+ test : $( UNIT_TESTS ) # # Run unit tests
99
103
100
104
test-with-upgrade : venv-upgrade venv-dev-upgrade test # # Upgrade deps and run unit tests
101
105
102
106
test-min : # # Run core unit tests in minimal environment
103
- $(VENV_MIN ) /python $( UNITTEST ) -core.py
107
+ $(VENV_MIN ) /python unittest -core.py
104
108
105
109
test-min-with-upgrade : venv-min-upgrade # # Upgrade deps and run unit tests in minimal environment
106
- $(VENV_MIN ) /python $( UNITTEST ) -core.py
110
+ $(VENV_MIN ) /python unittest -core.py
107
111
108
112
# ===================================================================
109
113
# Linters, profilers and cyber security
@@ -219,29 +223,28 @@ snapcraft:
219
223
# Need Docker Buildx package (apt install docker-buildx on Ubuntu)
220
224
# ===================================================================
221
225
226
+ define DOCKERFILE
227
+ docker-files/$(word 1,$(subst -, ,$* ) ) .Dockerfile
228
+ endef
229
+
230
+ define TARGET
231
+ $(word 2,$(subst -, ,$* ) )
232
+ endef
233
+
234
+ $(DOCKER_IMAGES ) : docker-% :
235
+ $(DOCKER_BUILD ) --target $(TARGET ) -f $(DOCKERFILE ) -t $(DOCKER_TAG ) .
236
+
222
237
docker : docker-alpine docker-ubuntu # # Generate local docker images
223
238
224
- docker-alpine : docker-alpine-full docker-alpine-minimal docker-alpine-dev # # Generate local docker images (Alpine)
239
+ docker-alpine : $(ALPINE_IMAGES ) # # Generate local docker images (Alpine)
240
+ docker-ubuntu : $(UBUNTU_IMAGES ) # # Generate local docker images (Ubuntu)
225
241
226
242
docker-alpine-full : # # Generate local docker image (Alpine full)
227
- $(DOCKER_BUILD ) --target full -f $(DOCKERFILE_ALPINE ) -t glances:local-alpine-full .
228
-
229
243
docker-alpine-minimal : # # Generate local docker image (Alpine minimal)
230
- $(DOCKER_BUILD ) --target minimal -f $(DOCKERFILE_ALPINE ) -t glances:local-alpine-minimal .
231
-
232
244
docker-alpine-dev : # # Generate local docker image (Alpine dev)
233
- $(DOCKER_BUILD ) --target dev -f $(DOCKERFILE_ALPINE ) -t glances:local-alpine-dev .
234
-
235
- docker-ubuntu : docker-ubuntu-full docker-ubuntu-minimal docker-ubuntu-dev # # Generate local docker images (Ubuntu)
236
-
237
245
docker-ubuntu-full : # # Generate local docker image (Ubuntu full)
238
- $(DOCKER_BUILD ) --target full -f $(DOCKERFILE_UBUNTU ) -t glances:local-ubuntu-full .
239
-
240
246
docker-ubuntu-minimal : # # Generate local docker image (Ubuntu minimal)
241
- $(DOCKER_BUILD ) --target minimal -f $(DOCKERFILE_UBUNTU ) -t glances:local-ubuntu-minimal .
242
-
243
247
docker-ubuntu-dev : # # Generate local docker image (Ubuntu dev)
244
- $(DOCKER_BUILD ) --target dev -f $(DOCKERFILE_UBUNTU ) -t glances:local-ubuntu-dev .
245
248
246
249
# ===================================================================
247
250
# Run
@@ -268,23 +271,15 @@ run-min-debug: ## Start minimal Glances in debug console mode (also called stand
268
271
run-min-local-conf : # # Start minimal Glances in console mode with the system conf file
269
272
$(VENV_MIN ) /python -m glances
270
273
271
- run-docker-alpine-minimal : # # Start Glances Alpine Docker minimal in console mode
272
- $(DOCKER_RUN ) $(DOCKER_OPTS ) $(DOCKER_SOCKS ) -it glances:local-alpine-minimal
274
+ $( DOCKER_RUNTIMES ) : run-docker-% :
275
+ $(DOCKER_RUN ) $(DOCKER_OPTS ) $(DOCKER_SOCKS ) -it $( DOCKER_TAG )
273
276
277
+ run-docker-alpine-minimal : # # Start Glances Alpine Docker minimal in console mode
274
278
run-docker-alpine-full : # # Start Glances Alpine Docker full in console mode
275
- $(DOCKER_RUN ) $(DOCKER_OPTS ) $(DOCKER_SOCKS ) -it glances:local-alpine-full
276
-
277
279
run-docker-alpine-dev : # # Start Glances Alpine Docker dev in console mode
278
- $(DOCKER_RUN ) $(DOCKER_OPTS ) $(DOCKER_SOCKS ) -it glances:local-alpine-dev
279
-
280
280
run-docker-ubuntu-minimal : # # Start Glances Ubuntu Docker minimal in console mode
281
- $(DOCKER_RUN ) $(DOCKER_OPTS ) $(DOCKER_SOCKS ) -it glances:local-ubuntu-minimal
282
-
283
281
run-docker-ubuntu-full : # # Start Glances Ubuntu Docker full in console mode
284
- $(DOCKER_RUN ) $(DOCKER_OPTS ) $(DOCKER_SOCKS ) -it glances:local-ubuntu-full
285
-
286
282
run-docker-ubuntu-dev : # # Start Glances Ubuntu Docker dev in console mode
287
- $(DOCKER_RUN ) $(DOCKER_OPTS ) $(DOCKER_SOCKS ) -it glances:local-ubuntu-dev
288
283
289
284
run-webserver : # # Start Glances in Web server mode
290
285
$(PYTHON ) -m glances -C $(CONF ) -w
0 commit comments