From ea98c5e3a85bf33e540a3ba9ad27cebe853c28ff Mon Sep 17 00:00:00 2001 From: Robert Sachunsky <38561704+bertsky@users.noreply.github.com> Date: Tue, 1 Oct 2024 19:10:53 +0200 Subject: [PATCH 1/2] improve-docker-build --- Dockerfile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index ad6c781..750ebf1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -FROM ocrd/core - +ARG DOCKER_BASE_IMAGE +FROM $DOCKER_BASE_IMAGE ARG VCS_REF ARG BUILD_DATE LABEL \ @@ -13,15 +13,19 @@ ENV PREFIX=/usr/local RUN apt-get update && apt-get install -y openjdk-11-jdk-headless wget git gcc unzip -WORKDIR /build +WORKDIR /build/ocrd_fileformat + COPY .git .git/ COPY repo/ocr-fileformat repo/ocr-fileformat/ COPY ocrd-fileformat-transform . COPY ocrd-tool.json . COPY Makefile . -RUN make install-fileformat install PREFIX=/usr/local SHELL="bash -x" + +RUN make install-fileformat install PREFIX=$PREFIX SHELL="bash -x" && \ + rm -fr /build/ocrd_fileformat +# smoke test +RUN ocrd-fileformat-transform --version WORKDIR /data ENV DEBIAN_FRONTEND teletype -CMD ["/usr/local/bin/ocrd-fileformat-transform", "--help"] From 894fa62f18bb41392ef31576111e3fbe586a5ba8 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky <38561704+bertsky@users.noreply.github.com> Date: Tue, 1 Oct 2024 19:16:05 +0200 Subject: [PATCH 2/2] make docker: pass in VCS_REF and BUILD_DATE, too --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7163056..55cd5e6 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ PROJECT_NAME := ocrd_fileformat TOOLS = ocrd-fileformat-transform -DOCKER_TAG = ocrd/fileformat +DOCKER_BASE_IMAGE ?= docker.io/ocrd/core:v2.69.0 +DOCKER_TAG ?= ocrd/fileformat PIP ?= pip3 @@ -67,7 +68,11 @@ uninstall: # Build Docker image docker: - docker build -t '$(DOCKER_TAG)' . + 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) . # # Assets