1
0

Makefile 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. # sync with https://github.com/fphammerle/docker-onion-service/blob/master/Makefile
  2. IMAGE_NAME = docker.io/fphammerle/sftpd
  3. PROJECT_VERSION = $(shell git describe --match=v* --abbrev=0 --dirty | sed -e 's/^v//')
  4. OPENSSH_SERVER_PACKAGE_VERSION := $(shell grep -Po 'OPENSSH_SERVER_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. IMAGE_TAG = ${PROJECT_VERSION}-openssh${OPENSSH_SERVER_PACKAGE_VERSION}-${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
  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}")' docker/${IMAGE_TAG} $(shell git rev-parse HEAD)