Browse Source

added makefile to support image building, pushing & tagging

https://github.com/fphammerle/docker-tor-proxy/commit/fea43b11d801de70d8fbbb3f11ff7b746942e55c
https://github.com/fphammerle/docker-tor-proxy/commit/ba4cafac279735c9a2586e05f3eb5dec27845e6f
Fabian Peter Hammerle 1 week ago
parent
commit
df7c828062
1 changed files with 21 additions and 0 deletions
  1. 21 0
      Makefile

+ 21 - 0
Makefile

@@ -0,0 +1,21 @@
+DOCKER_IMAGE_NAME := docker.io/fphammerle/onion-service
+DOCKER_TAG_VERSION := $(shell git describe --match=v* --abbrev=0 --dirty | sed -e 's/^v//')
+TOR_PACKAGE_VERSION := $(shell grep -Po 'TOR_PACKAGE_VERSION=\K.+' Dockerfile | tr -d -)
+ARCH := $(shell arch)
+DOCKER_TAG_ARCH_SUFFIX_aarch64 := arm64
+DOCKER_TAG_ARCH_SUFFIX_armv6l := armv6
+DOCKER_TAG_ARCH_SUFFIX_x86_64 := amd64
+DOCKER_TAG_ARCH_SUFFIX = ${DOCKER_TAG_ARCH_SUFFIX_${ARCH}}
+DOCKER_TAG = ${DOCKER_TAG_VERSION}-tor${TOR_PACKAGE_VERSION}-${DOCKER_TAG_ARCH_SUFFIX}
+
+.PHONY: docker-build docker-push
+
+docker-build:
+	git diff --exit-code
+	git diff --staged --exit-code
+	sudo docker build -t "${DOCKER_IMAGE_NAME}:${DOCKER_TAG}" .
+
+docker-push: docker-build
+	sudo docker push "${DOCKER_IMAGE_NAME}:${DOCKER_TAG}"
+	sleep 4 # wait for repo digest
+	@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)