Makefile 1.8 KB

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