From b76e9ee5bc229d6a92ee85cb6d7731d48634845c Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 28 Jan 2020 16:30:52 +0300 Subject: Makefile: refactoring --- Makefile | 118 ++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 56 insertions(+), 62 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 2a1e3a2..9e1838d 100644 --- a/Makefile +++ b/Makefile @@ -23,93 +23,87 @@ ifndef DOCKER_PASSWORD endif @echo "$(DOCKER_PASSWORD)" | docker login --username "$(DOCKER_USERNAME)" --password-stdin -# Quickly install a newer Compose version: -install-compose: - curl -L "https://github.com/docker/compose/releases/download/$(compose_version)/docker-compose-$$(uname -s)-$$(uname -m)" -o /usr/local/bin/docker-compose - chmod +x /usr/local/bin/docker-compose +# Build natively by default. +build: compose/build -compose: install-compose +clean: + docker system prune --all --force --volumes -# Re-register binfmt_misc formats with the F flag (required i.e. on Bionic): -fix-binfmt: - docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d +# Push multi-arch images by default. +push: buildx/push -binfmt: fix-binfmt +pull: + docker-compose pull -# `docker build` has week support for multiarch repos (you need to use multiple -# Dockerfile's, create a manifest manually, etc.), so it's only here for -# testing purposes, and native builds. -docker-build/%: -ifndef FORCE - $(warning Consider using `docker buildx` instead) -endif - docker build -t "$(DOCKER_USERNAME)/$*" "$*/" +up: + docker-compose up -d -docker-build: docker-build/dump1090 docker-build/fr24feed +down: + docker-compose down --volumes -# `docker-compose build` has the same problems as `docker build`. -compose-build: +check-build: ifndef FORCE - $(warning Consider using `docker buildx` instead) + $(warning Going to build natively; consider `docker buildx build` instead) endif - docker-compose build - -# The simple way to build multiarch repos. -builder/create: fix-binfmt - docker buildx create --use --name "$(PROJECT)_builder" -builder/rm: - docker buildx rm "$(PROJECT)_builder" - -buildx/%: - docker buildx build -t "$(DOCKER_USERNAME)/$*" --platform "$(platforms)" "$*/" +check-push: +ifndef FORCE + $(error Please use `docker buildx build --push` instead) +endif -buildx: buildx/dump1090 buildx/fr24feed +# `docker build` has week support for multiarch repos (you need to use multiple +# Dockerfile's, create a manifest manually, etc.), so it's only here for +# testing purposes, and native builds. +docker/build/%: check-build + docker build -t "$(DOCKER_USERNAME)/$*" "$*/" -# Build natively by default. -build: compose-build +docker/build: docker/build/dump1090 docker/build/fr24feed # `docker push` would replace the multiarch repo with a single image by default # (you'd have to create a manifest and push it instead), so it's only here for # testing purposes. -check-docker-push: -ifndef FORCE - $(error Please do not use `docker push`) -endif - -docker-push/%: check-docker-push docker-build/% +docker/push/%: check-push docker/build/% docker push "$(DOCKER_USERNAME)/$*" -docker-push: check-docker-push docker-push/dump1090 docker-push/fr24feed +docker/push: check-push docker/push/dump1090 docker/push/fr24feed -# `docker-compose push` has the same problems as `docker push`. -check-compose-push: -ifndef FORCE - $(error Please do not use `docker-compose push`) -endif +# Quickly install a newer Compose version: +compose/install: + curl -L "https://github.com/docker/compose/releases/download/$(compose_version)/docker-compose-$$(uname -s)-$$(uname -m)" -o /usr/local/bin/docker-compose + chmod +x /usr/local/bin/docker-compose + +# `docker-compose build` has the same problems as `docker build`. +compose/build: check-build + docker-compose build -compose-push: check-compose-push compose-build +# `docker-compose push` has the same problems as `docker push`. +compose/push: check-push compose/build docker-compose push -# The simple way to push multiarch repos. -buildx-push/%: - docker buildx build -t "$(DOCKER_USERNAME)/$*" --platform "$(platforms)" --push "$*/" +# The simple way to build multiarch repos is `docker buildx`. -buildx-push: buildx-push/dump1090 buildx-push/fr24feed +# Re-register binfmt_misc formats with the F flag (required i.e. on Bionic): +fix-binfmt: + docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d -# buildx is used by default. -push: buildx-push +buildx/create: fix-binfmt + docker buildx create --use --name "$(PROJECT)_builder" -pull: - docker-compose pull +buildx/rm: + docker buildx rm "$(PROJECT)_builder" -up: - docker-compose up -d +buildx/build/%: + docker buildx build -t "$(DOCKER_USERNAME)/$*" --platform "$(platforms)" "$*/" -down: - docker-compose down --volumes +buildx/build: buildx/build/dump1090 buildx/build/fr24feed -clean: - docker system prune --all --force --volumes +buildx/push/%: + docker buildx build -t "$(DOCKER_USERNAME)/$*" --platform "$(platforms)" --push "$*/" + +buildx/push: buildx/push/dump1090 buildx/push/fr24feed -.PHONY: all login install-compose compose fix-binfmt binfmt docker-build compose-build builder/create builder/rm buildx build check-docker-push docker-push check-compose-push compose-push buildx-push push pull up down clean +.PHONY: all login build clean push pull up down +.PHONY: check-build check-push +.PHONY: docker/build docker/push +.PHONY: compose/install compose/build compose/push +.PHONY: fix-binfmt buildx/create buildx/rm buildx/build buildx/push -- cgit v1.2.3