Dockerfile 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. from alpine:latest
  2. # define script basic information
  3. # Version of this Dockerfile
  4. ENV SCRIPT_VERSION=1.3.0
  5. # Download address uses backup address
  6. # (if downloading slowly, consider set it to yes)
  7. ENV USE_BACKUP=no
  8. # Version of some manually-installed package
  9. ENV VER_PHP=7.4.19
  10. ENV VER_SWOOLE=4.6.7
  11. ENV VER_HASH=1.5
  12. ENV VER_INOTIFY=3.0.0
  13. ENV VER_REDIS=5.3.4
  14. ENV VER_LIBXML2=2.9.12
  15. ENV VER_CURL=7.77.0
  16. ENV VER_LIBLZMA=master
  17. # LINK_OF_ADDRESS_ORIGIN
  18. ENV LINK_APK_REPO='mirrors.ustc.edu.cn'
  19. ENV LINK_APK_REPO_BAK='dl-cdn.alpinelinux.org'
  20. RUN if [ "${USE_BACKUP}" = "yes" ]; then \
  21. echo "Using backup address..." && sleep 3s; \
  22. else \
  23. echo "Using original address..." && sleep 3s; \
  24. fi
  25. RUN sed -i 's/dl-cdn.alpinelinux.org/'${LINK_APK_REPO}'/g' /etc/apk/repositories
  26. # build requirements
  27. RUN apk add cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses
  28. # php zlib dependencies
  29. RUN apk add zlib-dev zlib-static
  30. # php mbstring dependencies
  31. RUN apk add oniguruma-dev
  32. # php openssl dependencies
  33. RUN apk add openssl-libs-static openssl-dev openssl
  34. # php gd dependencies
  35. RUN apk add libpng-dev libpng-static
  36. # curl c-ares dependencies
  37. RUN apk add c-ares-static c-ares-dev
  38. RUN mkdir /app
  39. WORKDIR /app
  40. COPY download.sh /app/
  41. COPY compile-php.sh /app/
  42. RUN chmod +x /app/download.sh && \
  43. chmod +x /app/compile-php.sh
  44. RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
  45. RUN ./download.sh hash ${USE_BACKUP} ${VER_HASH}
  46. RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
  47. RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
  48. RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
  49. RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
  50. RUN ./download.sh swoole ${USE_BACKUP} ${VER_SWOOLE}
  51. RUN wget "http://mirrors.zhamao.xin/php/php-${VER_PHP}.tar.gz" -O php.tar.gz
  52. RUN wget "http://mirrors.zhamao.xin/pecl/swoole-${VER_SWOOLE}.tgz" -O swoole.tar.gz
  53. RUN wget "http://mirrors.zhamao.xin/pecl/hash-${VER_HASH}.tgz" -O hash.tar.gz
  54. RUN wget "http://mirrors.zhamao.xin/pecl/inotify-${VER_INOTIFY}.tgz" -O inotify.tar.gz
  55. RUN wget "http://mirrors.zhamao.xin/pecl/redis-${VER_REDIS}.tgz" -O redis.tar.gz
  56. RUN wget "https://dl.zhamao.me/libxml2/libxml2-${VER_LIBXML2}.tar.gz" -O libxml2.tar.gz
  57. RUN wget "https://dl.zhamao.me/liblzma/liblzma.tar.gz"
  58. RUN wget "https://dl.zhamao.me/curl/curl-${VER_CURL}.tar.gz" -O curl.tar.gz
  59. RUN tar -xf php.tar.gz && \
  60. tar -xf swoole.tar.gz && \
  61. tar -xf hash.tar.gz && \
  62. tar -xf inotify.tar.gz && \
  63. tar -xf redis.tar.gz && \
  64. tar -xf libxml2.tar.gz && \
  65. tar -xf liblzma.tar.gz && \
  66. tar -xf curl.tar.gz
  67. RUN cd liblzma && \
  68. ./configure && \
  69. make -j4 && \
  70. make install && \
  71. echo "liblzma compiled!"
  72. RUN cd "libxml2-${VER_LIBXML2}" && \
  73. ./configure --with-lzma --without-python && \
  74. make -j4 && \
  75. make install && \
  76. echo "libxml2 compiled!"
  77. RUN cd "curl-${VER_CURL}" && \
  78. CC=gcc CXX=g++ CFLAGS=-fPIC CPPFLAGS=-fPIC ./configure \
  79. --without-nghttp2 \
  80. --with-ssl=/usr \
  81. --with-pic=pic \
  82. --enable-ipv6 \
  83. --enable-shared=no \
  84. --without-libidn2 \
  85. --disable-ldap \
  86. --without-libpsl \
  87. --without-lber \
  88. --enable-ares && \
  89. make -j4 && \
  90. make install && \
  91. echo "curl compiled!"
  92. COPY ac_override_1 /
  93. COPY ac_override_2 /
  94. COPY compile-php.sh /app/
  95. RUN apk add bash
  96. # copy
  97. RUN mv "swoole-${VER_SWOOLE}" "php-${VER_PHP}/ext/swoole" && \
  98. mv "redis-${VER_REDIS}" "php-${VER_PHP}/ext/redis" && \
  99. mv "inotify-${VER_INOTIFY}" "php-${VER_PHP}/ext/inotify"
  100. RUN cat /ac_override_1 /app/php-${VER_PHP}/ext/curl/config.m4 /ac_override_2 > /app/aa
  101. RUN mv /app/aa /app/php-${VER_PHP}/ext/curl/config.m4
  102. RUN cd "php-${VER_PHP}/ext/swoole/" && \
  103. ./clear.sh && \
  104. cd ../../ && \
  105. ./buildconf --force
  106. RUN ./compile-php.sh ${VER_PHP}
  107. RUN cd "php-${VER_PHP}" && \
  108. sed -ie 's/-export-dynamic//g' "Makefile" && \
  109. sed -ie 's/-o \$(SAPI_CLI_PATH)/-all-static -o \$(SAPI_CLI_PATH)/g' "Makefile" && \
  110. sed -ie 's/swoole_clock_gettime(CLOCK_REALTIME/clock_gettime(CLOCK_REALTIME/g' "ext/swoole/include/swoole.h" && \
  111. make LDFLAGS=-ldl -j4 && \
  112. make install && \
  113. strip