From df790c5cc8d97b6a1a1f5d6f683068108d5deec1 Mon Sep 17 00:00:00 2001 From: Konstantin Baierer Date: Fri, 21 Feb 2020 15:50:48 +0100 Subject: [PATCH 1/4] [wip] set VCFS_REF and BUILD_DATE for `make docker` --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e38ec03..2a379eb 100644 --- a/Makefile +++ b/Makefile @@ -64,4 +64,7 @@ uninstall: # Build Docker image docker: - docker build -t '$(DOCKER_TAG)' . + docker build \ + --build-arg VCS_REF=$$(git rev-parse --short HEAD) \ + --build-arg BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ + -t '$(DOCKER_TAG)' . From b3222fbf1c95e915234af241ff54674a65100291 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky <38561704+bertsky@users.noreply.github.com> Date: Tue, 1 Oct 2024 18:56:16 +0200 Subject: [PATCH 2/4] make docker: pass in DOCKER_BASE_IMAGE, too --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2a379eb..962789e 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,8 @@ BINDIR = $(PREFIX)/bin SHAREDIR = $(PREFIX)/share/ocrd-im6convert # Docker tag -DOCKER_TAG = ocrd/im6convert +DOCKER_BASE_IMAGE ?= docker.io/ocrd/core:v2.69.0 +DOCKER_TAG ?= ocrd/im6convert # Python pip to install with ('$(PIP)') PIP ?= $(shell which pip) @@ -65,6 +66,9 @@ uninstall: # 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)' . + +.PHONY: help deps deps-ubuntu install uninstall docker From 8d6372910b9fcabd0d5dad89126a552ff96a012a Mon Sep 17 00:00:00 2001 From: Robert Sachunsky <38561704+bertsky@users.noreply.github.com> Date: Tue, 1 Oct 2024 19:00:09 +0200 Subject: [PATCH 3/4] dockerfile: apply DOCKER_BASE_IMAGE, add labels, rm build dir, smoke test --- Dockerfile | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6cf94df..cc60c8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,17 @@ -FROM ocrd/core -MAINTAINER OCR-D +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/OCR-D/ocrd_fileformat" \ + org.label-schema.build-date=$BUILD_DATE ENV DEBIAN_FRONTEND noninteractive ENV PREFIX=/usr/local -WORKDIR /build +WORKDIR /build/ocrd_fileformat COPY ocrd-im6convert . COPY ocrd-tool.json . COPY Makefile . @@ -13,11 +20,10 @@ RUN apt-get update && \ apt-get -y install apt-utils && \ apt-get -y install --no-install-recommends \ ca-certificates \ - make - -RUN make deps-ubuntu install + make && \ + make deps-ubuntu install && \ + rm -fr /build/ocrd_fileformat +# smoke test +RUN ocrd-fileformat-transform --version ENV DEBIAN_FRONTEND teletype - -# no fixed entrypoint (e.g. also allow `convert` etc) -CMD ["/usr/local/bin/ocrd-im6convert", "--help"] From 193dc318ec6b161de0256b846adb7189c9c1e408 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky <38561704+bertsky@users.noreply.github.com> Date: Tue, 1 Oct 2024 19:03:08 +0200 Subject: [PATCH 4/4] add CD --- .github/workflows/docker-image.yml | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..ebfc3f7 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,38 @@ +name: Docker Image CD + +on: + push: + branches: [ "master" ] + workflow_dispatch: + +jobs: + + deploy: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v3 + - # 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 + - 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 ocrd/im6convert + - name: Alias the Docker image for GHCR + run: docker tag ocrd/im6convert 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 }}