Browse Source

add labels org.opencontainers.image.{source,title,revision}

https://github.com/fphammerle/docker-onion-service/commit/aa124bde955047b2de6316ff72d6b1f76d14e3ba
https://github.com/fphammerle/docker-onion-service/commit/46ca6d70fb2d4570bfddac6b3f5e485183e72405
Fabian Peter Hammerle 2 years ago
parent
commit
01e49ae05e
2 changed files with 40 additions and 0 deletions
  1. 6 0
      Dockerfile
  2. 34 0
      Makefile

+ 6 - 0
Dockerfile

@@ -21,3 +21,9 @@ RUN apk add --no-cache ca-certificates curl \
 
 USER toit
 CMD ["toit", "--help"]
+
+# https://github.com/opencontainers/image-spec/blob/v1.0.1/annotations.md
+ARG REVISION=
+LABEL org.opencontainers.image.title="toit" \
+    org.opencontainers.image.source="https://git.hammerle.me/fphammerle/docker-toit" \
+    org.opencontainers.image.revision="$REVISION"

+ 34 - 0
Makefile

@@ -0,0 +1,34 @@
+# sync with https://github.com/fphammerle/docker-onion-service/blob/master/Makefile
+
+IMAGE_NAME := docker.io/fphammerle/toit
+PROJECT_VERSION = $(shell git describe --match=v* --abbrev=0 --dirty | sed -e 's/^v//')
+TOIT_PACKAGE_VERSION = $(shell grep -Po 'TOIT_VERSION=\K.+' Dockerfile | tr -d -)
+ARCH = $(shell arch)
+# architecture[arm_variant]
+# https://github.com/opencontainers/image-spec/blob/v1.0.1/image-index.md#image-index-property-descriptions
+IMAGE_TAG_ARCH_aarch64 = arm64
+IMAGE_TAG_ARCH_armv6l = armv6
+IMAGE_TAG_ARCH_armv7l = armv7
+IMAGE_TAG_ARCH_x86_64 = amd64
+IMAGE_TAG_ARCH = ${IMAGE_TAG_ARCH_${ARCH}}
+IMAGE_TAG = ${PROJECT_VERSION}-toit${TOIT_PACKAGE_VERSION}-${IMAGE_TAG_ARCH}
+BUILD_PARAMS = --tag="${IMAGE_NAME}:${IMAGE_TAG}" \
+	--build-arg=REVISION="$(shell git rev-parse HEAD)"
+
+.PHONY: worktree-clean docker-build podman-build docker-push
+
+worktree-clean:
+	git diff --exit-code
+	git diff --staged --exit-code
+
+docker-build: worktree-clean
+	sudo docker build ${BUILD_PARAMS} .
+
+podman-build: worktree-clean
+	# --format=oci (default) not fully supported by hub.docker.com
+	# https://github.com/docker/hub-feedback/issues/1871#issuecomment-748924149
+	podman build --format=docker ${BUILD_PARAMS} .
+
+docker-push: docker-build
+	sudo docker push "${IMAGE_NAME}:${IMAGE_TAG}"
+	@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)