Sign inSign up

netzheldencom/php

By netzheldencom

•Updated about 7 years ago

Image
1

496

netzheldencom/php repository overview

⁠PHP docker image based on the offical php image⁠

⁠Available Tags / PHP-Versions
  • 7.3.0-fpm

⁠Installed PHP Extension

  • mcrypt

  • intl

  • curl

  • xdebug

  • gd

  • opcache

  • pdo

  • pdo_mysql

  • bcmath

  • bz2

  • json

  • ldap

  • mbstring

  • pdo_pgsql

  • pdo_sqlite

  • phar

  • imagemagick

⁠Environemt variables and default values

⁠PHP

⁠php.ini.tpl
  • memory_limit: PHP_MEMORY_LIMIT=128M
  • short_open_tag: PHP_SHORT_OPEN_TAG=off
  • max_input_vars: PHP_MAX_INPUT_VARS=1000
  • max_execution_time: PHP_MAX_EXECUTION_TIME=300
  • max_input_time: PHP_MAX_INPUT_TIME=60
  • error_reporting: PHP_ERROR_REPORTING=E_ALL
  • display_errors: PHP_DISPLAY_ERRORS=On
  • html_errors: PHP_HTML_ERRORS=On
  • display_startup_errors: PHP_DISPLAY_STARTUP_ERRORS="On"
  • track_errors: PHP_TRACK_ERRORS="On"
  • post_max_size: PHP_POST_MAX_SIZE=8M
  • upload_max_filesize: PHP_UPLOAD_MAX_FILESIZE=2M
  • max_file_uploads: PHP_MAX_FILE_UPLOADS=20
  • allow_url_fopen: PHP_ALLOW_URL_FOPEN=On
  • default_socket_timeout: PHP_DEFAULT_SOCKET_TIMEOUT=60
  • date_timezone: PHP_DATE_TIMEZONE=Europe/Berlin
⁠conf.d/40.xdebug.ini.tpl
  • xdebug.remote_host: XDEBUG_REMOTE_HOST=localhost
  • xdebug.max_nesting_level: XDEBUG_MAX_NESTING_LEVEL=2000
  • xdebug.profiler_enable_trigger: XDEBUG_PROFILER_ENABLE_TRIGGER=1
  • xdebug.remote_enabled: XDEBUG_REMOTE_ENABLED=1
  • xdebug.remote_connect_back: XDEBUG_REMOTE_CONNECT_BACK=0
⁠conf.d/docker-php-ext-mysqli.ini.tpl
  • mysqli.max_persistent: PHP_MYSQLI_MAX_PERSISTENT=-1
  • mysqli.allow_persistent: PHP_MYSQLI_ALLOW_PERSISTENT=On
  • mysqli.max_links: PHP_MYSQLI_MAX_LINKS=-1
  • mysqli.cache_size: PHP_MYSQLI_CACHE_SIZE=2000
  • mysqli.default_port: PHP_MYSQLI_DEFAULT_PORT=3306
⁠conf.d/docker-php-ext-opcache.ini.tpl
  • opcache.enable_cli: PHP_OPCACHE_ENABLE_CLI=0
  • opcache.memory_consumption: PHP_OPCACHE_MEMORY_CONSUMPTION=128
  • opcache.max_accelerated_files: PHP_OPCACHE_MAX_ACCELERATED_FILES=10000
  • opcache.error_log: PHP_OPCACHE_ERROR_LOG=/proc/self/fd/2
  • opcache.enable: PHP_OPCACHE_ENABLE=1
  • opcache.log_verbosity_level: PHP_OPCACHE_LOG_VERBOSITY_LEVEL=4
⁠conf.d/docker-php-ext-pdo_mysql.ini.tpl
  • pdo_mysql.cache_size: PHP_PDO_MYSQL_CACHE_SIZE=2000

⁠PHP-FPM

⁠php-fpm-conf.tpl
  • error_log: FPM_LOG_DIR=/proc/self/fd/2
  • log_level: FPM_LOG_LEVEL=notice
  • pm.max_children: FPM_PM_MAX_CHILDREN=25
  • pm.start_servers: FPM_PM_START_SERVERS=10
  • pm.min_spare_servers: FPM_PM_MIN_SPARE_SERVERS=5
  • pm.max_spare_servers: FPM_PM_MAX_SPARE_SERVERS=20
  • pm.max_requests: FPM_PM_MAX_REQUESTS=500
  • pm.process_idle_timeout: FPM_PM_PROCESS_IDLE_TIMEOUT=10s
