1FROM debian:buster-slim
| 1FROM openjdk:11-jdk as BUILDER
|
2 3LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" 4
| 2 3LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" 4
|
5ENV UNIT_VERSION 1.21.0-1~buster
| 5RUN set -ex \ 6 && apt-get update \ 7 && apt-get install --no-install-recommends --no-install-suggests -y ca-certificates mercurial build-essential libssl-dev libpcre2-dev \ 8 && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \ 9 && hg clone https://hg.nginx.org/unit \ 10 && cd unit \ 11 && hg up 1.21.0 \ 12 && NCPU="$(getconf _NPROCESSORS_ONLN)" \ 13 && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \ 14 && CC_OPT="$(DEB_BUILD_MAINT_OPTIONS="hardening=+all,-pie" DEB_CFLAGS_MAINT_APPEND="-Wp,-D_FORTIFY_SOURCE=2 -fPIC" dpkg-buildflags --get CFLAGS)" \ 15 && LD_OPT="$(DEB_BUILD_MAINT_OPTIONS="hardening=+all,-pie" DEB_LDFLAGS_MAINT_APPEND="-Wl,--as-needed -pie" dpkg-buildflags --get LDFLAGS)" \ 16 && CONFIGURE_ARGS="--prefix=/usr \ 17 --state=/var/lib/unit \ 18 --control=unix:/var/run/control.unit.sock \ 19 --pid=/var/run/unit.pid \ 20 --log=/var/log/unit.log \ 21 --tmp=/var/tmp \ 22 --user=unit \ 23 --group=unit \ 24 --openssl \ 25 --libdir=/usr/lib/$DEB_HOST_MULTIARCH" \ 26 && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --ld-opt="$LD_OPT" --modules=/usr/lib/unit/debug-modules --debug \ 27 && make -j $NCPU unitd \ 28 && install -pm755 build/unitd /usr/sbin/unitd-debug \ 29 && make clean \ 30 && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --ld-opt="$LD_OPT" --modules=/usr/lib/unit/modules \ 31 && make -j $NCPU unitd \ 32 && install -pm755 build/unitd /usr/sbin/unitd \ 33 && make clean \ 34 && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --modules=/usr/lib/unit/debug-modules --debug \ 35 && ./configure java --jars=/usr/share/unit-jsc-common/ \ 36 && make -j $NCPU java-shared-install java-install \ 37 && make clean \ 38 && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --modules=/usr/lib/unit/modules \ 39 && ./configure java --jars=/usr/share/unit-jsc-common/ \ 40 && make -j $NCPU java-shared-install java-install \ 41 && ldd /usr/sbin/unitd | awk '/=>/{print $(NF-1)}' | while read n; do dpkg-query -S $n; done | sed 's/^\([^:]\+\):.*$/\1/' | sort | uniq > /requirements.apt
|
6
| 42
|
| 43FROM openjdk:11-jdk 44COPY docker-entrypoint.sh /usr/local/bin/ 45COPY --from=BUILDER /usr/sbin/unitd /usr/sbin/unitd 46COPY --from=BUILDER /usr/sbin/unitd-debug /usr/sbin/unitd-debug 47COPY --from=BUILDER /usr/lib/unit/ /usr/lib/unit/ 48COPY --from=BUILDER /requirements.apt /requirements.apt 49COPY --from=BUILDER /usr/share/unit-jsc-common/ /usr/share/unit-jsc-common/
|
7RUN set -x \
| 50RUN 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} unit-jsc11=${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
| 51 && mkdir -p /var/lib/unit/ \ 52 && mkdir /docker-entrypoint.d/ \ 53 && addgroup --system unit \ 54 && adduser \ 55 --system \ 56 --disabled-login \ 57 --ingroup unit \ 58 --no-create-home \ 59 --home /nonexistent \ 60 --gecos "unit user" \ 61 --shell /bin/false \ 62 unit \ 63 && apt update \ 64 && apt --no-install-recommends --no-install-suggests -y install $(cat /requirements.apt) \ 65 && apt-get clean && rm -rf /var/lib/apt/lists/* \ 66 && rm -f /requirements.apt \ 67 && ln -sf /dev/stdout /var/log/unit.log
|
85
| 68
|
86# forward log to docker log collector 87RUN ln -sf /dev/stdout /var/log/unit.log 88
| |
89STOPSIGNAL SIGTERM 90
| 69STOPSIGNAL SIGTERM 70
|
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"]
| 71ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] 72 73CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"]
|