mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-28 03:46:06 -05:00 
			
		
		
		
	Decrease the final size of the images containing .deb and .whl files
This commit is contained in:
		| @@ -7,6 +7,7 @@ FROM debian:bullseye-slim as main | |||||||
| LABEL org.opencontainers.image.description="A intermediate image with jbig2enc built" | LABEL org.opencontainers.image.description="A intermediate image with jbig2enc built" | ||||||
|  |  | ||||||
| ARG DEBIAN_FRONTEND=noninteractive | ARG DEBIAN_FRONTEND=noninteractive | ||||||
|  | ARG JBIG2ENC_VERSION | ||||||
|  |  | ||||||
| ARG BUILD_PACKAGES="\ | ARG BUILD_PACKAGES="\ | ||||||
|   build-essential \ |   build-essential \ | ||||||
| @@ -19,21 +20,16 @@ ARG BUILD_PACKAGES="\ | |||||||
|  |  | ||||||
| WORKDIR /usr/src/jbig2enc | WORKDIR /usr/src/jbig2enc | ||||||
|  |  | ||||||
| # As this is an base image for a multi-stage final image |  | ||||||
| # the added size of the install is basically irrelevant |  | ||||||
| RUN apt-get update --quiet \ |  | ||||||
|   && apt-get install --yes --quiet --no-install-recommends ${BUILD_PACKAGES} \ |  | ||||||
|   && rm -rf /var/lib/apt/lists/* |  | ||||||
|  |  | ||||||
| # Layers after this point change according to required version |  | ||||||
| # For better caching, seperate the basic installs from |  | ||||||
| # the building |  | ||||||
|  |  | ||||||
| ARG JBIG2ENC_VERSION |  | ||||||
|  |  | ||||||
| RUN set -eux \ | RUN set -eux \ | ||||||
|   && git clone --quiet --branch $JBIG2ENC_VERSION https://github.com/agl/jbig2enc . |   && echo "Installing build tools" \ | ||||||
| RUN set -eux \ |     && apt-get update --quiet \ | ||||||
|   && ./autogen.sh |     && apt-get install --yes --quiet --no-install-recommends ${BUILD_PACKAGES} \ | ||||||
| RUN set -eux \ |   && echo "Building jbig2enc" \ | ||||||
|   && ./configure && make |     && git clone --quiet --branch $JBIG2ENC_VERSION https://github.com/agl/jbig2enc . \ | ||||||
|  |     && ./autogen.sh \ | ||||||
|  |     && ./configure \ | ||||||
|  |     && make \ | ||||||
|  |   && echo "Cleaning up image" \ | ||||||
|  |     && apt-get -y purge ${BUILD_PACKAGES} \ | ||||||
|  |     && apt-get -y autoremove --purge \ | ||||||
|  |     && rm -rf /var/lib/apt/lists/* | ||||||
|   | |||||||
| @@ -17,6 +17,7 @@ FROM python:3.9-slim-bullseye as main | |||||||
| LABEL org.opencontainers.image.description="A intermediate image with pikepdf wheel built" | LABEL org.opencontainers.image.description="A intermediate image with pikepdf wheel built" | ||||||
|  |  | ||||||
| ARG DEBIAN_FRONTEND=noninteractive | ARG DEBIAN_FRONTEND=noninteractive | ||||||
|  | ARG PIKEPDF_VERSION | ||||||
|  |  | ||||||
| ARG BUILD_PACKAGES="\ | ARG BUILD_PACKAGES="\ | ||||||
|   build-essential \ |   build-essential \ | ||||||
| @@ -55,34 +56,33 @@ COPY --from=qpdf-builder /usr/src/qpdf/*.deb ./ | |||||||
| # the added size of the install is basically irrelevant | # the added size of the install is basically irrelevant | ||||||
|  |  | ||||||
| RUN set -eux \ | RUN set -eux \ | ||||||
|   && apt-get update --quiet \ |   && echo "Installing build tools" \ | ||||||
|   && apt-get install --yes --quiet --no-install-recommends $BUILD_PACKAGES \ |     && apt-get update --quiet \ | ||||||
|   && dpkg --install libqpdf28_*.deb \ |     && apt-get install --yes --quiet --no-install-recommends ${BUILD_PACKAGES} \ | ||||||
|   && dpkg --install libqpdf-dev_*.deb \ |   && echo "Installing qpdf" \ | ||||||
|   && python3 -m pip install --no-cache-dir --upgrade \ |     && dpkg --install libqpdf28_*.deb \ | ||||||
|     pip \ |     && dpkg --install libqpdf-dev_*.deb \ | ||||||
|     wheel \ |   && echo "Installing Python tools" \ | ||||||
|     # https://pikepdf.readthedocs.io/en/latest/installation.html#requirements |     && python3 -m pip install --no-cache-dir --upgrade \ | ||||||
|     pybind11 \ |       pip \ | ||||||
|   && rm -rf /var/lib/apt/lists/* |       wheel \ | ||||||
|  |       # https://pikepdf.readthedocs.io/en/latest/installation.html#requirements | ||||||
| # Layers after this point change according to required version |       pybind11 \ | ||||||
| # For better caching, seperate the basic installs from |  | ||||||
| # the building |  | ||||||
|  |  | ||||||
| ARG PIKEPDF_VERSION |  | ||||||
|  |  | ||||||
| RUN set -eux \ |  | ||||||
|   && echo "Building pikepdf wheel ${PIKEPDF_VERSION}" \ |   && echo "Building pikepdf wheel ${PIKEPDF_VERSION}" \ | ||||||
|   && mkdir wheels \ |     && mkdir wheels \ | ||||||
|   && python3 -m pip wheel \ |     && python3 -m pip wheel \ | ||||||
|     # Build the package at the required version |       # Build the package at the required version | ||||||
|     pikepdf==${PIKEPDF_VERSION} \ |       pikepdf==${PIKEPDF_VERSION} \ | ||||||
|     # Output the *.whl into this directory |       # Output the *.whl into this directory | ||||||
|     --wheel-dir wheels \ |       --wheel-dir wheels \ | ||||||
|     # Do not use a binary packge for the package being built |       # Do not use a binary packge for the package being built | ||||||
|     --no-binary=pikepdf \ |       --no-binary=pikepdf \ | ||||||
|     # Do use binary packages for dependencies |       # Do use binary packages for dependencies | ||||||
|     --prefer-binary \ |       --prefer-binary \ | ||||||
|     --no-cache-dir \ |       # Don't cache build files | ||||||
|   && ls -ahl wheels |       --no-cache-dir \ | ||||||
|  |     && ls -ahl wheels \ | ||||||
|  |   && echo "Cleaning up image" \ | ||||||
|  |     && apt-get -y purge ${BUILD_PACKAGES} \ | ||||||
|  |     && apt-get -y autoremove --purge \ | ||||||
|  |     && rm -rf /var/lib/apt/lists/* | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ FROM python:3.9-slim-bullseye as main | |||||||
|  |  | ||||||
| LABEL org.opencontainers.image.description="A intermediate image with psycopg2 wheel built" | LABEL org.opencontainers.image.description="A intermediate image with psycopg2 wheel built" | ||||||
|  |  | ||||||
|  | ARG PSYCOPG2_VERSION | ||||||
| ARG DEBIAN_FRONTEND=noninteractive | ARG DEBIAN_FRONTEND=noninteractive | ||||||
|  |  | ||||||
| ARG BUILD_PACKAGES="\ | ARG BUILD_PACKAGES="\ | ||||||
| @@ -21,29 +22,27 @@ WORKDIR /usr/src | |||||||
| # the added size of the install is basically irrelevant | # the added size of the install is basically irrelevant | ||||||
|  |  | ||||||
| RUN set -eux \ | RUN set -eux \ | ||||||
|   && apt-get update --quiet \ |   && echo "Installing build tools" \ | ||||||
|   && apt-get install --yes --quiet --no-install-recommends $BUILD_PACKAGES \ |     && apt-get update --quiet \ | ||||||
|   && rm -rf /var/lib/apt/lists/* \ |     && apt-get install --yes --quiet --no-install-recommends ${BUILD_PACKAGES} \ | ||||||
|   && python3 -m pip install --no-cache-dir --upgrade pip wheel |   && echo "Installing Python tools" \ | ||||||
|  |     && python3 -m pip install --no-cache-dir --upgrade pip wheel \ | ||||||
| # Layers after this point change according to required version |  | ||||||
| # For better caching, seperate the basic installs from |  | ||||||
| # the building |  | ||||||
|  |  | ||||||
| ARG PSYCOPG2_VERSION |  | ||||||
|  |  | ||||||
| RUN set -eux \ |  | ||||||
|   && echo "Building psycopg2 wheel ${PSYCOPG2_VERSION}" \ |   && echo "Building psycopg2 wheel ${PSYCOPG2_VERSION}" \ | ||||||
|   && cd /usr/src \ |     && cd /usr/src \ | ||||||
|   && mkdir wheels \ |     && mkdir wheels \ | ||||||
|   && python3 -m pip wheel \ |     && python3 -m pip wheel \ | ||||||
|     # Build the package at the required version |       # Build the package at the required version | ||||||
|     psycopg2==${PSYCOPG2_VERSION} \ |       psycopg2==${PSYCOPG2_VERSION} \ | ||||||
|     # Output the *.whl into this directory |       # Output the *.whl into this directory | ||||||
|     --wheel-dir wheels \ |       --wheel-dir wheels \ | ||||||
|     # Do not use a binary packge for the package being built |       # Do not use a binary packge for the package being built | ||||||
|     --no-binary=psycopg2 \ |       --no-binary=psycopg2 \ | ||||||
|     # Do use binary packages for dependencies |       # Do use binary packages for dependencies | ||||||
|     --prefer-binary \ |       --prefer-binary \ | ||||||
|     --no-cache-dir \ |       # Don't cache build files | ||||||
|   && ls -ahl wheels/ |       --no-cache-dir \ | ||||||
|  |     && ls -ahl wheels/ \ | ||||||
|  |   && echo "Cleaning up image" \ | ||||||
|  |     && apt-get -y purge ${BUILD_PACKAGES} \ | ||||||
|  |     && apt-get -y autoremove --purge \ | ||||||
|  |     && rm -rf /var/lib/apt/lists/* | ||||||
|   | |||||||
| @@ -1,8 +1,15 @@ | |||||||
|  | # This Dockerfile compiles the jbig2enc library | ||||||
|  | # Inputs: | ||||||
|  | #    - QPDF_VERSION - the version of qpdf to build a .deb. | ||||||
|  | #                     Must be preset as a deb-src | ||||||
|  |  | ||||||
| FROM debian:bullseye-slim as main | FROM debian:bullseye-slim as main | ||||||
|  |  | ||||||
| LABEL org.opencontainers.image.description="A intermediate image with qpdf built" | LABEL org.opencontainers.image.description="A intermediate image with qpdf built" | ||||||
|  |  | ||||||
| ARG DEBIAN_FRONTEND=noninteractive | ARG DEBIAN_FRONTEND=noninteractive | ||||||
|  | # This must match to pikepdf's minimum at least | ||||||
|  | ARG QPDF_VERSION | ||||||
|  |  | ||||||
| ARG BUILD_PACKAGES="\ | ARG BUILD_PACKAGES="\ | ||||||
|   build-essential \ |   build-essential \ | ||||||
| @@ -23,31 +30,23 @@ WORKDIR /usr/src | |||||||
| # the added size of the install is basically irrelevant | # the added size of the install is basically irrelevant | ||||||
|  |  | ||||||
| RUN set -eux \ | RUN set -eux \ | ||||||
|   && apt-get update --quiet \ |   && echo "Installing build tools" \ | ||||||
|   && apt-get install --yes --quiet --no-install-recommends $BUILD_PACKAGES \ |     && apt-get update --quiet \ | ||||||
|   && rm -rf /var/lib/apt/lists/* |     && apt-get install --yes --quiet --no-install-recommends $BUILD_PACKAGES \ | ||||||
|  |  | ||||||
| # Layers after this point change according to required version |  | ||||||
| # For better caching, seperate the basic installs from |  | ||||||
| # the building |  | ||||||
|  |  | ||||||
| # This must match to pikepdf's minimum at least |  | ||||||
| ARG QPDF_VERSION |  | ||||||
|  |  | ||||||
| # In order to get the required version of qpdf, it is backported from bookwork |  | ||||||
| # and then built from source |  | ||||||
| RUN set -eux \ |  | ||||||
|   && echo "Building qpdf" \ |   && echo "Building qpdf" \ | ||||||
|   && echo "deb-src http://deb.debian.org/debian/ bookworm main" > /etc/apt/sources.list.d/bookworm-src.list \ |     && echo "deb-src http://deb.debian.org/debian/ bookworm main" > /etc/apt/sources.list.d/bookworm-src.list \ | ||||||
|   && apt-get update \ |     && apt-get update \ | ||||||
|   && mkdir qpdf \ |     && mkdir qpdf \ | ||||||
|   && cd qpdf \ |     && cd qpdf \ | ||||||
|   && apt-get source --yes --quiet qpdf=${QPDF_VERSION}-1/bookworm \ |     && apt-get source --yes --quiet qpdf=${QPDF_VERSION}-1/bookworm \ | ||||||
|   && rm -rf /var/lib/apt/lists/* \ |     && cd qpdf-$QPDF_VERSION \ | ||||||
|   && cd qpdf-$QPDF_VERSION \ |     # We don't need to build the tests (also don't run them) | ||||||
|   # We don't need to build the tests (also don't run them) |     && rm -rf libtests \ | ||||||
|   && rm -rf libtests \ |     && DEBEMAIL=hello@paperless-ngx.com debchange --bpo \ | ||||||
|   && DEBEMAIL=hello@paperless-ngx.com debchange --bpo \ |     && export DEB_BUILD_OPTIONS="terse nocheck nodoc parallel=2" \ | ||||||
|   && export DEB_BUILD_OPTIONS="terse nocheck nodoc parallel=2" \ |     && dpkg-buildpackage --build=binary --unsigned-source --unsigned-changes --post-clean \ | ||||||
|   && dpkg-buildpackage --build=binary --unsigned-source --unsigned-changes \ |     && ls -ahl ../*.deb \ | ||||||
|   && ls -ahl ../*.deb |   && echo "Cleaning up image" \ | ||||||
|  |     && apt-get -y purge ${BUILD_PACKAGES} \ | ||||||
|  |     && apt-get -y autoremove --purge \ | ||||||
|  |     && rm -rf /var/lib/apt/lists/* | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Trenton Holmes
					Trenton Holmes