⁠php-fpm.d/www.conf.tpl
  • user: FPM_USER=www-data

⁠Installed tools

  • composer

⁠Directory structure

⁠bin

Bash scripts to ease the some installation processes. Currently setup of composer

⁠etc

Configuration files

⁠How to use build image.

Check out from VCS In the project root run

mvn docker:build

⁠Xdebug

When using xdebug and docker for mac there are some difficulties due to the restricted access of the container to the host systems network.

To workaround this issue an environment variable XDEBUG_REMOTE_HOST can be used.

  1. setup an alias IP for the loopback device (localhost / 127.0.0.1) sudo ifconfig lo0 alias 10.254.254.254.
  2. pass the IP of the loopback alias to the container using environment variables
    e.g in the docker-compose.yml
...

 php:
    imgae: php:7.0.8-fpm-oci8
    volumes:
      - ./src:/var/www/html
    environment:
      - XDEBUG_REMOTE=10.254.254.254
⁠Docker (Mac) De-facto Standard Host Address Alias

This launchd script will ensure that your Docker environment on your Mac will have 10.254.254.254 as an alias on your loopback device (127.0.0.1). The command being run is ifconfig lo0 alias 10.254.254.254

⁠Installation

Take a look at Ralph Schindlers - Docker (Mac) De-facto Standard Host Address Alias⁠
Short version below.

You may want to change the IP-address if it's already in use on your system.

Or copy the above Plist file to /Library/LaunchDaemons/de.kochan.docker_10254_alias.plist

Next and every successive reboot will ensure your lo0 will have the proper ip address.

⁠Why?

Because docker.local is gone. This seems to be the easiest way to setup xdebug to connect back to your IDE running on your host. Similarly, this is a solution for any kind of situations where a container needs to connect back to the host container at a known ip address.

For example, a configuration for xdebug in your php container for xdebug.ini might look like:

⁠How to install more PHP extensions

We provide the helper scripts docker-php-ext-configure, docker-php-ext-install, and docker-php-ext-enable to more easily install PHP extensions.

In order to keep the images smaller, PHP's source is kept in a compressed tar file. To facilitate linking of PHP's source with any extension, we also provide the helper script docker-php-source to easily extract the tar or delete the extracted source. Note: if you do use docker-php-source to extract the source, be sure to delete it in the same layer of the docker image.

FROM php:7.0-apache
RUN docker-php-source extract \
	# do important things \
	&& docker-php-source delete
⁠PHP Core Extensions

For example, if you want to have a PHP-FPM image with iconv, mcrypt and gd extensions, you can inherit the base image that you like, and write your own Dockerfile like this:

FROM php:7.0-fpm
RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng12-dev \
    && docker-php-ext-install -j$(nproc) iconv mcrypt \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd

Remember, you must install dependencies for your extensions manually. If an extension needs custom configure arguments, you can use the docker-php-ext-configure script like this example. There is no need to run docker-php-source manually in this case, since that is handled by the configure and install scripts.

⁠PECL extensions

Some extensions are not provided with the PHP source, but are instead available through PECL⁠. To install a PECL extension, use pecl install to download and compile it, then use docker-php-ext-enable to enable it:

FROM php:7.0-fpm
RUN apt-get update && apt-get install -y libmemcached-dev \
	&& pecl install memcached \
	&& docker-php-ext-enable memcached
⁠Other extensions

Some extensions are not provided via either Core or PECL; these can be installed too, although the process is less automated:

FROM php:7.0-apache
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
⁠Without a Dockerfile

If you don't want to include a Dockerfile in your project, it is sufficient to do the following:

$ docker run -d -p 80:80 --name my-apache-php-app -v "$PWD":/var/www/html php:7.0-apache

⁠Image Variants

The php images come in many flavors, each designed for a specific use case.

⁠php:<version>

This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.

⁠php:alpine

TODO UPDATE

⁠License

View license information⁠ for the software contained in this image.

Tag summary

Content type

Image

Digest

Size

242.9 MB

Last updated

almost 8 years ago

docker pull netzheldencom/php