diff --git a/packaging/Dockerfile b/packaging/Dockerfile new file mode 100644 index 0000000..1d7c7d3 --- /dev/null +++ b/packaging/Dockerfile @@ -0,0 +1,67 @@ +# syntax = docker/dockerfile:experimental +# +# Requires Docker v18.06 or later and BuildKit mode to use cache mount +# Docker v18.06 also requires the daemon to be running in experimental mode. +# +# $ export DOCKER_BUILDKIT=1 +# +# See https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/experimental.md +# +# To build for arm, see https://www.docker.com/blog/getting-started-with-docker-for-arm-on-linux/ +# +# Build targets supported: +# docker build --build-arg=TARGET=pld packaging +# docker build --build-arg=TARGET=debian packaging +# docker build --build-arg=TARGET=fedora packaging + +ARG VERSION=v1.0pre7 +ARG TARGET=debian + +FROM alpine AS source +RUN apk add git curl patch +ARG VERSION +RUN git clone --depth=1 -b $VERSION https://github.com/ruediger/VobSub2SRT /source +WORKDIR /source +RUN curl -sSfLO https://github.com/ruediger/VobSub2SRT/pull/72.patch +RUN patch -p1 < 72.patch + +## Debian +FROM debian:buster AS runtime-debian +RUN --mount=type=cache,id=apt,target=/var/cache/apt \ + apt update && apt install -y \ + libtesseract4 +FROM runtime-debian AS build-debian +RUN --mount=type=cache,id=apt,target=/var/cache/apt \ + apt install -y \ + build-essential cmake libtesseract-dev libtiff5-dev pkg-config tesseract-ocr-eng + +## PLD Linux +FROM registry.gitlab.com/pld-linux/pld AS runtime-pld +RUN --mount=type=cache,id=poldek,target=/var/cache/poldek \ + poldek -O 'keep downloads=yes' --up -u \ + tesseract +FROM runtime-pld AS build-pld +RUN --mount=type=cache,id=poldek,target=/var/cache/poldek \ + poldek -O 'keep downloads=yes' -u \ + cmake gzip libtiff-devel make tesseract-devel + +## Fedora Linux +FROM fedora:31 AS runtime-fedora +RUN --mount=type=cache,id=dnf,target=/var/cache/dnf \ + dnf install -y \ + tesseract +FROM runtime-fedora AS build-fedora +RUN --mount=type=cache,id=dnf,target=/var/cache/dnf \ + dnf install -y \ + cmake g++ libtiff-devel make tesseract-devel + +FROM build-$TARGET AS build +WORKDIR /build +COPY --from=source /source . +RUN ./configure +RUN make +RUN make install +RUN strip /usr/local/bin/* + +FROM runtime-$TARGET AS runtime +COPY --from=build /usr/local/bin/* /usr/local/bin