-
Notifications
You must be signed in to change notification settings - Fork 168
Community Tips
Contributor: @ieugen
When the default provided image is not enough or maybe missing some dependencies, please customise it. The easiest way is to build a custom base image with a php extension starting from the base images provided.
Let's add php intl
to php7.1 base image.
We need to do the following:
- add the extension and dependencies to the image
- use the new image in our docker compose setup
First we need to update php7.1/Dockerfile and update the build instructions to install the needed packages and dependencies for intl. Each extension has it's own dependencies. For the intl
example we need to make the following changes:
php7.1/Dockerfile:
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
less \
libpng12-dev \
libjpeg-dev \
libxml2-dev \
+ libicu-dev \
mariadb-client \
unzip \
......
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-install \
exif \
gd \
mysqli \
+ intl \
opcache \
To use the new image we should also update example/docker-compose.yml to use build our image instead of using the published one.
version: '3'
services:
wordpress:
- image: visiblevc/wordpress:0.15.2-php7.1
+ # image: visiblevc/wordpress:0.15.2-php7.1
+ build: ../php7.1
ports:
It may take multiple tries until you figure out the correct software packages for each extension so you will have to rebuild your image again and again. To do that just run:
docker-compose up --build
Contributor: @b0rt
Sometimes it is useful to have xdebug, not just for remote debugging but to have better var_dump output as described here pretty well
You are using xdebug, which overloads the default var_dump() to give you prettier and more configurable output. https://stackoverflow.com/questions/34342777/how-to-see-full-content-of-long-strings-with-var-dump-in-php
add those lines to your custom .dockerfile
USER root
RUN pecl install xdebug && docker-php-ext-enable xdebug \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.remote_host = host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
USER admin
and (optionally) expose port 9000 in your docker-compose.yml
version: '3'
services:
wordpress:
ports:
+ - 9000:9000