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