@@ -8,9 +8,10 @@ PYTHON := $(VENV)/python
8
8
LASTTAG = $(shell git describe --tags --abbrev=0)
9
9
10
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 )
11
+ DISTROS := alpine ubuntu
12
+ alpine_images := $(IMAGES_TYPES:%=docker-alpine-% )
13
+ ubuntu_images := $(IMAGES_TYPES:%=docker-ubuntu-% )
14
+ DOCKER_IMAGES := $(alpine_images ) $(ubuntu_images )
14
15
DOCKER_RUNTIMES := $(DOCKER_IMAGES:%=run-% )
15
16
UNIT_TESTS := test-core test-restful test-xmlrpc
16
17
DOCKER_BUILD := docker buildx build
@@ -20,10 +21,6 @@ DOCKER_SOCK ?= /var/run/docker.sock
20
21
DOCKER_SOCKS := -v $(PODMAN_SOCK ) :$(PODMAN_SOCK ) :ro -v $(DOCKER_SOCK ) :$(DOCKER_SOCK ) :ro
21
22
DOCKER_OPTS := --rm -e TZ="${TZ}" -e GLANCES_OPT="" --pid host --network host
22
23
23
- define DOCKER_TAG
24
- glances:local-$*
25
- endef
26
-
27
24
# if the command is only `make`, the default tasks will be the printing of the help.
28
25
.DEFAULT_GOAL := help
29
26
@@ -223,21 +220,17 @@ snapcraft:
223
220
# Need Docker Buildx package (apt install docker-buildx on Ubuntu)
224
221
# ===================================================================
225
222
226
- define DOCKERFILE
227
- docker-files/$(word 1,$(subst -, ,$* ) ) .Dockerfile
228
- endef
229
-
230
- define TARGET
231
- $(word 2,$(subst -, ,$* ) )
223
+ define MAKE_DOCKER_BUILD_RULES
224
+ $($(DISTRO ) _images) : docker-$(DISTRO ) -%: docker-files/$(DISTRO ) .Dockerfile
225
+ $(DOCKER_BUILD ) --target $$* -f $$< -t glances:local-$(DISTRO ) -$$* .
232
226
endef
233
227
234
- $(DOCKER_IMAGES ) : docker-% :
235
- $(DOCKER_BUILD ) --target $(TARGET ) -f $(DOCKERFILE ) -t $(DOCKER_TAG ) .
228
+ $(foreach DISTRO,$(DISTROS),$(eval $(MAKE_DOCKER_BUILD_RULES)))
236
229
237
230
docker : docker-alpine docker-ubuntu # # Generate local docker images
238
231
239
- docker-alpine : $(ALPINE_IMAGES ) # # Generate local docker images (Alpine)
240
- docker-ubuntu : $(UBUNTU_IMAGES ) # # Generate local docker images (Ubuntu)
232
+ docker-alpine : $(alpine_images ) # # Generate local docker images (Alpine)
233
+ docker-ubuntu : $(ubuntu_images ) # # Generate local docker images (Ubuntu)
241
234
242
235
docker-alpine-full : # # Generate local docker image (Alpine full)
243
236
docker-alpine-minimal : # # Generate local docker image (Alpine minimal)
@@ -272,7 +265,7 @@ run-min-local-conf: ## Start minimal Glances in console mode with the system con
272
265
$(VENV_MIN ) /python -m glances
273
266
274
267
$(DOCKER_RUNTIMES ) : run-docker-% :
275
- $(DOCKER_RUN ) $(DOCKER_OPTS ) $(DOCKER_SOCKS ) -it $( DOCKER_TAG )
268
+ $(DOCKER_RUN ) $(DOCKER_OPTS ) $(DOCKER_SOCKS ) -it glances:local- $*
276
269
277
270
run-docker-alpine-minimal : # # Start Glances Alpine Docker minimal in console mode
278
271
run-docker-alpine-full : # # Start Glances Alpine Docker full in console mode
0 commit comments