Skip to content

Commit d7c30b5

Browse files
authored
Merge pull request #119 from OCR-D/dockerfile
Fix dockerfile
2 parents d9cde1f + 37df6d8 commit d7c30b5

File tree

4 files changed

+89
-14
lines changed

4 files changed

+89
-14
lines changed

.github/workflows/docker.yml

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

Dockerfile

+24-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
1-
FROM ocrd/core
2-
MAINTAINER OCR-D
1+
ARG DOCKER_BASE_IMAGE
2+
FROM $DOCKER_BASE_IMAGE
3+
ARG VCS_REF
4+
ARG BUILD_DATE
5+
LABEL \
6+
maintainer="https://ocr-d.de/kontakt" \
7+
org.label-schema.vcs-ref=$VCS_REF \
8+
org.label-schema.vcs-url="https://github.com/OCR-D/ocrd_calamari" \
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_calamari" \
12+
org.opencontainers.image.description="OCR-D compliant workspace processor for the functionality of Calamari OCR" \
13+
org.opencontainers.image.source="https://github.com/OCR-D/ocrd_calamari" \
14+
org.opencontainers.image.documentation="https://github.com/OCR-D/ocrd_calamari/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=$DOCKER_BASE_IMAGE
318
ENV DEBIAN_FRONTEND noninteractive
419
ENV PYTHONIOENCODING utf8
520
ENV LC_ALL C.UTF-8
621
ENV LANG C.UTF-8
722

8-
WORKDIR /build
23+
WORKDIR /build/calamari
924
COPY Makefile .
10-
COPY setup.py .
25+
COPY pyproject.toml .
1126
COPY ocrd-tool.json .
1227
COPY requirements.txt .
1328
COPY README.md .
14-
COPY ocrd_calamari ocrd_calamari
29+
COPY ocrd_calamari ./ocrd_calamari
30+
RUN make install
31+
RUN rm -rf /build/calamari
1532

16-
RUN pip3 install --upgrade pip && \
17-
pip3 install . && \
18-
pip3 check
1933

20-
ENTRYPOINT ["/usr/local/bin/ocrd-calamari-recognize"]
34+
WORKDIR /data
35+
VOLUME ["/data"]

Makefile

+18-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ EXAMPLE = actevedef_718448162.first-page+binarization+segmentation
88

99
# BEGIN-EVAL makefile-parser --make-help Makefile
1010

11+
DOCKER_BASE_IMAGE = docker.io/ocrd/core-cuda-tf2:v2.70.0
12+
DOCKER_TAG = 'ocrd/calamari'
13+
1114
help:
1215
@echo ""
1316
@echo " Targets"
@@ -21,13 +24,16 @@ help:
2124
@echo " assets-clean Remove symlinks in test/assets"
2225
@echo " test Run unit tests"
2326
@echo " coverage Run unit tests and determine test coverage"
27+
@echo " docker Build Docker image"
2428
@echo ""
2529
@echo " Variables"
2630
@echo ""
27-
@echo " PYTHON '$(PYTHON)'"
28-
@echo " PIP_INSTALL '$(PIP_INSTALL)'"
29-
@echo " GIT_CLONE '$(GIT_CLONE)'"
30-
@echo " MODEL '$(MODEL)'"
31+
@echo " PYTHON '$(PYTHON)'"
32+
@echo " PIP_INSTALL '$(PIP_INSTALL)'"
33+
@echo " GIT_CLONE '$(GIT_CLONE)'"
34+
@echo " MODEL '$(MODEL)'"
35+
@echo " DOCKER_TAG '$(DOCKER_TAG)'"
36+
@echo " DOCKER_BASE_IMAGE '$(DOCKER_BASE_IMAGE)'"
3137

3238
# END-EVAL
3339

@@ -91,4 +97,11 @@ coverage: test/assets $(MODEL)
9197
coverage report
9298
coverage html
9399

94-
.PHONY: install assets-clean deps-test test coverage $(MODEL) example
100+
docker:
101+
docker build \
102+
--build-arg DOCKER_BASE_IMAGE=$(DOCKER_BASE_IMAGE) \
103+
--build-arg VCS_REF=$$(git rev-parse --short HEAD) \
104+
--build-arg BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
105+
-t $(DOCKER_TAG) .
106+
107+
.PHONY: install assets-clean deps-test test coverage $(MODEL) example docker

pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ Repository = "https://github.com/OCR-D/ocrd_calamari.git"
4040
dependencies = {file = ["requirements.txt"]}
4141
optional-dependencies.dev = {file = ["requirements-dev.txt"]}
4242

43+
[tool.setuptools.package-data]
44+
"*" = ["*.json"]
45+
4346
[tool.setuptools.packages.find]
4447
where = ["."]
4548
include = ["ocrd_calamari"]

0 commit comments

Comments
 (0)