ci: tag eynollah docker image with git tag version if possible, else latest

This commit is contained in:
kba 2026-04-29 16:28:09 +02:00
parent bb092364af
commit f58189d5f4
2 changed files with 10 additions and 4 deletions

View file

@ -35,7 +35,7 @@ jobs:
password: ${{ secrets.DOCKERIO_PASSWORD }}
- name: Build the Docker image
# build both tags at the same time
run: make docker DOCKER_TAG="docker.io/ocrd/eynollah -t ghcr.io/qurator-spk/eynollah"
run: make docker DOCKER_TAG="docker.io/ocrd/eynollah ghcr.io/qurator-spk/eynollah"
- name: Test the Docker image
run: docker run --rm ocrd/eynollah ocrd-eynollah-segment -h
- name: Push to Dockerhub

View file

@ -2,8 +2,7 @@ PYTHON ?= python3
PIP ?= pip3
EXTRAS ?=
# DOCKER_BASE_IMAGE = artefakt.dev.sbb.berlin:5000/sbb/ocrd_core:v2.68.0
DOCKER_BASE_IMAGE ?= docker.io/ocrd/core-cuda-tf2:latest
DOCKER_BASE_IMAGE ?= docker.io/ocrd/core-cuda-tf2:3.12.2
DOCKER_TAG ?= ocrd/eynollah
DOCKER ?= docker
WGET = wget -O
@ -120,12 +119,19 @@ coverage:
$(MAKE) test PYTHON="coverage run"
coverage report -m
# Concatenate docker image names with either the git tag describing current commit or 'latest' and
# merge list with "-t"
empty :=
space := $(empty) $(empty)
GIT_TAG := $(strip $(shell git describe --tags | grep -x "v[0-9]\+\.[0-9]\+\.[0-9]\+"))
DOCKER_TAGS = $(subst $(space),$(space)-t$(space),$(DOCKER_TAG:%=$(if $(GIT_TAG),%:$(GIT_TAG),%:latest)))
# Build docker image
docker:
$(DOCKER) build \
--build-arg DOCKER_BASE_IMAGE=$(DOCKER_BASE_IMAGE) \
--build-arg VCS_REF=$$(git rev-parse --short HEAD) \
--build-arg BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
-t $(DOCKER_TAG) .
-t $(DOCKER_TAGS) .
.PHONY: models build install install-dev test smoke-test ocrd-test coverage docker help