alpine 构建nginx+php镜像

531 阅读1分钟

################################alphine nginx ######################

FROM alpine
WORKDIR /data/program/soft/ 
ENV PATH=$PATH:/data/program/php-7.3.9/bin
ENV PATH=$PATH:/data/program/soft/nginx-1.13.9/sbin

# 修改源
RUN echo "http://mirrors.aliyun.com/alpine/latest-stable/main/" > /etc/apk/repositories && \
    echo "http://mirrors.aliyun.com/alpine/latest-stable/community/" >> /etc/apk/repositories
RUN apk update && \
    apk add --no-cache ca-certificates && \
    apk add --no-cache curl bash tree tzdata && \
    cp -rf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
COPY nginx ./
RUN  CONFIG="--user=www \
    --group=www \
    --prefix=/data/program/nginx-1.13.9 \
   " \ 
   && addgroup -S www \
   && adduser -D -S   -s /sbin/nologin -G www www \
   && apk add  \
        g++  \
        libffi-dev\
        libtool \
        supervisor \
        imagemagick \
        imagemagick-dev \
        autoconf \
        gcc \
        libc-dev \
        make \
        openssl-dev \
        pcre \
        pcre-dev \
        zlib-dev \
        linux-headers \
        curl \
        gnupg \
        libxslt-dev \
        gd-dev \
        geoip-dev \
        curl-dev \
        jpeg-dev \
        libpng \
        libpng-dev \
        freetype \
        freetype-dev \
        gettext \
        gettext-dev \
        glib-dev \
        libzip \
        libzip-dev \
   && tar zxC /data/program/soft/ -f /data/program/soft/nginx-1.13.9.tar.gz \
   && cd  /data/program/soft/nginx-1.13.9 \ 
   && ./configure $CONFIG \
   && sed -i 's/-Werror//' /data/program/soft/nginx-1.13.9/objs/Makefile \
   && make -j$(getconf _NPROCESSORS_ONLN) \
   && make install 

########################################alphine php######################

COPY php ./
COPY supervisord.conf /etc/supervisord.conf
RUN tar zxC /data/program/soft/ -f /data/program/soft/php-7.3.9.tar.gz \
    && cd  /data/program/soft/php-7.3.9 \ 
    && ./configure  \
        --prefix=/data/program/php-7.3.9 \
        --with-config-file-path=/data/program/php-7.3.9/etc \
        --with-mysqli=mysqlnd \
        --enable-mysqlnd \
        --with-pdo-mysql=mysqlnd \
        --enable-pcntl \ 
        --with-iconv \ 
        --with-gd \ 
        --with-freetype-dir \ 
        --with-jpeg-dir \ 
        --with-png-dir \ 
        --enable-opcache \ 
        --enable-zip \ 
        --enable-soap \
        --enable-mbstring \ 
        --with-openssl \ 
        --with-curl \
        --with-zlib \
        --with-gettext \  
        -with-xsl \
        --enable-xml \
        --enable-bcmath \ 
        --enable-shmop \
        --enable-sysvsem \
        --enable-sysvshm \
        --enable-inline-optimization \
        --enable-mbregex \ 
        --with-mhash \
        --enable-sockets \
        --with-xmlrpc \
        --enable-exif \
        --enable-fpm \
        --enable-pdo \
        --enable-libxml \
        --disable-ipv6 \
        --disable-rpath \
        --disable-debug \
        --without-pear  \
    && make \
    && make install  \
    && mv  /data/program/soft/etc/php-fpm.conf  /data/program/php-7.3.9/etc/php-fpm.conf \
    && mv  /data/program/soft/etc/php-fpm.d/www.conf   /data/program/php-7.3.9/etc/php-fpm.d/www.conf \
    && mv  /data/program/soft/etc/php.ini   /data/program/php-7.3.9/etc/php.ini \
    && rm -rf /data/program/soft/* 


#########################################php扩展安装######################################
#https://www.ifsvc.cn/posts/57
RUN curl -o /data/program/soft/swoole.tar.gz https://github.com/swoole/swoole-src/archive/master.tar.gz -L  \
    && tar zxC /data/program/soft/ -f /data/program/soft/swoole.tar.gz  \
    && mv swoole-src* swoole-src  \
    && cd swoole-src  \
    && /data/program/php-7.3.9/bin/phpize  \
    && ./configure --with-php-config=/data/program/php-7.3.9/bin/php-config \
        --enable-openssl \
        --enable-http2  \
    && make \
    && make install

RUN wget https://github.com/phpredis/phpredis/archive/3.1.2.zip \
    && unzip 3.1.2.zip  \
    && cd phpredis-3.1.2/ \
    && /data/program/php-7.3.9/bin/phpize \
    && ./configure --with-php-config=/data/program/php-7.3.9/bin/php-config \
    && make \
    && make install 

RUN wget http://pecl.php.net/get/imagick-3.4.4.tgz \
    && tar xvf imagick-3.4.4.tgz \
    && cd imagick-3.4.4/ \
    && /data/program/php-7.3.9/bin/phpize \
    && ./configure --with-php-config=/data/program/php-7.3.9/bin/php-config \
    && make \
    && make install  

ENTRYPOINT ["/usr/bin/supervisord"]