【Dockerfile】CentOS7 + Apache + PHP7(Xdebug) + Redis + mysql

CentOS7にPHP7のLAMPを構築するためのDockerfileです。
利用方法、Dockerfile一式は後日公開します。

```:Dockerfile
#------------------------------------------------------------
#
#  用途: 開発環境の基礎構成
#  構成: CentOS7 + Apache + PHP7(Xdebug) + Redis + mysql
#
# @version    0.0
# @author     Maemori Fumihiro
#

#------------------------------------------------------------
# FROM
FROM centos:7

#------------------------------------------------------------
MAINTAINER Maemori Fumihiro

#------------------------------------------------------------
# Update
RUN yum update -y

#------------------------------------------------------------
# 基本ソフトウェア
RUN yum install -y tar gcc gcc-c++ libaio libaio-devel passwd wget ntp openssl  mod_ssl openssh-server openssl-devel libssl-dev

#------------------------------------------------------------
# 日本語化
RUN yum -y groupinstall "Japanese Support"
RUN echo "LANG=\"ja_JP.UTF-8\"" > /etc/sysconfig/i18n
RUN source /etc/sysconfig/i18n

#------------------------------------------------------------
# Httpd
RUN yum install -y httpd

#------------------------------------------------------------
# Redis
## Install file
ENV REDIS="redis-2.8.12"
## Radis install
RUN cd /usr/local/src && wget http://download.redis.io/releases/$REDIS.tar.gz
RUN cd /usr/local/src && tar xzf $REDIS.tar.gz
RUN cd /usr/local/src/$REDIS && make && make install
RUN cd /usr/local/src/$REDIS/utils && ./install_server.sh

#------------------------------------------------------------
# MySQL
## Install
RUN yum install -y http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
RUN yum install -y mysql-client mysql-server mysql-devel
## Configuration
ADD conf/my.cnf /etc/my.cnf
RUN touch /etc/sysconfig/network #This file is needed in /etc/init.d/mysqld
RUN mysql_install_db
RUN chown -R mysql:mysql /var/lib/mysql
RUN chmod 664 /etc/my.cnf
RUN mkdir /var/log/mysql
RUN chown -R mysql:mysql /var/log/mysql
RUN chmod 664 /var/log/mysql

#------------------------------------------------------------
# Ntp
RUN cp -p /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

#------------------------------------------------------------
# Server certs
RUN mkdir -p /etc/httpd/certs
RUN openssl genrsa -out /etc/httpd/certs/server.key 4096
RUN openssl req -new -batch -key /etc/httpd/certs/server.key -out /etc/httpd/certs/server.csr
RUN openssl x509 -req -days 3650 -in /etc/httpd/certs/server.csr -signkey /etc/httpd/certs/server.key -out /etc/httpd/certs/server.crt

#------------------------------------------------------------
# PHP7
## make install
RUN yum -y install httpd-devel gd-devel t1lib-devel
RUN yum -y install bzip2-devel curl-devel gmp-devel aspell-devel recode-devel
RUN yum -y install icu libicu-devel
RUN yum -y install tokyocabinet-devel
RUN yum -y install enchant-devel libc-client-devel firebird-devel unixODBC-devel freetds-devel postgresql-devel libedit-devel net-snmp-devel libtidy-devel
RUN yum -y install libxml2-devel libxslt-devel
### libmcrypt install
RUN cd /usr/local/src && wget http://dl.fedoraproject.org/pub/epel/6/x86_64/libmcrypt-2.5.8-9.el6.x86_64.rpm
RUN cd /usr/local/src && wget http://dl.fedoraproject.org/pub/epel/6/x86_64/libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
RUN cd /usr/local/src && yum localinstall -y libmcrypt-2.5.8-9.el6.x86_64.rpm libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
### bison install
RUN cd /usr/local/src && wget http://ftp.gnu.org/gnu/bison/bison-2.7.tar.gz
RUN cd /usr/local/src && tar zxvf bison-2.7.tar.gz
RUN cd /usr/local/src/bison-2.7 && ./configure && make && make install
### re2c install
RUN cd /usr/local/src && wget https://github.com/skvadrik/re2c/releases/download/0.14.3/re2c-0.14.3.tar.gz
RUN cd /usr/local/src && tar zxvf re2c-0.14.3.tar.gz
RUN cd /usr/local/src/re2c-0.14.3 && ./configure && make && make install
### php7 install
ENV PHP7="php-7.0.0"
RUN wget http://jp2.php.net/get/$PHP7.tar.gz/from/this/mirror -O /usr/local/src/$PHP7.tar.gz
RUN cd /usr/local/src && tar zxvf $PHP7.tar.gz
RUN cd /usr/local/src/$PHP7 && ./buildconf --force
RUN cd /usr/local/src/$PHP7 && ./configure \
    --prefix=/usr \
    --with-libdir=lib64 \
    --sysconfdir=/etc \
    --with-config-file-path=/etc \
    --with-config-file-scan-dir=/etc/php.d \
    --enable-mbstring \
    --enable-zip \
    --enable-bcmath \
    --enable-pcntl \
    --enable-ftp \
    --enable-exif \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    --enable-gd-native-ttf \
    --enable-gd-jis-conv \
    --enable-sockets \
    --enable-mysqlnd \
    --enable-soap \
    --enable-shmop \
    --enable-intl \
    --with-curl \
    --with-mcrypt \
    --with-iconv \
    --with-gmp \
    --with-pspell \
    --with-gd \
    --with-jpeg-dir=/usr \
    --with-png-dir=/usr \
    --with-zlib-dir=/usr \
    --with-xpm-dir=/usr \
    --with-freetype-dir=/usr \
    --with-openssl \
    --with-mysqli=shared,mysqlnd \
    --with-mysql-sock=/var/lib/mysql/mysql.sock \
    --with-pdo-mysql=shared,mysqlnd \
    --with-gettext=/usr \
    --with-zlib=/usr \
    --with-bz2=/usr \
    --with-kerberos \
    --with-libxml-dir=/usr \
    --with-mhash=/usr \
    --with-imap=shared \
    --with-imap-ssl \
    --with-xmlrpc=shared \
    --with-snmp=shared,/usr \
    --with-xsl=shared,/usr \
    --with-libedit \
    --with-tidy=shared,/usr \
    --with-icu-dir=/usr \
    --with-apxs2=/usr/sbin/apxs
RUN cd /usr/local/src/$PHP7 && make && make test && make install
### xdebug install
RUN cd /usr/local/src && wget http://xdebug.org/files/xdebug-2.4.0rc2.tgz
RUN cd /usr/local/src && tar zxvf xdebug-2.4.0rc2.tgz
RUN cd /usr/local/src/xdebug-2.4.0RC2 && phpize
RUN cd /usr/local/src/xdebug-2.4.0RC2 && ./configure && make && make install
### redis install
RUN cd /usr/local/src && git clone -b php7 --depth 1 https://github.com/phpredis/phpredis
RUN cd /usr/local/src/phpredis && phpize
RUN cd /usr/local/src/phpredis && ./configure && make && make install

#------------------------------------------------------------
# 後処理
## 不要なカーネルの削除
RUN yum install -y yum-utils
RUN package-cleanup --oldkernels --count=1

#------------------------------------------------------------
# COMMON Configuration
RUN mkdir /develop
## httpd
ADD conf/httpd.conf /etc/httpd/conf/httpd.conf
ADD conf/php.conf /etc/httpd/conf.d/php.conf
## php
ADD conf/php.ini /etc/php.ini
ADD conf/xdebug.ini /etc/php.d/xdebug.ini
ADD conf/opcache.ini /etc/php.d/opcache.ini
ADD conf/pdo_mysqlnd.ini /etc/php.d/pdo_mysqlnd.ini
ADD conf/redis.ini /etc/php.d/redis.ini
ADD module/phpinfo.php /var/www/html/phpinfo.php
RUN ls -la /etc/php.d/
## MySQL
RUN sed -i -e "s/sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES/# sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES/" /usr/my.cnf

#------------------------------------------------------------
# 起動用ファイルの設置
ADD script/run.sh /etc/service/run
RUN chmod +x /etc/service/run

#------------------------------------------------------------
# 起動
CMD ["/etc/service/run"]

```