aboutsummaryrefslogtreecommitdiffstatshomepage
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
parentprettier Makefile (diff)
downloadmath-server-f8ccf5579ec2572ac9277b96bdf4e8679ce198b6.tar.gz
math-server-f8ccf5579ec2572ac9277b96bdf4e8679ce198b6.zip
Makefile: restructure
-rw-r--r--.travis.yml8
-rw-r--r--Makefile118
2 files changed, 59 insertions, 67 deletions
diff --git a/.travis.yml b/.travis.yml
index 865c95f..940a158 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -70,11 +70,11 @@ jobs:
name: 'Docker: build native images'
language: shell
services: [docker]
- script: make docker-build
+ script: make docker/build
- <<: *docker
name: 'Docker: build native images using Compose'
- script: make compose-build
+ script: make compose/build
- &buildx
<<: *clear
@@ -95,9 +95,9 @@ jobs:
# https://github.com/moby/buildkit/issues/606
- echo '{}' | sudo tee /etc/docker/daemon.json
- sudo systemctl restart docker
- script: make builder/create && make buildx
+ script: make buildx/create && make buildx/build
- <<: *buildx
name: 'Docker: build & publish multi-arch images'
if: branch = master
- script: make login && make builder/create && make push
+ script: make login && make buildx/create && make buildx/push
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