Skip to content

Commit 2854820

Browse files
author
Robert Sachunsky
committed
Docker: shortcut ocrd-all-tool.json via ocrd-tool.json
1 parent 9262698 commit 2854820

File tree

4 files changed

+84
-59
lines changed

4 files changed

+84
-59
lines changed

.circleci/config.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/docker.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Docker Image CI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ "master", "fix-alpha-shape" ]
7+
8+
env:
9+
REPO_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
permissions:
17+
packages: write
18+
contents: read
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
# we need tags for docker version tagging
24+
fetch-tags: true
25+
fetch-depth: 0
26+
- # Activate cache export feature to reduce build time of images
27+
name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
- name: Login to GitHub Container Registry
30+
uses: docker/login-action@v2
31+
with:
32+
registry: ghcr.io
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
- name: Log in to Docker Hub
36+
uses: docker/login-action@v3
37+
with:
38+
username: ${{ secrets.DOCKERIO_USERNAME }}
39+
password: ${{ secrets.DOCKERIO_PASSWORD }}
40+
- name: define image name from repo name
41+
run: echo "IMAGE_NAME=ghcr.io/${REPO_NAME,,}" >> $GITHUB_ENV
42+
- name: Build the Docker image
43+
# build both tags at the same time
44+
run: make docker-build DOCKER_TAG="docker.io/ocrd/cis -t ${{ env.IMAGE_NAME }}"
45+
- name: Test the Docker image
46+
run: docker run --rm ${{ env.IMAGE_NAME }} ocrd-cis-ocropy-segment -h
47+
- name: Push to Dockerhub
48+
run: docker push docker.io/ocrd/cis
49+
- name: Push to Github Container Registry
50+
run: docker push ${{ env.IMAGE_NAME }}
51+

Dockerfile

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
FROM ocrd/core:v2.67.2 AS base
1+
ARG DOCKER_BASE_IMAGE
2+
FROM $DOCKER_BASE_IMAGE AS base
23
ARG VCS_REF
34
ARG BUILD_DATE
45
LABEL \
5-
maintainer="https://github.com/OCR-D/ocrd_cis/issues" \
6+
maintainer="https://github.com/cisocrgroup/ocrd_cis/issues" \
67
org.label-schema.vcs-ref=$VCS_REF \
7-
org.label-schema.vcs-url="https://github.com/OCR-D/ocrd_cis" \
8-
org.label-schema.build-date=$BUILD_DATE
8+
org.label-schema.vcs-url="https://github.com/cisocrgroup/ocrd_cis" \
9+
org.label-schema.build-date=$BUILD_DATE \
10+
org.opencontainers.image.vendor="DFG-Funded Initiative for Optical Character Recognition Development" \
11+
org.opencontainers.image.title="ocrd_cis" \
12+
org.opencontainers.image.description="Ocropy OCR and CIS post-correction bindings" \
13+
org.opencontainers.image.source="https://github.com/cisocrgroup/ocrd_cis" \
14+
org.opencontainers.image.documentation="https://github.com/cisocrgroup/ocrd_cis/blob/${VCS_REF}/README.md" \
15+
org.opencontainers.image.revision=$VCS_REF \
16+
org.opencontainers.image.created=$BUILD_DATE \
17+
org.opencontainers.image.base.name=ocrd/core
918

1019
ENV GITURL="https://github.com/cisocrgroup"
11-
ENV DOWNLOAD_URL="http://cis.lmu.de/~finkf"
1220

1321
SHELL ["/bin/bash", "-c"]
1422

@@ -51,19 +59,23 @@ RUN apt-get update \
5159

5260
FROM base AS postcorrection
5361
# install ocrd_cis (python)
54-
VOLUME ["/data"]
62+
WORKDIR /build/ocrd_cis
5563
COPY --from=languagemodel /etc/profiler/languages /etc/profiler/languages
5664
COPY --from=profiler /apps/profiler /apps/
5765
COPY --from=profiler /usr/lib/x86_64-linux-gnu/libicuuc.so /usr/lib//x86_64-linux-gnu/
5866
COPY --from=profiler /usr/lib/x86_64-linux-gnu/libicudata.so /usr/lib//x86_64-linux-gnu/
5967
COPY --from=profiler /usr/lib//x86_64-linux-gnu/libxerces-c-3.2.so /usr/lib//x86_64-linux-gnu/
60-
COPY . /build/ocrd_cis
68+
COPY . .
69+
# prepackage ocrd-tool.json as ocrd-all-tool.json
70+
RUN ocrd ocrd-tool ocrd_cis/ocrd-tool.json dump-tools > $(dirname $(ocrd bashlib filename))/ocrd-all-tool.json
71+
# install everything and reduce image size
6172
RUN apt-get update \
6273
&& apt-get -y install --no-install-recommends gcc wget default-jre-headless \
63-
&& pushd /build/ocrd_cis \
6474
&& make install \
6575
# test always fail, resources not available for download. Resources should be made available
6676
# somewhere else, e.g. github.com/OCR-D/assets
6777
# && make test \
68-
&& popd \
6978
&& rm -rf /build/ocrd_cis
79+
80+
WORKDIR /data
81+
VOLUME /data

Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,28 @@ PY ?= python3
22
PIP ?= pip3
33
V ?= > /dev/null 2>&1
44
PKG = ocrd_cis
5-
TAG = flobar/ocrd_cis
5+
DOCKER_TAG = ocrd/cis
6+
DOCKER_BASE_IMAGE = docker.io/ocrd/core:v3.1.0
67
SHELL = bash
78

89
install:
9-
${PIP} install --upgrade pip .
10-
install-devel:
11-
${PIP} install --upgrade pip -e .
10+
${PIP} install .
11+
12+
install-devel install-dev:
13+
${PIP} install -e .
14+
1215
uninstall:
1316
${PIP} uninstall ${PKG}
1417

1518
docker-build: Dockerfile
1619
docker build \
20+
--build-arg DOCKER_BASE_IMAGE=$(DOCKER_BASE_IMAGE) \
1721
--build-arg VCS_REF=$$(git rev-parse --short HEAD) \
1822
--build-arg BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
19-
-t $(TAG):latest .
23+
-t $(DOCKER_TAG):latest .
24+
2025
docker-push: docker-build
21-
docker push $(TAG):latest
26+
docker push $(DOCKER_TAG):latest
2227

2328
TEST_SCRIPTS=$(sort $(filter-out tests/run_training_test.bash, $(wildcard tests/run_*.bash)))
2429
INDENT != MAX=; for NAME in $(TEST_SCRIPTS:tests/%=%); do if test $${\#MAX} -lt $${\#NAME}; then MAX=$${NAME//?/_}; fi; done; echo $$MAX
@@ -43,4 +48,4 @@ test: $(TEST_SCRIPTS)
4348
@cat test_parallel.log
4449
@$(RM) test_serially.log test_parallel.log
4550

46-
.PHONY: install install-devel uninstall test docker-build docker-push
51+
.PHONY: install install-dev install-devel uninstall test docker-build docker-push

0 commit comments

Comments
 (0)