Makefile 993 B

123456789101112131415161718192021
  1. DOCKER_IMAGE_NAME := docker.io/fphammerle/onion-service
  2. DOCKER_TAG_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. DOCKER_TAG_ARCH_SUFFIX_aarch64 := arm64
  6. DOCKER_TAG_ARCH_SUFFIX_armv6l := armv6
  7. DOCKER_TAG_ARCH_SUFFIX_x86_64 := amd64
  8. DOCKER_TAG_ARCH_SUFFIX = ${DOCKER_TAG_ARCH_SUFFIX_${ARCH}}
  9. DOCKER_TAG = ${DOCKER_TAG_VERSION}-tor${TOR_PACKAGE_VERSION}-${DOCKER_TAG_ARCH_SUFFIX}
  10. .PHONY: docker-build docker-push
  11. docker-build:
  12. git diff --exit-code
  13. git diff --staged --exit-code
  14. sudo docker build -t "${DOCKER_IMAGE_NAME}:${DOCKER_TAG}" .
  15. docker-push: docker-build
  16. sudo docker push "${DOCKER_IMAGE_NAME}:${DOCKER_TAG}"
  17. sleep 4 # wait for repo digest
  18. @echo git tag --sign --message '$(shell sudo docker image inspect --format '{{join .RepoDigests "\n"}}' "${DOCKER_IMAGE_NAME}:${DOCKER_TAG}")' docker/${DOCKER_TAG} $(shell git rev-parse HEAD)