Dockerfile 3.73 KB
Newer Older
1
FROM php:7-fpm
2 3 4
MAINTAINER Dave Lane <dave@oerfoundation.org> (@lightweight)

RUN apt-get update && apt-get install -y software-properties-common apt-utils
Dave Lane's avatar
Dave Lane committed
5 6
ENV DEBIAN_FRONTEND="noninteractive"
#RUN add-apt-repository ppa:ondrej/php
7 8 9 10

# Install PHP extensions
RUN apt-get update && apt-get install -y apt-utils git less libbz2-dev libc-client-dev \
    libcurl4-gnutls-dev libicu-dev libkrb5-dev libmcrypt-dev libpng-dev \
11
    libpspell-dev libssl-dev libxml2-dev telnet unzip zip
12 13
RUN apt-get install -y net-tools vim dnsutils
# install cron and msmtp for outgoing email
Dave Lane's avatar
Dave Lane committed
14
RUN apt-get install -y cron msmtp sudo 
15
RUN docker-php-ext-configure imap --with-imap --with-imap-ssl --with-kerberos
16
# RUN docker-php-ext-install bz2 curl imap intl mbstring mcrypt \
17
RUN docker-php-ext-install bz2 curl imap intl mbstring \
18 19 20
    pspell opcache soap xmlrpc zip

# install PHPRedis
21
ENV PHPREDIS_VERSION 4.1.1
22 23 24 25 26 27 28
RUN docker-php-source extract \
    && curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz \
    && tar xfz /tmp/redis.tar.gz \
    && rm -r /tmp/redis.tar.gz \
    && mv phpredis-$PHPREDIS_VERSION /usr/src/php/ext/redis \
    && docker-php-ext-install redis \
    && docker-php-source delete
29 30 31 32 33 34 35

# install GD
RUN apt-get update && apt-get install -y \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libmcrypt-dev \
    libpng-dev \
Dave Lane's avatar
Dave Lane committed
36 37
<<<<<<< HEAD
=======
38
#    && docker-php-ext-install -j$(nproc) iconv mcrypt \
39
    && docker-php-ext-install -j$(nproc) iconv \
40 41 42 43 44 45 46
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd

# install APCU and YAML
RUN apt-get install -y \
    libyaml-dev unzip
RUN pecl install yaml-2.0.0
Dave Lane's avatar
Dave Lane committed
47
RUN docker-php-ext-enable yaml
48 49 50 51 52 53 54
RUN pecl install apcu
RUN docker-php-ext-enable apcu

# clean up all Apt stuff
RUN rm -rf /var/lib/apt/lists/*

# address app-specific config requirements
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
RUN set -ex \
    && { \
        echo 'log_errors = on'; \
        echo 'display_errors = off'; \
        echo 'always_populate_raw_post_data = -1'; \
        echo 'date.timezone = "Pacific/Auckland"'; \
        echo 'cgi.fix_pathinfo = 0'; \
        echo 'sendmail_path = /usr/bin/msmtp -t'; \
        echo 'upload_max_filesize = 100M'; \
        echo 'post_max_size = 150M'; \
        echo 'memory_limit = 250M'; \
        echo '[opcache]'; \
        echo 'opcache.enable = 1'; \
        echo 'opcache.memory_consumption = 128'; \
        echo 'opcache.max_accelerated_files = 8000'; \
        echo 'opcache.revalidate_freq = 60'; \
        echo 'opcache.use_cwd = 1'; \
        echo 'opcache.validate_timestamps = 1'; \
        echo 'opcache.save_comments = 1'; \
        echo 'opcache.enable_file_override = 0'; \
    } | tee /usr/local/etc/php/conf.d/php.ini
76

77
# the PHP-fpm configuration - create new www.conf file!
78
RUN set -ex \  
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
    && { \
        echo '[global]'; \
        echo 'error_log = /proc/self/fd/2'; \
        echo '[www]'; \
        echo 'user = www-data'; \
        echo 'group = www-data'; \
        echo '; if we send this to /proc/self/fd/1, it never appears'; \
        echo 'access.log = /proc/self/fd/2'; \
        echo 'clear_env = no'; \
        echo 'catch_workers_output = yes'; \
        echo '; Ensure worker stdout and stderr are sent to the main error log.'; \
        echo 'security.limit_extensions = .php'; \
        echo '; process management stuff'; \
        echo 'pm = ondemand'; \
        echo 'pm.max_children = 10'; \
        echo 'pm.start_servers = 2'; \
        echo 'pm.min_spare_servers = 1'; \
        echo 'pm.max_spare_servers = 3'; \
    } | tee /usr/local/etc/php-fpm.d/www.conf

99 100 101 102 103 104
VOLUME /var/www/html

# Copy init scripts and custom .htaccess
COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]