From 171b55c05f1ff25ad2862750fef835b6aa37662b Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sun, 11 Jul 2021 01:46:35 +0800 Subject: [PATCH] refactor: compile gnu-libiconv locally --- Dockerfile | 12 +++++++++--- conf/docker/iconv.sh | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 conf/docker/iconv.sh diff --git a/Dockerfile b/Dockerfile index 00a66e2..6884b8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,16 @@ +FROM alpine as iconv +COPY ./conf/docker/iconv.sh / +RUN sh /iconv.sh + FROM alpine LABEL maintainer="dnomd343" COPY . /var/www/echoIP -ADD ./conf/docker/init.sh / -ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php -RUN apk --update add --no-cache nginx curl nodejs php7 php7-fpm php7-json php7-iconv php7-sqlite3 php7-openssl php7-mbstring gnu-libiconv && \ +COPY --from=iconv /tmp/iconv/ /usr/local/lib/ +RUN apk --update add --no-cache nginx curl nodejs php7 php7-fpm php7-json php7-iconv php7-sqlite3 php7-openssl php7-mbstring && \ + rm /usr/lib/php7/modules/iconv.so && ln -s /usr/local/lib/iconv.so /usr/lib/php7/modules/ && \ + mv /usr/local/lib/libiconv.so /usr/local/lib/libiconv.so.2 && \ mkdir -p /run/nginx && touch /run/nginx/nginx.pid && \ + cp /var/www/echoIP/conf/docker/init.sh / && \ cp /var/www/echoIP/conf/docker/ip.conf /etc/nginx/echoip.conf && \ cp -f /var/www/echoIP/conf/docker/nginx.conf /etc/nginx/nginx.conf && \ cp /var/www/echoIP/conf/docker/init.sh / && \ diff --git a/conf/docker/iconv.sh b/conf/docker/iconv.sh new file mode 100644 index 0000000..ec7ea0c --- /dev/null +++ b/conf/docker/iconv.sh @@ -0,0 +1,22 @@ +apk add --update wget php7 php7-dev build-base autoconf re2c libtool +mkdir -p /tmp + +wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz -O /tmp/libiconv.tar.gz +tar xf /tmp/libiconv.tar.gz -C /tmp +cd /tmp/libiconv-1.16/ +sed -i 's/_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");/#if HAVE_RAW_DECL_GETS\n_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");\n#endif/g' srclib/stdio.in.h +./configure --prefix=/usr/local +make && make install + +php_version=`php -r "phpinfo();" | grep "PHP Version" | head -1` +php_version=${php_version#*=> } +wget http://php.net/distributions/php-$php_version.tar.gz -O /tmp/php.tar.gz +tar xf /tmp/php.tar.gz -C /tmp +cd /tmp/php-$php_version/ext/iconv +phpize +./configure --with-iconv=/usr/local +make && make install + +mkdir /tmp/iconv +cp /usr/local/lib/libiconv.so /tmp/iconv +cp /usr/lib/php7/modules/iconv.so /tmp/iconv