add GHA CD via Dockerhub

pull/70/head
Robert Sachunsky 2 months ago
parent 978f425bd1
commit 23e282ce8c

@ -0,0 +1,47 @@
name: Docker Image CD
on:
push:
branches: [ "master" ]
workflow_dispatch:
inputs:
docker-tagname:
description: Tag name of the Docker image
default: 'ocrd/sbb_binarization'
env:
DOCKER_TAGNAME: ${{ github.evenv.inputs.docker-tagname || 'ocrd/sbb_binarization' }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- # Activate cache export feature to reduce build time of image
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build the Docker image
run: make docker DOCKER_TAG=${{ env.DOCKER_TAGNAME }}
- name: Login to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Push image to Dockerhub
run: docker push ${{ env.DOCKER_TAGNAME }}
- name: Alias the Docker image for GHCR
run: docker tag ${{ env.DOCKER_TAGNAME }} ghcr.io/${{ github.repository }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image to Github Container Registry
run: docker push ghcr.io/${{ github.repository }}

@ -0,0 +1,22 @@
ARG DOCKER_BASE_IMAGE
FROM $DOCKER_BASE_IMAGE
ARG VCS_REF
ARG BUILD_DATE
LABEL \
maintainer="https://ocr-d.de/kontakt" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/qurator-spk/sbb_binarization" \
org.label-schema.build-date=$BUILD_DATE
WORKDIR /build/sbb_binarization
COPY setup.py .
COPY ocrd-tool.json .
COPY sbb_binarize ./sbb_binarize
COPY requirements.txt .
COPY README.md .
COPY Makefile .
RUN make install
RUN rm -rf /build/sbb_binarization
WORKDIR /data
VOLUME ["/data"]

@ -1,5 +1,8 @@
# BEGIN-EVAL makefile-parser --make-help Makefile # BEGIN-EVAL makefile-parser --make-help Makefile
DOCKER_BASE_IMAGE = docker.io/ocrd/core:v2.69.0
DOCKER_TAG = ocrd/nmalign
.PHONY: help install .PHONY: help install
help: help:
@echo "" @echo ""
@ -10,8 +13,12 @@ help:
@echo " test Run tests" @echo " test Run tests"
@echo " clean Remove copies/results in test/assets" @echo " clean Remove copies/results in test/assets"
@echo "" @echo ""
@echo " docker Build a Docker image $(DOCKER_TAG) from $(DOCKER_BASE_IMAGE)"
@echo ""
@echo " Variables" @echo " Variables"
@echo "" @echo ""
@echo " PYTHON"
@echo " DOCKER_TAG Docker image tag of result for the docker target"
# END-EVAL # END-EVAL
@ -40,6 +47,15 @@ test: test/assets models
ocrd-sbb-binarize -m test/assets/kant_aufklaerung_1784-page-region/data/mets.xml -g phys_0001 -I OCR-D-GT-SEG-REGION -O BIN -P model default -P operation_level region ocrd-sbb-binarize -m test/assets/kant_aufklaerung_1784-page-region/data/mets.xml -g phys_0001 -I OCR-D-GT-SEG-REGION -O BIN -P model default -P operation_level region
ocrd-sbb-binarize -m test/assets/kant_aufklaerung_1784-page-region/data/mets.xml -g phys_0001 -I OCR-D-GT-SEG-REGION -O BIN2 -P model default-2021-03-09 -P operation_level region ocrd-sbb-binarize -m test/assets/kant_aufklaerung_1784-page-region/data/mets.xml -g phys_0001 -I OCR-D-GT-SEG-REGION -O BIN2 -P model default-2021-03-09 -P operation_level region
.PHONY: docker
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) .
.PHONY: clean .PHONY: clean
clean: clean:
-$(RM) -fr test/assets -$(RM) -fr test/assets

@ -3,7 +3,8 @@
> Document Image Binarization > Document Image Binarization
[![pip release](https://img.shields.io/pypi/v/sbb-binarization.svg)](https://pypi.org/project/sbb-binarization/) [![pip release](https://img.shields.io/pypi/v/sbb-binarization.svg)](https://pypi.org/project/sbb-binarization/)
[![GHActions Tests](https://github.com/qurator-spk/sbb_binarization/actions/workflows/test.yml/badge.svg)](https://github.com/qurator-spk/sbb_binarization/actions/workflows/test.yml) [![GHActions CI](https://github.com/qurator-spk/sbb_binarization/actions/workflows/test.yml/badge.svg)](https://github.com/qurator-spk/sbb_binarization/actions/workflows/test.yml)
[![GHActions CD](https://github.com/qurator-spk/sbb_binarization/actions/workflows/docker-image.yml/badge.svg)](https://github.com/qurator-spk/sbb_binarization/actions/workflows/docker-image.yml)
<img src="https://user-images.githubusercontent.com/952378/63592437-e433e400-c5b1-11e9-9c2d-889c6e93d748.jpg" width="180"><img src="https://user-images.githubusercontent.com/952378/63592435-e433e400-c5b1-11e9-88e4-3e441b61fa67.jpg" width="180"><img src="https://user-images.githubusercontent.com/952378/63592440-e4cc7a80-c5b1-11e9-8964-2cd1b22c87be.jpg" width="220"><img src="https://user-images.githubusercontent.com/952378/63592438-e4cc7a80-c5b1-11e9-86dc-a9e9f8555422.jpg" width="220"> <img src="https://user-images.githubusercontent.com/952378/63592437-e433e400-c5b1-11e9-9c2d-889c6e93d748.jpg" width="180"><img src="https://user-images.githubusercontent.com/952378/63592435-e433e400-c5b1-11e9-88e4-3e441b61fa67.jpg" width="180"><img src="https://user-images.githubusercontent.com/952378/63592440-e4cc7a80-c5b1-11e9-8964-2cd1b22c87be.jpg" width="220"><img src="https://user-images.githubusercontent.com/952378/63592438-e4cc7a80-c5b1-11e9-86dc-a9e9f8555422.jpg" width="220">
@ -13,16 +14,19 @@ Python `3.7-3.10` with Tensorflow `<=2.11.1` are currently supported. While newe
You can either install from PyPI via You can either install from PyPI via
```
pip install sbb-binarization pip install sbb-binarization
```
or clone the repository, enter it and install (editable) with or clone the repository, enter it and install (editable) with
```
git clone git@github.com:qurator-spk/sbb_binarization.git git clone git@github.com:qurator-spk/sbb_binarization.git
cd sbb_binarization; pip install -e . cd sbb_binarization; pip install -e .
```
Alternatively, download the prebuilt image from Dockerhub:
docker pull ocrd/sbb_binarization
### Models ### Models

Loading…
Cancel
Save