xref: /unit/pkg/docker/Dockerfile.php8.1 (revision 2119)
12092Sthresh@nginx.comFROM php:8.1-cli as BUILDER
22092Sthresh@nginx.com
32092Sthresh@nginx.comLABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>"
42092Sthresh@nginx.com
52092Sthresh@nginx.comRUN set -ex \
62092Sthresh@nginx.com    && apt-get update \
72092Sthresh@nginx.com    && apt-get install --no-install-recommends --no-install-suggests -y ca-certificates mercurial build-essential libssl-dev libpcre2-dev \
82092Sthresh@nginx.com    && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \
92092Sthresh@nginx.com    && hg clone https://hg.nginx.org/unit \
102092Sthresh@nginx.com    && cd unit \
11*2119Szelenkov@nginx.com    && hg up 1.27.0 \
122092Sthresh@nginx.com    && NCPU="$(getconf _NPROCESSORS_ONLN)" \
132092Sthresh@nginx.com    && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \
142092Sthresh@nginx.com    && CC_OPT="$(DEB_BUILD_MAINT_OPTIONS="hardening=+all,-pie" DEB_CFLAGS_MAINT_APPEND="-Wp,-D_FORTIFY_SOURCE=2 -fPIC" dpkg-buildflags --get CFLAGS)" \
152092Sthresh@nginx.com    && LD_OPT="$(DEB_BUILD_MAINT_OPTIONS="hardening=+all,-pie" DEB_LDFLAGS_MAINT_APPEND="-Wl,--as-needed -pie" dpkg-buildflags --get LDFLAGS)" \
162092Sthresh@nginx.com    && CONFIGURE_ARGS="--prefix=/usr \
172092Sthresh@nginx.com                --state=/var/lib/unit \
182092Sthresh@nginx.com                --control=unix:/var/run/control.unit.sock \
192092Sthresh@nginx.com                --pid=/var/run/unit.pid \
202092Sthresh@nginx.com                --log=/var/log/unit.log \
212092Sthresh@nginx.com                --tmp=/var/tmp \
222092Sthresh@nginx.com                --user=unit \
232092Sthresh@nginx.com                --group=unit \
242092Sthresh@nginx.com                --openssl \
252092Sthresh@nginx.com                --libdir=/usr/lib/$DEB_HOST_MULTIARCH" \
262092Sthresh@nginx.com    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --ld-opt="$LD_OPT" --modules=/usr/lib/unit/debug-modules --debug \
272092Sthresh@nginx.com    && make -j $NCPU unitd \
282092Sthresh@nginx.com    && install -pm755 build/unitd /usr/sbin/unitd-debug \
292092Sthresh@nginx.com    && make clean \
302092Sthresh@nginx.com    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --ld-opt="$LD_OPT" --modules=/usr/lib/unit/modules \
312092Sthresh@nginx.com    && make -j $NCPU unitd \
322092Sthresh@nginx.com    && install -pm755 build/unitd /usr/sbin/unitd \
332092Sthresh@nginx.com    && make clean \
342092Sthresh@nginx.com    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --modules=/usr/lib/unit/debug-modules --debug \
352092Sthresh@nginx.com    && ./configure php \
362092Sthresh@nginx.com    && make -j $NCPU php-install \
372092Sthresh@nginx.com    && make clean \
382092Sthresh@nginx.com    && ./configure $CONFIGURE_ARGS --cc-opt="$CC_OPT" --modules=/usr/lib/unit/modules \
392092Sthresh@nginx.com    && ./configure php \
402092Sthresh@nginx.com    && make -j $NCPU php-install \
412092Sthresh@nginx.com    && ldd /usr/sbin/unitd | awk '/=>/{print $(NF-1)}' | while read n; do dpkg-query -S $n; done | sed 's/^\([^:]\+\):.*$/\1/' | sort | uniq > /requirements.apt
422092Sthresh@nginx.com
432092Sthresh@nginx.comFROM php:8.1-cli
442092Sthresh@nginx.comCOPY docker-entrypoint.sh /usr/local/bin/
452092Sthresh@nginx.comCOPY --from=BUILDER /usr/sbin/unitd /usr/sbin/unitd
462092Sthresh@nginx.comCOPY --from=BUILDER /usr/sbin/unitd-debug /usr/sbin/unitd-debug
472092Sthresh@nginx.comCOPY --from=BUILDER /usr/lib/unit/ /usr/lib/unit/
482092Sthresh@nginx.comCOPY --from=BUILDER /requirements.apt /requirements.apt
492092Sthresh@nginx.comRUN ldconfig
502092Sthresh@nginx.comRUN set -x \
512092Sthresh@nginx.com    && if [ -f "/tmp/libunit.a" ]; then \
522092Sthresh@nginx.com        mv /tmp/libunit.a /usr/lib/$(dpkg-architecture -q DEB_HOST_MULTIARCH)/libunit.a; \
532092Sthresh@nginx.com        rm -f /tmp/libunit.a; \
542092Sthresh@nginx.com    fi \
552092Sthresh@nginx.com    && mkdir -p /var/lib/unit/ \
562092Sthresh@nginx.com    && mkdir /docker-entrypoint.d/ \
572092Sthresh@nginx.com    && addgroup --system unit \
582092Sthresh@nginx.com    && adduser \
592092Sthresh@nginx.com         --system \
602092Sthresh@nginx.com         --disabled-login \
612092Sthresh@nginx.com         --ingroup unit \
622092Sthresh@nginx.com         --no-create-home \
632092Sthresh@nginx.com         --home /nonexistent \
642092Sthresh@nginx.com         --gecos "unit user" \
652092Sthresh@nginx.com         --shell /bin/false \
662092Sthresh@nginx.com         unit \
672092Sthresh@nginx.com    && apt update \
682092Sthresh@nginx.com    && apt --no-install-recommends --no-install-suggests -y install curl $(cat /requirements.apt) \
692092Sthresh@nginx.com    && apt-get clean && rm -rf /var/lib/apt/lists/* \
702092Sthresh@nginx.com    && rm -f /requirements.apt \
712092Sthresh@nginx.com    && ln -sf /dev/stdout /var/log/unit.log
722092Sthresh@nginx.com
732092Sthresh@nginx.comSTOPSIGNAL SIGTERM
742092Sthresh@nginx.com
752092Sthresh@nginx.comENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
762092Sthresh@nginx.com
772092Sthresh@nginx.comCMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"]
78