diff options
Diffstat (limited to '')
-rw-r--r-- | Makefile | 62 |
1 files changed, 25 insertions, 37 deletions
@@ -8,6 +8,9 @@ MAKEFLAGS += --warn-undefined-variables SHELL := bash .SHELLFLAGS := -eu -o pipefail -c +.PHONY: DO +DO: + PROJECT := math-server # Enable buildx support: export DOCKER_CLI_EXPERIMENTAL := enabled @@ -39,29 +42,26 @@ endif curl := curl --silent --show-error --location --dump-header - --connect-timeout 20 .PHONY: all -all: build +all: docker/build -.PHONY: DO -DO: - -.PHONY: login -login: +.PHONY: docker/login +docker/login: ifndef DOCKER_PASSWORD $(error Please define DOCKER_PASSWORD) endif @echo '$(call escape,$(DOCKER_PASSWORD))' | docker login --username '$(call escape,$(DOCKER_USERNAME))' --password-stdin -.PHONY: build -# Build natively by default. -build: compose/build +.PHONY: docker/build +# Build using Compose by default. +docker/build: compose/build -.PHONY: clean -clean: +.PHONY: docker/clean +docker/clean: docker system prune --all --force --volumes -.PHONY: push +.PHONY: docker/push # Push multi-arch images by default. -push: buildx/push +docker/push: buildx/push .PHONY: pull pull: @@ -79,44 +79,32 @@ client: down: docker-compose down --volumes -.PHONY: check-build -check-build: +# `docker build` has weak support for multiarch repos (you need to use multiple +# Dockerfile's, create a manifest manually, etc.). + +.PHONY: docker/check-build +docker/check-build: ifndef FORCE $(warning Going to build natively; consider `docker buildx build` instead) endif -.PHONY: check-push -check-push: +# `docker push` would replace the multiarch repo with a single image by default +# (you'd have to create a manifest and push it instead). + +.PHONY: docker/check-push +docker/check-push: ifndef FORCE $(error Please use `docker buildx build --push` instead) endif -# `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/%: DO check-build - docker build -f '$*/Dockerfile' -t '$(call escape,$(DOCKER_USERNAME))/math-$*' . - -.PHONY: docker/build -docker/build: docker/build/client docker/build/server - -# `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. -docker/push/%: DO check-push docker/build/% - docker push '$(call escape,$(DOCKER_USERNAME))/math-$*' - -.PHONY: docker/push -docker/push: check-push docker/push/client docker/push/server - .PHONY: compose/build # `docker-compose build` has the same problems as `docker build`. -compose/build: check-build +compose/build: docker/check-build docker-compose build .PHONY: compose/push # `docker-compose push` has the same problems as `docker push`. -compose/push: check-push compose/build +compose/push: docker/check-push compose/build docker-compose push # The simple way to build multiarch repos is `docker buildx`. |