1
0

Makefile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # sync with https://github.com/fphammerle/docker-onion-service/blob/master/Makefile
  2. IMAGE_NAME = docker.io/fphammerle/postfix
  3. PROJECT_VERSION = $(shell git describe --match=v* --abbrev=0 --dirty | sed -e 's/^v//')
  4. POSTFIX_PACKAGE_VERSION = $(shell grep -Po 'POSTFIX_PACKAGE_VERSION=\K.+' Dockerfile | tr -d -)
  5. ARCH = $(shell arch)
  6. # architecture[arm_variant]
  7. # https://github.com/opencontainers/image-spec/blob/v1.0.1/image-index.md#image-index-property-descriptions
  8. IMAGE_TAG_ARCH_aarch64 = arm64
  9. IMAGE_TAG_ARCH_armv6l = armv6
  10. IMAGE_TAG_ARCH_armv7l = armv7
  11. IMAGE_TAG_ARCH_x86_64 = amd64
  12. IMAGE_TAG_ARCH = ${IMAGE_TAG_ARCH_${ARCH}}
  13. MANIFEST_TAG = ${PROJECT_VERSION}-postfix${POSTFIX_PACKAGE_VERSION}
  14. IMAGE_TAG = ${MANIFEST_TAG}-${IMAGE_TAG_ARCH}
  15. BUILD_PARAMS = --tag="${IMAGE_NAME}:${IMAGE_TAG}" \
  16. --build-arg=REVISION="$(shell git rev-parse HEAD)"
  17. .PHONY: worktree-clean docker-build podman-build docker-push docker-manifest-create docker-manifest-push
  18. worktree-clean:
  19. git diff --exit-code
  20. git diff --staged --exit-code
  21. docker-build: worktree-clean
  22. sudo docker build ${BUILD_PARAMS} .
  23. podman-build: worktree-clean
  24. # --format=oci (default) not fully supported by hub.docker.com
  25. # https://github.com/docker/hub-feedback/issues/1871#issuecomment-748924149
  26. podman build --format=docker ${BUILD_PARAMS} .
  27. docker-push: docker-build
  28. sudo docker push "${IMAGE_NAME}:${IMAGE_TAG}"
  29. @echo git tag --sign --message '$(shell sudo docker image inspect --format '{{join .RepoDigests "\n"}}' "${IMAGE_NAME}:${IMAGE_TAG}")' docker/${IMAGE_TAG} $(shell git rev-parse HEAD)
  30. docker-manifest-push:
  31. git tag | grep '^docker/${MANIFEST_TAG}-' | xargs -L1 -t git tag -v \
  32. | grep @sha256: | xargs -t sudo docker manifest create "${IMAGE_NAME}:${MANIFEST_TAG}"
  33. sudo docker manifest push "${IMAGE_NAME}:${MANIFEST_TAG}"
  34. sudo docker manifest inspect "${IMAGE_NAME}:${MANIFEST_TAG}" | yq --yaml-output .