|
| 1 | +# |
| 2 | +# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh" |
| 3 | +# |
| 4 | +# PLEASE DO NOT EDIT IT DIRECTLY. |
| 5 | +# |
| 6 | +ARG IMAGE=nginxinc/nginx-unprivileged:1.27.5 |
| 7 | +FROM $IMAGE |
| 8 | + |
| 9 | +ARG UID=101 |
| 10 | +ARG GID=101 |
| 11 | + |
| 12 | +USER root |
| 13 | + |
| 14 | +ENV OTEL_VERSION=0.1.2 |
| 15 | + |
| 16 | +RUN set -x; \ |
| 17 | + NGINX_GPGKEY_PATH=/etc/apt/keyrings/nginx-archive-keyring.gpg; \ |
| 18 | + dpkgArch="$(dpkg --print-architecture)" \ |
| 19 | + && nginxPackages=" \ |
| 20 | + nginx=${NGINX_VERSION}-${PKG_RELEASE} \ |
| 21 | + nginx-module-xslt=${NGINX_VERSION}-${DYNPKG_RELEASE} \ |
| 22 | + nginx-module-geoip=${NGINX_VERSION}-${DYNPKG_RELEASE} \ |
| 23 | + nginx-module-image-filter=${NGINX_VERSION}-${DYNPKG_RELEASE} \ |
| 24 | + nginx-module-njs=${NGINX_VERSION}+${NJS_VERSION}-${NJS_RELEASE} \ |
| 25 | + nginx-module-otel=${NGINX_VERSION}+${OTEL_VERSION}-${PKG_RELEASE} \ |
| 26 | + " \ |
| 27 | + && case "$dpkgArch" in \ |
| 28 | + amd64|arm64) \ |
| 29 | +# arches officialy built by upstream |
| 30 | + echo "deb [signed-by=$NGINX_GPGKEY_PATH] https://nginx.org/packages/mainline/debian/ bookworm nginx" >> /etc/apt/sources.list.d/nginx.list \ |
| 31 | + && apt-get update \ |
| 32 | + ;; \ |
| 33 | + *) \ |
| 34 | +# we're on an architecture upstream doesn't officially build for |
| 35 | +# let's build binaries from the published packaging sources |
| 36 | +# new directory for storing sources and .deb files |
| 37 | + tempDir="$(mktemp -d)" \ |
| 38 | + && chmod 777 "$tempDir" \ |
| 39 | +# (777 to ensure APT's "_apt" user can access it too) |
| 40 | + \ |
| 41 | +# save list of currently-installed packages so build dependencies can be cleanly removed later |
| 42 | + && savedAptMark="$(apt-mark showmanual)" \ |
| 43 | + \ |
| 44 | +# build .deb files from upstream's packaging sources |
| 45 | + && apt-get update \ |
| 46 | + && apt-get install --no-install-recommends --no-install-suggests -y \ |
| 47 | + curl \ |
| 48 | + devscripts \ |
| 49 | + equivs \ |
| 50 | + git \ |
| 51 | + libxml2-utils \ |
| 52 | + lsb-release \ |
| 53 | + xsltproc \ |
| 54 | + && ( \ |
| 55 | + cd "$tempDir" \ |
| 56 | + && REVISION="${NGINX_VERSION}-${PKG_RELEASE}" \ |
| 57 | + && REVISION=${REVISION%~*} \ |
| 58 | + && curl -f -L -O https://github.com/nginx/pkg-oss/archive/${REVISION}.tar.gz \ |
| 59 | + && PKGOSSCHECKSUM="c773d98b567bd585c17f55702bf3e4c7d82b676bfbde395270e90a704dca3c758dfe0380b3f01770542b4fd9bed1f1149af4ce28bfc54a27a96df6b700ac1745 *${REVISION}.tar.gz" \ |
| 60 | + && if [ "$(openssl sha512 -r ${REVISION}.tar.gz)" = "$PKGOSSCHECKSUM" ]; then \ |
| 61 | + echo "pkg-oss tarball checksum verification succeeded!"; \ |
| 62 | + else \ |
| 63 | + echo "pkg-oss tarball checksum verification failed!"; \ |
| 64 | + exit 1; \ |
| 65 | + fi \ |
| 66 | + && tar xzvf ${REVISION}.tar.gz \ |
| 67 | + && cd pkg-oss-${REVISION} \ |
| 68 | + && cd debian \ |
| 69 | + && for target in module-otel; do \ |
| 70 | + make rules-$target; \ |
| 71 | + mk-build-deps --install --tool="apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes" \ |
| 72 | + debuild-$target/nginx-$NGINX_VERSION/debian/control; \ |
| 73 | + done \ |
| 74 | + && make module-otel \ |
| 75 | + ) \ |
| 76 | +# we don't remove APT lists here because they get re-downloaded and removed later |
| 77 | + \ |
| 78 | +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies |
| 79 | +# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies) |
| 80 | + && apt-mark showmanual | xargs apt-mark auto > /dev/null \ |
| 81 | + && { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \ |
| 82 | + \ |
| 83 | +# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be) |
| 84 | + && ls -lAFh "$tempDir" \ |
| 85 | + && ( cd "$tempDir" && dpkg-scanpackages . > Packages ) \ |
| 86 | + && grep '^Package: ' "$tempDir/Packages" \ |
| 87 | + && echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list \ |
| 88 | +# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes") |
| 89 | +# Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied) |
| 90 | +# ... |
| 91 | +# E: Failed to fetch store:/var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied) |
| 92 | + && apt-get -o Acquire::GzipIndexes=false update \ |
| 93 | + ;; \ |
| 94 | + esac \ |
| 95 | + \ |
| 96 | + && apt-get install --no-install-recommends --no-install-suggests -y \ |
| 97 | + $nginxPackages \ |
| 98 | + gettext-base \ |
| 99 | + curl \ |
| 100 | + && apt-get remove --purge --auto-remove -y && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx.list \ |
| 101 | + \ |
| 102 | +# if we have leftovers from building, let's purge them (including extra, unnecessary build deps) |
| 103 | + && if [ -n "$tempDir" ]; then \ |
| 104 | + apt-get purge -y --auto-remove \ |
| 105 | + && rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \ |
| 106 | + fi |
| 107 | + |
| 108 | +USER $UID |
0 commit comments