hoangweb
4/16/2016 - 1:01 PM

dockerfile - php app

dockerfile - php app

FROM php:5.6-apache
MAINTAINER Name <email.id@here>

RUN a2enmod rewrite expires

# install the PHP extensions we need
RUN apt-get update && apt-get install -y \
    libpng12-dev \
    libjpeg-dev \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libmcrypt-dev \
    
    && rm -rf /var/lib/apt/lists/* \
    # install php extension
    && docker-php-ext-install -j$(nproc) iconv mcrypt \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-png-dir=/usr --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd mysqli opcache

# perl extension (e.g memcached)
RUN apt-get install -y libmemcached-dev \
    && pecl install memcached \
    && docker-php-ext-enable memcached

# other php extension.ie: xcache
RUN curl -fsSL 'https://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz' -o xcache.tar.gz \
    && mkdir -p xcache \
    && tar -xf xcache.tar.gz -C xcache --strip-components=1 \
    && rm xcache.tar.gz \
    && ( \
        cd xcache \
        && phpize \
        && ./configure --enable-xcache \
        && make -j$(nproc) \
        && make install \
    ) \
    && rm -r xcache \
    && docker-php-ext-enable xcache

# enable apache mods
RUN a2enmod rewrite rewrite expires headers actions fastcgi alias ssl actions include cgi dav_fs suexec dav auth_digest

# set recommended PHP.ini settings
COPY config/php.ini /usr/local/etc/php/

# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
        echo 'opcache.memory_consumption=128'; \
        echo 'opcache.interned_strings_buffer=8'; \
        echo 'opcache.max_accelerated_files=4000'; \
        echo 'opcache.revalidate_freq=60'; \
        echo 'opcache.fast_shutdown=1'; \
        echo 'opcache.enable_cli=1';

    } > /usr/local/etc/php/conf.d/opcache-recommended.ini

RUN touch /usr/local/etc/php/conf.d/upload-limit.ini \
    && echo "upload_max_filesize = 32M" >>
    /usr/local/etc/php/conf.d/upload-limit.ini \
    && echo "post_max_size = 32M" >> /usr/local/etc/php/conf.d/uploadlimit.ini

RUN {\
    echo 'output_buffering = 4096;'; \
    echo 'magic_quotes_gpc = Off;'; \
    echo 'register_globals = Off;'; \
    echo 'default_charset	= UTF-8;'; \
    echo 'memory_limit = 128M;'; \
    echo 'upload_max_filesize = 100M;'; \
    echo 'safe_mode = Off;'; \
    echo 'mysql.connect_timeout = 20;'; \
    echo 'session.use_cookies = On;'; \
    echo 'session.use_trans_sid = Off;'; \
    echo 'session.gc_maxlifetime = 12000000;'; \
    echo 'apc.enabled = 0;';
} > /usr/local/etc/php/conf.d/custom-php.ini

ENV CART_VERSION 1.5

VOLUME /var/www/html
COPY web/ /var/www/html/cart
RUN chown -R www-data:www-data /var/www/html/cart

WORKDIR /var/www/html/cart

CMD [ "php", "./index.php" ]