xref: /unit/pkg/docker/template.Dockerfile (revision 1783)
1*1783Sthresh@videolan.orgFROM @@CONTAINER@@ as BUILDER
2*1783Sthresh@videolan.org
3*1783Sthresh@videolan.orgLABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>"
4*1783Sthresh@videolan.org
5*1783Sthresh@videolan.orgRUN set -ex \
6*1783Sthresh@videolan.org    && apt-get update \
7*1783Sthresh@videolan.org    && apt-get install --no-install-recommends --no-install-suggests -y ca-certificates mercurial build-essential libssl-dev libpcre2-dev \
8*1783Sthresh@videolan.org    && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \
9*1783Sthresh@videolan.org    && hg clone https://hg.nginx.org/unit \
10*1783Sthresh@videolan.org    && cd unit \
11*1783Sthresh@videolan.org    && hg up @@VERSION@@ \
12*1783Sthresh@videolan.org    && NCPU="$(getconf _NPROCESSORS_ONLN)" \
13*1783Sthresh@videolan.org    && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \
14*1783Sthresh@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)" \
15*1783Sthresh@videolan.org    && LD_OPT="$(DEB_BUILD_MAINT_OPTIONS="hardening=+all,-pie" DEB_LDFLAGS_MAINT_APPEND="-Wl,--as-needed -pie" dpkg-buildflags --get LDFLAGS)" \
16*1783Sthresh@videolan.org    && CONFIGURE_ARGS="--prefix=/usr \
17*1783Sthresh@videolan.org                --state=/var/lib/unit \
18*1783Sthresh@videolan.org                --control=unix:/var/run/control.unit.sock \
19*1783Sthresh@videolan.org                --pid=/var/run/unit.pid \
20*1783Sthresh@videolan.org                --log=/var/log/unit.log \
21*1783Sthresh@videolan.org                --tmp=/var/tmp \
22*1783Sthresh@videolan.org                --user=unit \
23*1783Sthresh@videolan.org                --group=unit \
24*1783Sthresh@videolan.org                --openssl \
25*1783Sthresh@videolan.org                --libdir=/usr/lib/$DEB_HOST_MULTIARCH" \
26*1783Sthresh@videolan.org    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --ld-opt="$LD_OPT" --modules=/usr/lib/unit/debug-modules --debug \
27*1783Sthresh@videolan.org    && make -j $NCPU unitd \
28*1783Sthresh@videolan.org    && install -pm755 build/unitd /usr/sbin/unitd-debug \
29*1783Sthresh@videolan.org    && make clean \
30*1783Sthresh@videolan.org    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --ld-opt="$LD_OPT" --modules=/usr/lib/unit/modules \
31*1783Sthresh@videolan.org    && make -j $NCPU unitd \
32*1783Sthresh@videolan.org    && install -pm755 build/unitd /usr/sbin/unitd \
33*1783Sthresh@videolan.org    && make clean \
34*1783Sthresh@videolan.org    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --modules=/usr/lib/unit/debug-modules --debug \
35*1783Sthresh@videolan.org    && ./configure @@CONFIGURE@@ \
36*1783Sthresh@videolan.org    && make -j $NCPU @@INSTALL@@ \
37*1783Sthresh@videolan.org    && make clean \
38*1783Sthresh@videolan.org    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --modules=/usr/lib/unit/modules \
39*1783Sthresh@videolan.org    && ./configure @@CONFIGURE@@ \
40*1783Sthresh@videolan.org    && make -j $NCPU @@INSTALL@@ \
41*1783Sthresh@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
42*1783Sthresh@videolan.org
43*1783Sthresh@videolan.orgFROM @@CONTAINER@@
44*1783Sthresh@videolan.orgCOPY docker-entrypoint.sh /usr/local/bin/
45*1783Sthresh@videolan.orgCOPY --from=BUILDER /usr/sbin/unitd /usr/sbin/unitd
46*1783Sthresh@videolan.orgCOPY --from=BUILDER /usr/sbin/unitd-debug /usr/sbin/unitd-debug
47*1783Sthresh@videolan.orgCOPY --from=BUILDER /usr/lib/unit/ /usr/lib/unit/
48*1783Sthresh@videolan.orgCOPY --from=BUILDER /requirements.apt /requirements.apt
49*1783Sthresh@videolan.org@@COPY@@
50*1783Sthresh@videolan.orgRUN set -x \
51*1783Sthresh@videolan.org    && mkdir -p /var/lib/unit/ \
52*1783Sthresh@videolan.org    && mkdir /docker-entrypoint.d/ \
53*1783Sthresh@videolan.org    && addgroup --system unit \
54*1783Sthresh@videolan.org    && adduser \
55*1783Sthresh@videolan.org         --system \
56*1783Sthresh@videolan.org         --disabled-login \
57*1783Sthresh@videolan.org         --ingroup unit \
58*1783Sthresh@videolan.org         --no-create-home \
59*1783Sthresh@videolan.org         --home /nonexistent \
60*1783Sthresh@videolan.org         --gecos "unit user" \
61*1783Sthresh@videolan.org         --shell /bin/false \
62*1783Sthresh@videolan.org         unit \
63*1783Sthresh@videolan.org    && apt update \
64*1783Sthresh@videolan.org    && apt --no-install-recommends --no-install-suggests -y install $(cat /requirements.apt) \
65*1783Sthresh@videolan.org    && apt-get clean && rm -rf /var/lib/apt/lists/* \
66*1783Sthresh@videolan.org    && rm -f /requirements.apt \
67*1783Sthresh@videolan.org    && ln -sf /dev/stdout /var/log/unit.log
68*1783Sthresh@videolan.org
69*1783Sthresh@videolan.orgSTOPSIGNAL SIGTERM
70*1783Sthresh@videolan.org
71*1783Sthresh@videolan.orgENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
72*1783Sthresh@videolan.org
73*1783Sthresh@videolan.orgCMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"]
74