|
| 1 | +FROM php:8.3-fpm-bullseye |
| 2 | + |
| 3 | +# Container containing php-fpm and php-cli to run and interact with Ibexa DXP |
| 4 | + |
| 5 | +# Set defaults for variables used by run.sh |
| 6 | +ENV COMPOSER_HOME=/root/.composer |
| 7 | + |
| 8 | +# Get packages that we need in container |
| 9 | +RUN apt-get update -q -y \ |
| 10 | + && apt-get install -q -y --no-install-recommends \ |
| 11 | + ca-certificates \ |
| 12 | + curl \ |
| 13 | + acl \ |
| 14 | + sudo \ |
| 15 | +# Needed for the php extensions we enable below |
| 16 | + # gd |
| 17 | + libfreetype6 \ |
| 18 | + libjpeg62-turbo \ |
| 19 | + libxpm4 \ |
| 20 | + libpng16-16 \ |
| 21 | + # intl |
| 22 | + libicu67 \ |
| 23 | + # xslt |
| 24 | + libxslt1.1 \ |
| 25 | + # memcached |
| 26 | + libmemcachedutil2 \ |
| 27 | + # zip |
| 28 | + libzip4 \ |
| 29 | + # imagick |
| 30 | + imagemagick \ |
| 31 | + # mbstring |
| 32 | + libonig5 \ |
| 33 | + # PostgreSQL |
| 34 | + libpq5 \ |
| 35 | +# git & unzip needed for composer, unless we document to use dev image for composer install |
| 36 | +# unzip needed due to https://github.com/composer/composer/issues/4471 |
| 37 | + unzip \ |
| 38 | + git \ |
| 39 | +# packages useful for dev |
| 40 | + less \ |
| 41 | + mariadb-client \ |
| 42 | + vim \ |
| 43 | + wget \ |
| 44 | + tree \ |
| 45 | + gdb-minimal \ |
| 46 | + && rm -rf /var/lib/apt/lists/* |
| 47 | + |
| 48 | +# Install and configure php plugins |
| 49 | +RUN set -xe \ |
| 50 | + && buildDeps=" \ |
| 51 | + # gd |
| 52 | + libjpeg62-turbo-dev \ |
| 53 | + libpng-dev \ |
| 54 | + libxpm-dev \ |
| 55 | + libfreetype6-dev \ |
| 56 | + # PostgreSQL |
| 57 | + libpq-dev \ |
| 58 | + # mbstring \ |
| 59 | + libonig-dev \ |
| 60 | + # intl |
| 61 | + libicu-dev \ |
| 62 | + # xsl |
| 63 | + libxslt1-dev \ |
| 64 | + # zip |
| 65 | + libzip-dev \ |
| 66 | + # imagick |
| 67 | + libmagickwand-dev \ |
| 68 | + # memcached |
| 69 | + libmemcached-dev \ |
| 70 | + " \ |
| 71 | + && apt-get update -q -y && apt-get install -q -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/* \ |
| 72 | +# Extract php source and install missing extensions |
| 73 | + && docker-php-source extract \ |
| 74 | + && docker-php-ext-configure mysqli --with-mysqli=mysqlnd \ |
| 75 | + && docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \ |
| 76 | + && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \ |
| 77 | + && docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ --with-xpm=/usr/include/ --enable-gd-jis-conv \ |
| 78 | + && docker-php-ext-install exif gd mbstring intl xsl zip mysqli pdo_mysql pdo_pgsql pgsql soap bcmath sockets \ |
| 79 | + && docker-php-ext-enable opcache \ |
| 80 | + && cp /usr/src/php/php.ini-production ${PHP_INI_DIR}/php.ini \ |
| 81 | + \ |
| 82 | +# Install imagemagick |
| 83 | + && for i in $(seq 1 3); do pecl install -o imagick && s=0 && break || s=$? && sleep 1; done; (exit $s) \ |
| 84 | + && docker-php-ext-enable imagick \ |
| 85 | +# Install xdebug |
| 86 | + && for i in $(seq 1 3); do echo yes | pecl install -o "xdebug" && s=0 && break || s=$? && sleep 1; done; (exit $s) \ |
| 87 | +# Install blackfire: https://blackfire.io/docs/integrations/docker |
| 88 | + && version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ |
| 89 | + && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ |
| 90 | + && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \ |
| 91 | + && mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ |
| 92 | + && rm -f /tmp/blackfire-probe.tar.gz \ |
| 93 | + \ |
| 94 | +# Install igbinary (for more efficient serialization in redis/memcached) |
| 95 | + && for i in $(seq 1 3); do pecl install -o igbinary && s=0 && break || s=$? && sleep 1; done; (exit $s) \ |
| 96 | + && docker-php-ext-enable igbinary \ |
| 97 | + \ |
| 98 | +# Install redis (manualy build in order to be able to enable igbinary) |
| 99 | + && for i in $(seq 1 3); do pecl install -o --nobuild redis && s=0 && break || s=$? && sleep 1; done; (exit $s) \ |
| 100 | + && cd "$(pecl config-get temp_dir)/redis" \ |
| 101 | + && phpize \ |
| 102 | + && ./configure --enable-redis-igbinary \ |
| 103 | + && make \ |
| 104 | + && make install \ |
| 105 | + && docker-php-ext-enable redis \ |
| 106 | + && cd - \ |
| 107 | + \ |
| 108 | +# Install memcached (manualy build in order to be able to enable igbinary) |
| 109 | + && for i in $(seq 1 3); do echo no | pecl install -o --nobuild memcached && s=0 && break || s=$? && sleep 1; done; (exit $s) \ |
| 110 | + && cd "$(pecl config-get temp_dir)/memcached" \ |
| 111 | + && phpize \ |
| 112 | + && ./configure --enable-memcached-igbinary \ |
| 113 | + && make \ |
| 114 | + && make install \ |
| 115 | + && docker-php-ext-enable memcached \ |
| 116 | + && cd - \ |
| 117 | + \ |
| 118 | +# Delete source & builds deps so it does not hang around in layers taking up space |
| 119 | + && pecl clear-cache \ |
| 120 | + && rm -Rf "$(pecl config-get temp_dir)/*" \ |
| 121 | + && docker-php-source delete \ |
| 122 | + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps |
| 123 | + |
| 124 | +# Set timezone |
| 125 | +RUN echo "UTC" > /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata |
| 126 | + |
| 127 | +# Set pid file to be able to restart php-fpm |
| 128 | +RUN sed -i "s@^\[global\]@\[global\]\n\npid = /run/php-fpm.pid@" ${PHP_INI_DIR}-fpm.conf |
| 129 | + |
| 130 | +COPY conf.d/blackfire.ini ${PHP_INI_DIR}/conf.d/blackfire.ini |
| 131 | +COPY conf.d/xdebug.ini ${PHP_INI_DIR}/conf.d/xdebug.ini.disabled |
| 132 | + |
| 133 | +# Create Composer directory (cache and auth files) & Get Composer |
| 134 | +RUN mkdir -p $COMPOSER_HOME \ |
| 135 | + && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer |
| 136 | + |
| 137 | +# As application is put in as volume we do all needed operation on run |
| 138 | +COPY scripts /scripts |
| 139 | + |
| 140 | +# Add some custom config |
| 141 | +COPY conf.d/php.ini ${PHP_INI_DIR}/conf.d/php.ini |
| 142 | + |
| 143 | +RUN chmod 755 /scripts/*.sh |
| 144 | + |
| 145 | +# Needed for docker-machine |
| 146 | +RUN usermod -u 1000 www-data |
| 147 | + |
| 148 | +WORKDIR /var/www |
| 149 | + |
| 150 | +ENTRYPOINT ["/scripts/docker-entrypoint.sh"] |
| 151 | + |
| 152 | +CMD php-fpm |
| 153 | + |
| 154 | +EXPOSE 9000 |
0 commit comments