|
| 1 | +# |
| 2 | +# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh" |
| 3 | +# |
| 4 | +# PLEASE DO NOT EDIT IT DIRECTLY. |
| 5 | +# |
| 6 | +FROM nginx:1.26.0 |
| 7 | + |
| 8 | +ENV OTEL_VERSION 0.1.0 |
| 9 | + |
| 10 | +RUN set -x \ |
| 11 | + && apt-get update \ |
| 12 | + && apt-get install --no-install-recommends --no-install-suggests -y gnupg1 ca-certificates \ |
| 13 | + && \ |
| 14 | + NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \ |
| 15 | + NGINX_GPGKEY_PATH=/usr/share/keyrings/nginx-archive-keyring.gpg; \ |
| 16 | + export GNUPGHOME="$(mktemp -d)"; \ |
| 17 | + found=''; \ |
| 18 | + for server in \ |
| 19 | + hkp://keyserver.ubuntu.com:80 \ |
| 20 | + pgp.mit.edu \ |
| 21 | + ; do \ |
| 22 | + echo "Fetching GPG key $NGINX_GPGKEY from $server"; \ |
| 23 | + gpg1 --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \ |
| 24 | + done; \ |
| 25 | + test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \ |
| 26 | + gpg1 --export "$NGINX_GPGKEY" > "$NGINX_GPGKEY_PATH" ; \ |
| 27 | + rm -rf "$GNUPGHOME"; \ |
| 28 | + apt-get remove --purge --auto-remove -y gnupg1 && rm -rf /var/lib/apt/lists/* \ |
| 29 | + && dpkgArch="$(dpkg --print-architecture)" \ |
| 30 | + && nginxPackages=" \ |
| 31 | + nginx=${NGINX_VERSION}-${PKG_RELEASE} \ |
| 32 | + nginx-module-xslt=${NGINX_VERSION}-${PKG_RELEASE} \ |
| 33 | + nginx-module-geoip=${NGINX_VERSION}-${PKG_RELEASE} \ |
| 34 | + nginx-module-image-filter=${NGINX_VERSION}-${PKG_RELEASE} \ |
| 35 | + nginx-module-njs=${NGINX_VERSION}+${NJS_VERSION}-${PKG_RELEASE} \ |
| 36 | + nginx-module-otel=${NGINX_VERSION}+${OTEL_VERSION}-${PKG_RELEASE} \ |
| 37 | + " \ |
| 38 | + && case "$dpkgArch" in \ |
| 39 | + amd64|arm64) \ |
| 40 | +# arches officialy built by upstream |
| 41 | + echo "deb [signed-by=$NGINX_GPGKEY_PATH] https://nginx.org/packages/debian/ bookworm nginx" >> /etc/apt/sources.list.d/nginx.list \ |
| 42 | + && apt-get update \ |
| 43 | + ;; \ |
| 44 | + *) \ |
| 45 | +# we're on an architecture upstream doesn't officially build for |
| 46 | +# let's build binaries from the published source packages |
| 47 | + echo "deb-src [signed-by=$NGINX_GPGKEY_PATH] https://nginx.org/packages/debian/ bookworm nginx" >> /etc/apt/sources.list.d/nginx.list \ |
| 48 | + \ |
| 49 | +# new directory for storing sources and .deb files |
| 50 | + && tempDir="$(mktemp -d)" \ |
| 51 | + && chmod 777 "$tempDir" \ |
| 52 | +# (777 to ensure APT's "_apt" user can access it too) |
| 53 | + \ |
| 54 | +# save list of currently-installed packages so build dependencies can be cleanly removed later |
| 55 | + && savedAptMark="$(apt-mark showmanual)" \ |
| 56 | + \ |
| 57 | +# build .deb files from upstream's source packages (which are verified by apt-get) |
| 58 | + && apt-get update \ |
| 59 | + && apt-get build-dep -y nginx-module-otel \ |
| 60 | + && ( \ |
| 61 | + cd "$tempDir" \ |
| 62 | + && DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \ |
| 63 | + apt-get source --compile nginx-module-otel \ |
| 64 | + ) \ |
| 65 | +# we don't remove APT lists here because they get re-downloaded and removed later |
| 66 | + \ |
| 67 | +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies |
| 68 | +# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies) |
| 69 | + && apt-mark showmanual | xargs apt-mark auto > /dev/null \ |
| 70 | + && { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \ |
| 71 | + \ |
| 72 | +# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be) |
| 73 | + && ls -lAFh "$tempDir" \ |
| 74 | + && ( cd "$tempDir" && dpkg-scanpackages . > Packages ) \ |
| 75 | + && grep '^Package: ' "$tempDir/Packages" \ |
| 76 | + && echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list \ |
| 77 | +# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes") |
| 78 | +# Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied) |
| 79 | +# ... |
| 80 | +# 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) |
| 81 | + && apt-get -o Acquire::GzipIndexes=false update \ |
| 82 | + ;; \ |
| 83 | + esac \ |
| 84 | + \ |
| 85 | + && apt-get install --no-install-recommends --no-install-suggests -y \ |
| 86 | + $nginxPackages \ |
| 87 | + gettext-base \ |
| 88 | + curl \ |
| 89 | + && apt-get remove --purge --auto-remove -y && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx.list \ |
| 90 | + \ |
| 91 | +# if we have leftovers from building, let's purge them (including extra, unnecessary build deps) |
| 92 | + && if [ -n "$tempDir" ]; then \ |
| 93 | + apt-get purge -y --auto-remove \ |
| 94 | + && rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \ |
| 95 | + fi |
0 commit comments