aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Makefile
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-01-28 17:09:35 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-01-28 17:09:35 +0300
commitf8ccf5579ec2572ac9277b96bdf4e8679ce198b6 (patch)
tree5caee1f8895eebb409768ed96c738d5d97d73f3a /Makefile
parentprettier Makefile (diff)
downloadmath-server-f8ccf5579ec2572ac9277b96bdf4e8679ce198b6.tar.gz
math-server-f8ccf5579ec2572ac9277b96bdf4e8679ce198b6.zip
Makefile: restructure
Diffstat (limited to '')
-rw-r--r--Makefile118
1 files changed, 55 insertions, 63 deletions
diff --git a/Makefile b/Makefile
index 4d1cdb0..d6a433c 100644
--- a/Makefile
+++ b/Makefile
@@ -17,93 +17,85 @@ ifndef DOCKER_PASSWORD
endif
@echo "$(DOCKER_PASSWORD)" | docker login --username "$(DOCKER_USERNAME)" --password-stdin
-# Re-register binfmt_misc formats with the F flag (required i.e. on Bionic):
-fix-binfmt:
- docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
+# Build natively by default.
+build: compose/build
-binfmt: fix-binfmt
+clean:
+ docker system prune --all --force --volumes
-# `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 -f "$*/Dockerfile" -t "$(DOCKER_USERNAME)/math-$*" .
+# Push multi-arch images by default.
+push: buildx/push
-docker-build: docker-build/client docker-build/server
+pull:
+ docker-compose pull
-# `docker-compose build` has the same problems as `docker build`.
-compose-build:
-ifndef FORCE
- $(warning Consider using `docker buildx` instead)
-endif
- docker-compose build
+up:
+ docker-compose up -d server
-# The simple way to build multiarch repos.
-builder/create: fix-binfmt
- docker buildx create --use --name "$(PROJECT)_builder"
+client:
+ docker-compose --rm run client
-builder/rm:
- docker buildx rm "$(PROJECT)_builder"
+down:
+ docker-compose down --volumes
-buildx/%:
- docker buildx build -f "$*/Dockerfile" -t "$(DOCKER_USERNAME)/math-$*" --platform "$(platforms)" --progress plain .
+check-build:
+ifndef FORCE
+ $(warning Going to build natively; consider `docker buildx build` instead)
+endif
-buildx: buildx/client buildx/server
+check-push:
+ifndef FORCE
+ $(error Please use `docker buildx build --push` instead)
+endif
-# Build natively by default.
-build: compose-build
+# `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 -f "$*/Dockerfile" -t "$(DOCKER_USERNAME)/math-$*" .
+
+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.
-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)/math-$*"
-docker-push: check-docker-push docker-push/client docker-push/server
+docker/push: check-push docker/push/client docker/push/server
-# `docker-compose push` has the same problems as `docker push`.
-check-compose-push:
-ifndef FORCE
- $(error Please do not use `docker-compose push`)
-endif
+# `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 -f "$*/Dockerfile" -t "$(DOCKER_USERNAME)/math-$*" --platform "$(platforms)" --progress plain --push .
+# The simple way to build multiarch repos is `docker buildx`.
-buildx-push: buildx-push/client buildx-push/server
+# 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 server
+buildx/build/%:
+ docker buildx build -f "$*/Dockerfile" -t "$(DOCKER_USERNAME)/math-$*" --platform "$(platforms)" --progress plain .
-run/client:
- docker-compose --rm run client
+buildx/build: buildx/build/client buildx/build/server
-down:
- docker-compose down --volumes
+buildx/push/%:
+ docker buildx build -f "$*/Dockerfile" -t "$(DOCKER_USERNAME)/math-$*" --platform "$(platforms)" --progress plain --push .
-clean:
- docker system prune --all --force --volumes
+buildx/push: buildx/push/client buildx/push/server
-.PHONY: all login clean
-.PHONY: fix-binfmt binfmt builder/create builder/rm
-.PHONY: docker-build compose-build buildx build
-.PHONY: check-docker-push docker-push check-compose-push compose-push buildx-push push
-.PHONY: pull up run/client down
+.PHONY: all login build clean push pull up client down
+.PHONY: check-build check-push
+.PHONY: docker/build docker/push
+.PHONY: compose/build compose/push
+.PHONY: fix-binfmt buildx/create buildx/rm buildx/build buildx/push