xref: /unit/pkg/docker/template.Dockerfile (revision 2397:817968931c58)
1FROM @@CONTAINER@@ as BUILDER
2
3LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>"
4
5RUN set -ex \
6    && savedAptMark="$(apt-mark showmanual)" \
7    && apt-get update \
8    && apt-get install --no-install-recommends --no-install-suggests -y ca-certificates mercurial build-essential libssl-dev libpcre2-dev \
9    && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \
10    && hg clone https://hg.nginx.org/unit \
11    && cd unit \
12    && hg up @@VERSION@@ \
13    && NCPU="$(getconf _NPROCESSORS_ONLN)" \
14    && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \
15    && CC_OPT="$(DEB_BUILD_MAINT_OPTIONS="hardening=+all,-pie" DEB_CFLAGS_MAINT_APPEND="-Wp,-D_FORTIFY_SOURCE=2 -fPIC" dpkg-buildflags --get CFLAGS)" \
16    && LD_OPT="$(DEB_BUILD_MAINT_OPTIONS="hardening=+all,-pie" DEB_LDFLAGS_MAINT_APPEND="-Wl,--as-needed -pie" dpkg-buildflags --get LDFLAGS)" \
17    && CONFIGURE_ARGS="--prefix=/usr \
18                --statedir=/var/lib/unit \
19                --control=unix:/var/run/control.unit.sock \
20                --pid=/var/run/unit.pid \
21                --log=/var/log/unit.log \
22                --tmpdir=/var/tmp \
23                --user=unit \
24                --group=unit \
25                --openssl \
26                --libdir=/usr/lib/$DEB_HOST_MULTIARCH" \
27    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --ld-opt="$LD_OPT" --modulesdir=/usr/lib/unit/debug-modules --debug \
28    && make -j $NCPU unitd \
29    && install -pm755 build/sbin/unitd /usr/sbin/unitd-debug \
30    && make clean \
31    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --ld-opt="$LD_OPT" --modulesdir=/usr/lib/unit/modules \
32    && make -j $NCPU unitd \
33    && install -pm755 build/sbin/unitd /usr/sbin/unitd \
34    && make clean \
35    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --modulesdir=/usr/lib/unit/debug-modules --debug \
36    && ./configure @@CONFIGURE@@ \
37    && make -j $NCPU @@INSTALL@@ \
38    && make clean \
39    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --modulesdir=/usr/lib/unit/modules \
40    && ./configure @@CONFIGURE@@ \
41    && make -j $NCPU @@INSTALL@@ \
42    && for f in /usr/sbin/unitd /usr/lib/unit/modules/*.unit.so; do \
43        ldd $f | awk '/=>/{print $(NF-1)}' | while read n; do dpkg-query -S $n; done | sed 's/^\([^:]\+\):.*$/\1/' | sort | uniq >> /requirements.apt; \
44       done \
45    && apt-mark showmanual | xargs apt-mark auto > /dev/null \
46    && { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \
47    && @@RUN@@ \
48    && mkdir -p /var/lib/unit/ \
49    && mkdir /docker-entrypoint.d/ \
50    && addgroup --system unit \
51    && adduser \
52         --system \
53         --disabled-login \
54         --ingroup unit \
55         --no-create-home \
56         --home /nonexistent \
57         --gecos "unit user" \
58         --shell /bin/false \
59         unit \
60    && apt-get update \
61    && apt-get --no-install-recommends --no-install-suggests -y install curl $(cat /requirements.apt) \
62    && apt-get purge -y --auto-remove \
63    && apt-get clean && rm -rf /var/lib/apt/lists/* \
64    && rm -f /requirements.apt \
65    && ln -sf /dev/stdout /var/log/unit.log
66
67COPY docker-entrypoint.sh /usr/local/bin/
68
69STOPSIGNAL SIGTERM
70
71ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
72
73CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"]
74