xref: /unit/pkg/docker/template.Dockerfile (revision 2056)
11783Sthresh@videolan.orgFROM @@CONTAINER@@ as BUILDER
21783Sthresh@videolan.org
31783Sthresh@videolan.orgLABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>"
41783Sthresh@videolan.org
51783Sthresh@videolan.orgRUN set -ex \
61783Sthresh@videolan.org    && apt-get update \
71783Sthresh@videolan.org    && apt-get install --no-install-recommends --no-install-suggests -y ca-certificates mercurial build-essential libssl-dev libpcre2-dev \
81783Sthresh@videolan.org    && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \
91783Sthresh@videolan.org    && hg clone https://hg.nginx.org/unit \
101783Sthresh@videolan.org    && cd unit \
111783Sthresh@videolan.org    && hg up @@VERSION@@ \
121783Sthresh@videolan.org    && NCPU="$(getconf _NPROCESSORS_ONLN)" \
131783Sthresh@videolan.org    && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \
141783Sthresh@videolan.org    && CC_OPT="$(DEB_BUILD_MAINT_OPTIONS="hardening=+all,-pie" DEB_CFLAGS_MAINT_APPEND="-Wp,-D_FORTIFY_SOURCE=2 -fPIC" dpkg-buildflags --get CFLAGS)" \
151783Sthresh@videolan.org    && LD_OPT="$(DEB_BUILD_MAINT_OPTIONS="hardening=+all,-pie" DEB_LDFLAGS_MAINT_APPEND="-Wl,--as-needed -pie" dpkg-buildflags --get LDFLAGS)" \
161783Sthresh@videolan.org    && CONFIGURE_ARGS="--prefix=/usr \
171783Sthresh@videolan.org                --state=/var/lib/unit \
181783Sthresh@videolan.org                --control=unix:/var/run/control.unit.sock \
191783Sthresh@videolan.org                --pid=/var/run/unit.pid \
201783Sthresh@videolan.org                --log=/var/log/unit.log \
211783Sthresh@videolan.org                --tmp=/var/tmp \
221783Sthresh@videolan.org                --user=unit \
231783Sthresh@videolan.org                --group=unit \
241783Sthresh@videolan.org                --openssl \
251783Sthresh@videolan.org                --libdir=/usr/lib/$DEB_HOST_MULTIARCH" \
261783Sthresh@videolan.org    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --ld-opt="$LD_OPT" --modules=/usr/lib/unit/debug-modules --debug \
271783Sthresh@videolan.org    && make -j $NCPU unitd \
281783Sthresh@videolan.org    && install -pm755 build/unitd /usr/sbin/unitd-debug \
291783Sthresh@videolan.org    && make clean \
301783Sthresh@videolan.org    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --ld-opt="$LD_OPT" --modules=/usr/lib/unit/modules \
311783Sthresh@videolan.org    && make -j $NCPU unitd \
321783Sthresh@videolan.org    && install -pm755 build/unitd /usr/sbin/unitd \
331783Sthresh@videolan.org    && make clean \
341783Sthresh@videolan.org    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --modules=/usr/lib/unit/debug-modules --debug \
351783Sthresh@videolan.org    && ./configure @@CONFIGURE@@ \
361783Sthresh@videolan.org    && make -j $NCPU @@INSTALL@@ \
371783Sthresh@videolan.org    && make clean \
381783Sthresh@videolan.org    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --modules=/usr/lib/unit/modules \
391783Sthresh@videolan.org    && ./configure @@CONFIGURE@@ \
401783Sthresh@videolan.org    && make -j $NCPU @@INSTALL@@ \
411783Sthresh@videolan.org    && ldd /usr/sbin/unitd | awk '/=>/{print $(NF-1)}' | while read n; do dpkg-query -S $n; done | sed 's/^\([^:]\+\):.*$/\1/' | sort | uniq > /requirements.apt
421783Sthresh@videolan.org
431783Sthresh@videolan.orgFROM @@CONTAINER@@
441783Sthresh@videolan.orgCOPY docker-entrypoint.sh /usr/local/bin/
451783Sthresh@videolan.orgCOPY --from=BUILDER /usr/sbin/unitd /usr/sbin/unitd
461783Sthresh@videolan.orgCOPY --from=BUILDER /usr/sbin/unitd-debug /usr/sbin/unitd-debug
471783Sthresh@videolan.orgCOPY --from=BUILDER /usr/lib/unit/ /usr/lib/unit/
481783Sthresh@videolan.orgCOPY --from=BUILDER /requirements.apt /requirements.apt
491783Sthresh@videolan.org@@COPY@@
501783Sthresh@videolan.orgRUN set -x \
51*2056Sthresh@nginx.com    && if [ -f "/tmp/libunit.a" ]; then \
52*2056Sthresh@nginx.com        mv /tmp/libunit.a /usr/lib/$(dpkg-architecture -q DEB_HOST_MULTIARCH)/libunit.a; \
53*2056Sthresh@nginx.com        rm -f /tmp/libunit.a; \
54*2056Sthresh@nginx.com    fi \
551783Sthresh@videolan.org    && mkdir -p /var/lib/unit/ \
561783Sthresh@videolan.org    && mkdir /docker-entrypoint.d/ \
571783Sthresh@videolan.org    && addgroup --system unit \
581783Sthresh@videolan.org    && adduser \
591783Sthresh@videolan.org         --system \
601783Sthresh@videolan.org         --disabled-login \
611783Sthresh@videolan.org         --ingroup unit \
621783Sthresh@videolan.org         --no-create-home \
631783Sthresh@videolan.org         --home /nonexistent \
641783Sthresh@videolan.org         --gecos "unit user" \
651783Sthresh@videolan.org         --shell /bin/false \
661783Sthresh@videolan.org         unit \
671783Sthresh@videolan.org    && apt update \
681801Sthresh@nginx.com    && apt --no-install-recommends --no-install-suggests -y install curl $(cat /requirements.apt) \
691783Sthresh@videolan.org    && apt-get clean && rm -rf /var/lib/apt/lists/* \
701783Sthresh@videolan.org    && rm -f /requirements.apt \
711783Sthresh@videolan.org    && ln -sf /dev/stdout /var/log/unit.log
721783Sthresh@videolan.org
731783Sthresh@videolan.orgSTOPSIGNAL SIGTERM
741783Sthresh@videolan.org
751783Sthresh@videolan.orgENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
761783Sthresh@videolan.org
771783Sthresh@videolan.orgCMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"]
78