From 253291d62397b086a718e18ddcd38dd9f0ae03d6 Mon Sep 17 00:00:00 2001 From: joschrew Date: Wed, 31 Jan 2024 15:27:06 +0100 Subject: [PATCH 1/3] Add Dockerfile --- Dockerfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0557a05 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM ocrd/core:v2.62.0 AS base + +WORKDIR /build-ocrd_segment +COPY setup.py . +COPY ocrd_segment/ocrd-tool.json . +COPY ocrd_segment ./ocrd_segment +COPY requirements.txt . +COPY README.md . +RUN pip install . \ + && rm -rf /build-ocrd_segment + +WORKDIR /data From 11adddfab39c4dd32dc4daff717dae01c2915030 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Thu, 8 Feb 2024 10:59:40 +0100 Subject: [PATCH 2/3] add docker --- Dockerfile | 14 +++++++++++--- Makefile | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 Makefile diff --git a/Dockerfile b/Dockerfile index 0557a05..5e738a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,20 @@ FROM ocrd/core:v2.62.0 AS base +ARG VCS_REF +ARG BUILD_DATE +LABEL \ + maintainer="https://github.com/OCR-D/ocrd_segment/issues" \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url="https://github.com/OCR-D/ocrd_segment" \ + org.label-schema.build-date=$BUILD_DATE -WORKDIR /build-ocrd_segment +WORKDIR /build COPY setup.py . COPY ocrd_segment/ocrd-tool.json . COPY ocrd_segment ./ocrd_segment COPY requirements.txt . COPY README.md . -RUN pip install . \ - && rm -rf /build-ocrd_segment +RUN pip install . +RUN rm -rf /build WORKDIR /data +VOLUME ["/data"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6403c36 --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +SHELL = /bin/bash +PYTHON ?= python +PIP ?= pip +TAG ?= ocrd/segment + +# BEGIN-EVAL makefile-parser --make-help Makefile + +help: + @echo "" + @echo " Targets" + @echo "" + @echo " deps (install required Python packages)" + @echo " install (install this Python package)" + @echo " docker (build Docker image)" + @echo "" + +# END-EVAL + +# (install required Python packages) +deps: + $(PIP) install -r requirements.txt + +#deps-test: +# $(PIP) install -r requirements_test.txt + +# Dependencies for deployment in an ubuntu/debian linux +# deps-ubuntu: +# sudo apt-get install -y \ +# ... + +# (install this Python package) +install: deps + $(PIP) install . + +docker: + docker build \ + -t $(TAG) \ + --build-arg VCS_REF=$(git rev-parse --short HEAD) \ + --build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") . + +.PHONY: help deps install docker # deps-test test From c67a11aa7b650c243188812c18f0bef039a8cd4e Mon Sep 17 00:00:00 2001 From: Robert Sachunsky <38561704+bertsky@users.noreply.github.com> Date: Wed, 14 Feb 2024 21:16:50 +0100 Subject: [PATCH 3/3] add CI/CD --- .circleci/config.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..874234d --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,37 @@ +version: 2.1 +jobs: + + build-python3: + docker: + - image: ocrd/core + environment: + PIP: pip3 + PYTHON: python3 + steps: + - checkout + - run: make install + + deploy-docker: + docker: + - image: circleci/buildpack-deps:stretch + steps: + - checkout + - setup_remote_docker: # https://circleci.com/docs/2.0/building-docker-images/ + docker_layer_caching: true + - run: make docker + - run: + name: Login to Docker Hub + command: echo "$DOCKERHUB_PASS" | docker login --username "$DOCKERHUB_USER" --password-stdin + - run: docker push ocrd/segment + +workflows: + version: 2 + build-and-test: + jobs: + - build-python3 + deploy: + jobs: + - deploy-docker: + filters: + branches: + only: master