1FROM debian:buster-slim 2 3LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" 4 5ENV UNIT_VERSION 1.19.0-1~buster 6 7RUN set -x \ 8 && apt-get update \ 9 && apt-get install --no-install-recommends --no-install-suggests -y gnupg1 apt-transport-https ca-certificates \ 10 && \ 11 NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \ 12 found=''; \ 13 for server in \ 14 ha.pool.sks-keyservers.net \ 15 hkp://keyserver.ubuntu.com:80 \ 16 hkp://p80.pool.sks-keyservers.net:80 \ 17 pgp.mit.edu \ 18 ; do \ 19 echo "Fetching GPG key $NGINX_GPGKEY from $server"; \ 20 apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \ 21 done; \ 22 test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \ 23 apt-get remove --purge --auto-remove -y gnupg1 && rm -rf /var/lib/apt/lists/* \ 24# work-around debian bug 863199 25 && mkdir -p /usr/share/man/man1 \ 26 && dpkgArch="$(dpkg --print-architecture)" \ 27 && unitPackages="unit=${UNIT_VERSION}" \ 28 && case "$dpkgArch" in \ 29 amd64|i386) \ 30# arches officialy built by upstream 31 echo "deb https://packages.nginx.org/unit/debian/ buster unit" >> /etc/apt/sources.list.d/unit.list \ 32 && apt-get update \ 33 ;; \ 34 *) \ 35# we're on an architecture upstream doesn't officially build for 36# let's build binaries from the published source packages 37 echo "deb-src https://packages.nginx.org/unit/debian/ buster unit" >> /etc/apt/sources.list.d/unit.list \ 38 \ 39# new directory for storing sources and .deb files 40 && tempDir="$(mktemp -d)" \ 41 && chmod 777 "$tempDir" \ 42# (777 to ensure APT's "_apt" user can access it too) 43 \ 44# save list of currently-installed packages so build dependencies can be cleanly removed later 45 && savedAptMark="$(apt-mark showmanual)" \ 46 \ 47# build .deb files from upstream's source packages (which are verified by apt-get) 48 && apt-get update \ 49 && apt-get build-dep -y $unitPackages \ 50 && ( \ 51 cd "$tempDir" \ 52 && DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \ 53 apt-get source --compile $unitPackages \ 54 ) \ 55# we don't remove APT lists here because they get re-downloaded and removed later 56 \ 57# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies 58# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies) 59 && apt-mark showmanual | xargs apt-mark auto > /dev/null \ 60 && { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \ 61 \ 62# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be) 63 && ls -lAFh "$tempDir" \ 64 && ( cd "$tempDir" && dpkg-scanpackages . > Packages ) \ 65 && grep '^Package: ' "$tempDir/Packages" \ 66 && echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list \ 67# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes") 68# Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied) 69# ... 70# 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) 71 && apt-get -o Acquire::GzipIndexes=false update \ 72 ;; \ 73 esac \ 74 \ 75 && apt-get install --no-install-recommends --no-install-suggests -y \ 76 $unitPackages \ 77 curl \ 78 && apt-get remove --purge --auto-remove -y apt-transport-https && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/unit.list \ 79 \ 80# if we have leftovers from building, let's purge them (including extra, unnecessary build deps) 81 && if [ -n "$tempDir" ]; then \ 82 apt-get purge -y --auto-remove \ 83 && rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \ 84 fi 85 86# forward log to docker log collector 87RUN ln -sf /dev/stdout /var/log/unit.log 88 89STOPSIGNAL SIGTERM 90 91COPY docker-entrypoint.sh /usr/local/bin/ 92RUN mkdir /docker-entrypoint.d/ 93ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] 94 95CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] 96