mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
119 lines
3.6 KiB
Docker
119 lines
3.6 KiB
Docker
# This Dockerfile builds the pikepdf wheel
|
|
# Inputs:
|
|
# - REPO - Docker repository to pull qpdf from
|
|
# - QPDF_VERSION - The image qpdf version to copy .deb files from
|
|
# - PIKEPDF_VERSION - Version of pikepdf to build wheel for
|
|
|
|
# Default to pulling from the main repo registry when manually building
|
|
ARG REPO="paperless-ngx/paperless-ngx"
|
|
|
|
# This does nothing, except provide a name for a copy below
|
|
ARG QPDF_VERSION
|
|
FROM --platform=$BUILDPLATFORM ghcr.io/${REPO}/builder/qpdf:${QPDF_VERSION} as qpdf-builder
|
|
|
|
#
|
|
# Stage: builder
|
|
# Purpose:
|
|
# - Build the pikepdf wheel
|
|
# - Build any dependent wheels which can't be found
|
|
#
|
|
FROM python:3.9-slim-bullseye as builder
|
|
|
|
LABEL org.opencontainers.image.description="A intermediate image with pikepdf wheel built"
|
|
|
|
# Buildx provided
|
|
ARG TARGETARCH
|
|
ARG TARGETVARIANT
|
|
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
# Workflow provided
|
|
ARG QPDF_VERSION
|
|
ARG PIKEPDF_VERSION
|
|
# These are not used, but will still bust the cache if one changes
|
|
# Otherwise, the main image will try to build thing (and fail)
|
|
ARG PILLOW_VERSION
|
|
ARG LXML_VERSION
|
|
|
|
ARG BUILD_PACKAGES="\
|
|
build-essential \
|
|
python3-dev \
|
|
python3-pip \
|
|
# qpdf requirement - https://github.com/qpdf/qpdf#crypto-providers
|
|
libgnutls28-dev \
|
|
# lxml requrements - https://lxml.de/installation.html
|
|
libxml2-dev \
|
|
libxslt1-dev \
|
|
# Pillow requirements - https://pillow.readthedocs.io/en/stable/installation.html#external-libraries
|
|
# JPEG functionality
|
|
libjpeg62-turbo-dev \
|
|
# conpressed PNG
|
|
zlib1g-dev \
|
|
# compressed TIFF
|
|
libtiff-dev \
|
|
# type related services
|
|
libfreetype-dev \
|
|
# color management
|
|
liblcms2-dev \
|
|
# WebP format
|
|
libwebp-dev \
|
|
# JPEG 2000
|
|
libopenjp2-7-dev \
|
|
# improved color quantization
|
|
libimagequant-dev \
|
|
# complex text layout support
|
|
libraqm-dev"
|
|
|
|
WORKDIR /usr/src
|
|
|
|
COPY --from=qpdf-builder /usr/src/qpdf/${QPDF_VERSION}/${TARGETARCH}${TARGETVARIANT}/*.deb ./
|
|
|
|
# As this is an base image for a multi-stage final image
|
|
# the added size of the install is basically irrelevant
|
|
|
|
RUN set -eux \
|
|
&& echo "Installing build tools" \
|
|
&& apt-get update --quiet \
|
|
&& apt-get install --yes --quiet --no-install-recommends ${BUILD_PACKAGES} \
|
|
&& echo "Installing qpdf" \
|
|
&& dpkg --install libqpdf29_*.deb \
|
|
&& dpkg --install libqpdf-dev_*.deb \
|
|
&& echo "Installing Python tools" \
|
|
&& python3 -m pip install --no-cache-dir --upgrade \
|
|
pip \
|
|
wheel \
|
|
# https://pikepdf.readthedocs.io/en/latest/installation.html#requirements
|
|
pybind11 \
|
|
&& echo "Building pikepdf wheel ${PIKEPDF_VERSION}" \
|
|
&& mkdir wheels \
|
|
&& python3 -m pip wheel \
|
|
# Build the package at the required version
|
|
pikepdf==${PIKEPDF_VERSION} \
|
|
# Look to piwheels for additional pre-built wheels
|
|
--extra-index-url https://www.piwheels.org/simple \
|
|
# Output the *.whl into this directory
|
|
--wheel-dir wheels \
|
|
# Do not use a binary packge for the package being built
|
|
--no-binary=pikepdf \
|
|
# Do use binary packages for dependencies
|
|
--prefer-binary \
|
|
# Don't cache build files
|
|
--no-cache-dir \
|
|
&& ls -ahl wheels \
|
|
&& echo "Gathering package data" \
|
|
&& dpkg-query -f '${Package;-40}${Version}\n' -W > ./wheels/pkg-list.txt \
|
|
&& echo "Cleaning up image" \
|
|
&& apt-get -y purge ${BUILD_PACKAGES} \
|
|
&& apt-get -y autoremove --purge \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
#
|
|
# Stage: package
|
|
# Purpose: Holds the compiled .whl files in a tiny image to pull
|
|
#
|
|
FROM alpine:3.17 as package
|
|
|
|
WORKDIR /usr/src/wheels/
|
|
|
|
COPY --from=builder /usr/src/wheels/*.whl ./
|
|
COPY --from=builder /usr/src/wheels/pkg-list.txt ./
|