#用centos7的镜像
FROM centos:7

#作者
MAINTAINER guigangljr@sina.com

#一些安装包,ADD与COPY区别在于前者解压到容器里面,后者只是单纯的cp
ADD  php-5.3.27.tar.gz  /root/
COPY oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm  /root/
COPY oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm  /root/
ADD  memcache-2.2.7.tgz  /root/
ADD  mongo-1.6.13.tgz  /root/
ADD  redis-3.1.1.tgz  /root/
ADD  ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz  /root/
ADD  PDO_OCI-1.0.tgz  /root/
ADD  oci8-1.4.5.tgz   /root/

#配置yum源
ADD http://mirrors.aliyun.com/repo/Centos-7.repo /etc/yum.repos.d/CentOS-Base.repo
ADD http://mirrors.aliyun.com/repo/epel-7.repo  /etc/yum.repos.d/epel.repo

#安装本次的环境
RUN yum repolist
RUN yum -y install make vim gcc gcc-c++  libaio cronie php php-mysql  gmp-devel bzip2  bzip2-devel  libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-deve  php-mcrypt  libmcrypt  libmcrypt-devel freetype-devel make autoconf libxslt libxslt-devel \
 && groupadd www && useradd -g www -s /sbin/nologin -M www


#工作目录
WORKDIR /root


#Compile php_5.3
RUN cd /root/php-5.3.27 \
 && ./configure --prefix=/usr/local/php --with-fpm-user=www --with-fpm-group=www  --with-config-file-path=/usr/local/php/etc --with-openssl --with-mhash --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-fpm --disable-fileinfo --without-gdbm --enable-pdo --with-openssl-dir --enable-tokenizer --enable-wddx --with-gettext --with-png-dir --with-zlib-dir --with-gd --enable-exif --with-gmp  --with-mcrypt --with-mysql=shared,mysqlnd --enable-gd-native-ttf --with-bz2  --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
 && make&&make install \
 && cp /root/php-5.3.27/php.ini-production /usr/local/php/etc/php.ini \
 && /root/php-5.3.27/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin \
 && ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar \
 && cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf \
 && ln -s /usr/local/php/sbin/php-fpm /usr/local/sbin/php-fpm \
 && cp /root/php-5.3.27/sapi/fpm/init.d.php-fpm  /etc/init.d/php-fpm \
 && chmod +x /etc/init.d/php-fpm
RUN rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm \
 && rpm -ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm \
 && echo '/usr/lib/oracle/11.2/client64/lib/' > /etc/ld.so.conf.d/oracle-x86_64.conf \
 && ln -s /usr/lib/oracle/11.2/client64 /usr/lib/oracle/11.2/client \
 && ln -s /usr/include/oracle/11.2/client64 /usr/include/oracle/11.2/client \
 && echo "export ORACLE_HOME=/usr/lib/oracle/11.2/client64/" >> /etc/profile \
 && echo "export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64:$LD_LIBRARY_PATH" >> /etc/profile \
 && echo "export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"" >> /etc/profile \
 && source /etc/profile \
 && cd /root/PDO_OCI-1.0 \
 && ln -s /usr/include/oracle/11.2 /usr/include/oracle/10.2.0.1 \
 && ln -s /usr/lib/oracle/11.2 /usr/lib/oracle/10.2.0.1 \
 && /usr/local/php/bin/phpize \
 && ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-oci=instantclient,/usr,10.2.0.1 \
 && make&&make install \
 && echo "extension_dir = /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/" >> /usr/local/php/etc/php.ini \
 && echo "extension = pdo_oci.so" >> /usr/local/php/etc/php.ini \
 && cd /root/oci8-1.4.5 \
 && /usr/local/php/bin/phpize \
 && ./configure --with-php-config=/usr/local/php/bin/php-config --with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client/lib \
 && make&&make install \
 && echo "extension = oci8.so" >> /usr/local/php/etc/php.ini \
 && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

RUN cd redis-3.1.1 \
 && /usr/local/php/bin/phpize \
 && ./configure --with-php-config=/usr/local/php/bin/php-config \
 && make&&make install \
 && echo "extension = redis.so" >> /usr/local/php/etc/php.ini

RUN cd memcache-2.2.7 \
 && /usr/local/php/bin/phpize \
 && ./configure --with-php-config=/usr/local/php/bin/php-config \
 &&  make&&make install \
 && echo "extension = memcache.so" >> /usr/local/php/etc/php.ini

RUN cd mongo-1.6.13 \
 && /usr/local/php/bin/phpize \
 && ./configure --with-php-config=/usr/local/php/bin/php-config \
 && make&&make install \
 && echo "extension = mongo.so" >> /usr/local/php/etc/php.ini

RUN cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /usr/local/php/lib/php \
 && echo "[Zend]" >> /usr/local/php/etc/php.ini \
 && echo "zend_extension=/usr/local/php/lib/php/ZendGuardLoader.so" >> /usr/local/php/etc/php.ini

RUN echo "/etc/init.d/php-fpm start" >> /root/start.sh \
 && chmod  +x /root/start.sh \
 && echo "bash /root/start.sh" >> /etc/rc.d/rc.local \
 && chmod +x /etc/rc.d/rc.local

#为了能让容器使用计划任务
RUN sed -i '/session    required   pam_loginuid.so/c\#session    required   pam_loginuid.so' /etc/pam.d/crond

#Exposing port
EXPOSE 80
EXPOSE 9000

CMD ["/usr/sbin/init"]
Last modification:April 20th, 2020 at 09:58 am
如果觉得我的文章对你有用,请随意赞赏