Skip to content

Commit a370109

Browse files
committed
Rules targetting docker-* are now built at runtime
* removed the macros `DOCKERFILE`, `TARGET`, & `DOCKER_TAG` * introduced the macro `MAKE_DOCKER_BUILD_RULES` * at runtime, `docker-*` are built from the `DISTROS` list: done using `eval` [1] * `make help` is unchanged: ``` $ make | grep '\sdocker-' make docker-alpine Generate local docker images (Alpine) make docker-alpine-dev Generate local docker image (Alpine dev) make docker-alpine-full Generate local docker image (Alpine full) make docker-alpine-minimal Generate local docker image (Alpine minimal) make docker-ubuntu Generate local docker images (Ubuntu) make docker-ubuntu-dev Generate local docker image (Ubuntu dev) make docker-ubuntu-full Generate local docker image (Ubuntu full) make docker-ubuntu-minimal Generate local docker image (Ubuntu minimal) $ make docker -n docker buildx build --target full -f docker-files/alpine.Dockerfile -t glances:local-alpine-full . docker buildx build --target minimal -f docker-files/alpine.Dockerfile -t glances:local-alpine-minimal . docker buildx build --target dev -f docker-files/alpine.Dockerfile -t glances:local-alpine-dev . docker buildx build --target full -f docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-full . docker buildx build --target minimal -f docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-minimal . docker buildx build --target dev -f docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-dev . ``` [1] https://www.gnu.org/software/make/manual/html_node/Eval-Function.html Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
1 parent ddfcf46 commit a370109

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

Makefile

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ DOCKER_SOCK ?= /var/run/docker.sock
2121
DOCKER_SOCKS := -v $(PODMAN_SOCK):$(PODMAN_SOCK):ro -v $(DOCKER_SOCK):$(DOCKER_SOCK):ro
2222
DOCKER_OPTS := --rm -e TZ="${TZ}" -e GLANCES_OPT="" --pid host --network host
2323

24-
define DOCKER_TAG
25-
glances:local-$*
26-
endef
27-
2824
# if the command is only `make`, the default tasks will be the printing of the help.
2925
.DEFAULT_GOAL := help
3026

@@ -224,16 +220,12 @@ snapcraft:
224220
# Need Docker Buildx package (apt install docker-buildx on Ubuntu)
225221
# ===================================================================
226222

227-
define DOCKERFILE
228-
docker-files/$(word 1,$(subst -, ,$*)).Dockerfile
229-
endef
230-
231-
define TARGET
232-
$(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)-$$* .
233226
endef
234227

235-
$(DOCKER_IMAGES): docker-%:
236-
$(DOCKER_BUILD) --target $(TARGET) -f $(DOCKERFILE) -t $(DOCKER_TAG) .
228+
$(foreach DISTRO,$(DISTROS),$(eval $(MAKE_DOCKER_BUILD_RULES)))
237229

238230
docker: docker-alpine docker-ubuntu ## Generate local docker images
239231

@@ -273,7 +265,7 @@ run-min-local-conf: ## Start minimal Glances in console mode with the system con
273265
$(VENV_MIN)/python -m glances
274266

275267
$(DOCKER_RUNTIMES): run-docker-%:
276-
$(DOCKER_RUN) $(DOCKER_OPTS) $(DOCKER_SOCKS) -it $(DOCKER_TAG)
268+
$(DOCKER_RUN) $(DOCKER_OPTS) $(DOCKER_SOCKS) -it glances:local-$*
277269

278270
run-docker-alpine-minimal: ## Start Glances Alpine Docker minimal in console mode
279271
run-docker-alpine-full: ## Start Glances Alpine Docker full in console mode

0 commit comments

Comments
 (0)