1509Sthresh@nginx.comFROM debian:stretch-slim 2509Sthresh@nginx.com 3509Sthresh@nginx.comLABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" 4509Sthresh@nginx.com 51186Svbart@nginx.comENV UNIT_VERSION 1.11.0-1~stretch 6509Sthresh@nginx.com 7509Sthresh@nginx.comRUN set -x \ 8509Sthresh@nginx.com && apt-get update \ 9509Sthresh@nginx.com && apt-get install --no-install-recommends --no-install-suggests -y gnupg1 apt-transport-https ca-certificates \ 10509Sthresh@nginx.com && \ 11509Sthresh@nginx.com NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \ 12509Sthresh@nginx.com found=''; \ 13509Sthresh@nginx.com for server in \ 14509Sthresh@nginx.com ha.pool.sks-keyservers.net \ 15509Sthresh@nginx.com hkp://keyserver.ubuntu.com:80 \ 16509Sthresh@nginx.com hkp://p80.pool.sks-keyservers.net:80 \ 17509Sthresh@nginx.com pgp.mit.edu \ 18509Sthresh@nginx.com ; do \ 19509Sthresh@nginx.com echo "Fetching GPG key $NGINX_GPGKEY from $server"; \ 20509Sthresh@nginx.com apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \ 21509Sthresh@nginx.com done; \ 22509Sthresh@nginx.com test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \ 23509Sthresh@nginx.com apt-get remove --purge --auto-remove -y gnupg1 && rm -rf /var/lib/apt/lists/* \ 24509Sthresh@nginx.com && dpkgArch="$(dpkg --print-architecture)" \ 25509Sthresh@nginx.com && unitPackages="unit=${UNIT_VERSION}" \ 26509Sthresh@nginx.com && case "$dpkgArch" in \ 27509Sthresh@nginx.com amd64|i386) \ 28509Sthresh@nginx.com# arches officialy built by upstream 29509Sthresh@nginx.com echo "deb https://packages.nginx.org/unit/debian/ stretch unit" >> /etc/apt/sources.list.d/unit.list \ 30509Sthresh@nginx.com && apt-get update \ 31509Sthresh@nginx.com ;; \ 32509Sthresh@nginx.com *) \ 33509Sthresh@nginx.com# we're on an architecture upstream doesn't officially build for 34509Sthresh@nginx.com# let's build binaries from the published source packages 35509Sthresh@nginx.com echo "deb-src https://packages.nginx.org/unit/debian/ stretch unit" >> /etc/apt/sources.list.d/unit.list \ 36509Sthresh@nginx.com \ 37509Sthresh@nginx.com# new directory for storing sources and .deb files 38509Sthresh@nginx.com && tempDir="$(mktemp -d)" \ 39509Sthresh@nginx.com && chmod 777 "$tempDir" \ 40509Sthresh@nginx.com# (777 to ensure APT's "_apt" user can access it too) 41509Sthresh@nginx.com \ 42509Sthresh@nginx.com# save list of currently-installed packages so build dependencies can be cleanly removed later 43509Sthresh@nginx.com && savedAptMark="$(apt-mark showmanual)" \ 44509Sthresh@nginx.com \ 45509Sthresh@nginx.com# build .deb files from upstream's source packages (which are verified by apt-get) 46509Sthresh@nginx.com && apt-get update \ 47509Sthresh@nginx.com && apt-get build-dep -y $unitPackages \ 48509Sthresh@nginx.com && ( \ 49509Sthresh@nginx.com cd "$tempDir" \ 50509Sthresh@nginx.com && DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \ 51509Sthresh@nginx.com apt-get source --compile $unitPackages \ 52509Sthresh@nginx.com ) \ 53509Sthresh@nginx.com# we don't remove APT lists here because they get re-downloaded and removed later 54509Sthresh@nginx.com \ 55509Sthresh@nginx.com# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies 56509Sthresh@nginx.com# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies) 57509Sthresh@nginx.com && apt-mark showmanual | xargs apt-mark auto > /dev/null \ 58509Sthresh@nginx.com && { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \ 59509Sthresh@nginx.com \ 60509Sthresh@nginx.com# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be) 61509Sthresh@nginx.com && ls -lAFh "$tempDir" \ 62509Sthresh@nginx.com && ( cd "$tempDir" && dpkg-scanpackages . > Packages ) \ 63509Sthresh@nginx.com && grep '^Package: ' "$tempDir/Packages" \ 64509Sthresh@nginx.com && echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list \ 65509Sthresh@nginx.com# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes") 66509Sthresh@nginx.com# Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied) 67509Sthresh@nginx.com# ... 68509Sthresh@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) 69509Sthresh@nginx.com && apt-get -o Acquire::GzipIndexes=false update \ 70509Sthresh@nginx.com ;; \ 71509Sthresh@nginx.com esac \ 72509Sthresh@nginx.com \ 73509Sthresh@nginx.com && apt-get install --no-install-recommends --no-install-suggests -y \ 74509Sthresh@nginx.com $unitPackages \ 75509Sthresh@nginx.com curl \ 76826Sdefan@nginx.com && apt-get remove --purge --auto-remove -y apt-transport-https && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/unit.list \ 77509Sthresh@nginx.com \ 78509Sthresh@nginx.com# if we have leftovers from building, let's purge them (including extra, unnecessary build deps) 79509Sthresh@nginx.com && if [ -n "$tempDir" ]; then \ 80509Sthresh@nginx.com apt-get purge -y --auto-remove \ 81509Sthresh@nginx.com && rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \ 82509Sthresh@nginx.com fi 83509Sthresh@nginx.com 84509Sthresh@nginx.com# forward log to docker log collector 85509Sthresh@nginx.comRUN ln -sf /dev/stdout /var/log/unit.log 86509Sthresh@nginx.com 87509Sthresh@nginx.comSTOPSIGNAL SIGTERM 88509Sthresh@nginx.com 89*1220Sthresh@nginx.comCOPY docker-entrypoint.sh /usr/local/bin/ 90*1220Sthresh@nginx.comRUN mkdir /docker-entrypoint.d/ 91*1220Sthresh@nginx.comENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] 92*1220Sthresh@nginx.com 93509Sthresh@nginx.comCMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] 94