dokcerfile创建LNMP

FROM centos:7

MAINTAINER xuxin

安装sshd

RUN yum install passwd openssl openssh-server -y

RUN ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N ''&&ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''&&ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key -N ''

RUN sed -i "s/#UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g" /etc/ssh/sshd_config && sed -i "s/UsePAM.*/UsePAM no/g" /etc/ssh/sshd_config

RUN echo "root:qwe123"| chpasswd

ADD sshd.sh /opt/

RUN chmod 755 /opt/sshd.sh

安装php7.3

RUN yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel libzip gcc-c++

RUN yum -y install wget

RUN mkdir -p  /usr/soft

WORKDIR /usr/soft

RUN  wget https://www.php.net/distributions/php-7.3.5.tar.gz

RUN tar -zxvf php-7.3.5.tar.gz

RUN groupadd www

RUN  useradd -g www www

RUN  wget https://github.com/Kitware/CMake/releases/download/v3.14.3/cmake-3.14.3.tar.gz

RUN  tar -zxvf cmake-3.14.3.tar.gz

WORKDIR /usr/soft/cmake-3.14.3

RUN  ./bootstrap

RUN make&&make install

RUN yum remove libzip -y

ADD libzip-1.5.2.tar.gz  /usr/soft/

#WORKDIR /usr/soft

#ADD libzip-1.5.2.tar.gz  /usr/soft

#RUN wget  https://libzip.org/download/libzip-1.5.2.tar.gz

#RUN tar -zxvf libzip-1.5.2.tar.gz

WORKDIR /usr/soft/libzip-1.5.2

RUN mkdir -p build

WORKDIR /usr/soft/libzip-1.5.2/build

RUN cmake ..

RUN make && make install

RUN echo "/usr/local/lib64" >> /etc/ld.so.conf && echo "/usr/loca/lib" >> /etc/ld.so.conf && echo "/usr/lib" >>  /etc/ld.so.conf &&echo "/usr/lib64" >> /etc/ld.so.conf

RUN ldconfig -v

RUN mkdir -p /usr/local/php/conf && mkdir -p /usr/local/php/etc

WORKDIR /usr/soft/php-7.3.5

RUN ./configure \

--prefix=/usr/local/php\

--enable-fpm\

--with-fpm-user=www\

--with-fpm-group=www\

--with-config-file-path=/usr/local/php/conf\

--disable-rpath\

--enable-soap\

--with-libxml-dir\

--with-xmlrpc\

--with-openssl\

--with-mhash\

--with-pcre-regex\

--with-zlib\

--enable-bcmath\

--with-bz2\

--enable-calendar\

--with-curl\

--enable-exif\

--with-pcre-dir\

--enable-ftp\

--with-gd\

--with-openssl-dir\

--with-jpeg-dir\

--with-png-dir\

--with-zlib-dir\

--with-freetype-dir\

--enable-gd-jis-conv\

--with-gettext\

--with-gmp\

--with-mhash\

--enable-mbstring\

--with-onig\

--with-mysqli=mysqlnd\

--with-pdo-mysql=mysqlnd\

--with-zlib-dir\

--with-readline\

--enable-shmop\

--enable-sockets\

--enable-sysvmsg\

--enable-sysvsem \

--enable-sysvshm \

--enable-wddx\

--with-libxml-dir\

--with-xsl\

--enable-zip\

--with-pear

RUN make && make install

RUN echo "PATH=$PATH:/usr/local/php/bin" >> /etc/profile && echo "export PATH" >> /etc/profile

RUN source /etc/profile

RUN cp php.ini-production /usr/local/php/conf/php.ini && 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/bin

RUN touch /usr/local/php/etc/php-fpm.d/www.conf

RUN echo -e "[www]\nlisten = /var/run/www/php-cgi.sock\nlisten.mode = 0666\nuser = www\ngroup = www\npm = dynamic\npm.max_children = 128\npm.start_servers = 20\npm.min_spare_servers = 5\npm.max_spare_servers = 35\npm.max_requests = 10000\nrlimit_files = 1024\nslowlog = log/pool.log.slow" >> /usr/local/php/etc/php-fpm.d/www.conf

RUN mkdir /var/run/www && chown -R www:www /var/run/www

安装nginx

RUN yum -y update && yum -y install gcc gcc-c++ make zlib-devel pcre-devel openssl-devel

WORKDIR /usr/soft

ADD ["pcre-8.42.tar.gz","zlib-1.2.11.tar.gz","nginx-1.16.1.tar.gz","/usr/soft/"]

WORKDIR /usr/soft/pcre-8.42

RUN ./configure

RUN make && make install

WORKDIR /usr/soft/zlib-1.2.11

RUN ./configure

RUN make && make install

RUN mkdir -p /var/tmp/nginx

WORKDIR /usr/soft/nginx-1.16.1

RUN ./configure \

--prefix=/usr/local/nginx \

--sbin-path=/usr/local/nginx/sbin/nginx \

--conf-path=/usr/local/nginx/nginx.conf \

--pid-path=/usr/local/nginx/nginx.pid \

--user=www \

--group=www \

--with-http_ssl_module \

--with-http_flv_module \

--with-http_mp4_module  \

--with-http_stub_status_module \

--with-http_gzip_static_module \

--http-client-body-temp-path=/var/tmp/nginx/client/ \

--http-proxy-temp-path=/var/tmp/nginx/proxy/ \

--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \

--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \

--http-scgi-temp-path=/var/tmp/nginx/scgi \

--with-pcre=/usr/soft/pcre-8.42 \

--with-zlib=/usr/soft/zlib-1.2.11

RUN make && make install

ADD nginx.conf /usr/local/nginx/

安装mysql

RUN  mkdir -p /usr/local/mysql && mkdir -p /data/mysql/data

ADD  mysql-boost-5.7.25.tar.gz /usr/soft

ADD my.cnf /etc/

RUN yum install gcc gcc-c++ ncurses-devel perl cmake make autoconf -y

RUN groupadd mysql && useradd -r -g mysql mysql

RUN chown -R mysql:mysql /data/mysql

WORKDIR /usr/soft/mysql-5.7.25

RUN cmake -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=boost && make && make install

RUN chown -R  mysql:mysql /usr/local/mysql

WORKDIR /usr/local/mysql/bin

RUN ./mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data

WORKDIR /usr/local/mysql/support-files

RUN cp mysql.server /etc/init.d/mysqld

RUN echo "PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile

WORKDIR /

EXPOSE 80

EXPOSE 22

EXPOSE 3306

ENTRYPOINT /opt/sshd.sh

你可能感兴趣的:(dokcerfile创建LNMP)