Ddev: Web container - additional php modules

Created on 28 Jun 2018  路  11Comments  路  Source: drud/ddev

Is your feature request related to a problem? Please describe.
In my projects (usually Neos CMS) i usually need the php-imagick and php-redis php-modules wich are not preset in the current web container. Currently i only can use a custom web container or install these modules via porst-start hook. Both works not really satisfying for me.

Describe the solution you'd like
I would like to have a documented way of adding php-modules to the web container.

Describe alternatives you've considered
Offcourse providing the modules php-imagick and php-redis would solve the problem for me and but i think other users will have different php-module needs.

Most helpful comment

Hope anybody coming here from Google asking the same reads until here.

This now is done via webimage_extra_packages directly in the config.yaml.

For example:

webimage_extra_packages: [php-yaml, php7.3-ldap]

See https://ddev.readthedocs.io/en/stable/users/extend/customizing-images/#adding-extra-debian-packages-with-webimage_extra_packages-and-dbimage_extra_packages

All 11 comments

It seems everybody needs a new package of one type or another, so we've added sudo into the latest v0.20.0 release of ddev. An example of adding a package on post-start is given in https://ddev.readthedocs.io/en/latest/users/extending-commands/#supported-tasks

We're hoping that's a solution for all problems of this type, if it's good enough for you, give us the go-ahead to close this. Thanks!

This solution kind of works with the following limitations

  1. If i run sudo apt-get install -y php-gmagick or run sudo apt-get install -y php-imagick i get tons of error messahes and so far i have not managed to solve the issue
  2. The post start is always executed whenever containers are restarted. It would be great to have a post-create hook for such cases
  1. Run sudo apt-get update first. Then sudo apt-get install -y php-imagick.
  2. Containers are created on start or restart, there's not a separate operation.

I ran sudo apt-get update first but php-imagick or php-gmagick seem not to like that. Seems to be more an issue of those modules that of ddev so i will close this for now and try to figure out how to get this running in containers.

Thanks, I tried sudo apt-get update && sudo apt-get install -y php-imagick and it almost worked. I'm not sure what package wants to create the 'messagebus' user,

adduser: No UID/GID pair is available in the range 100-999 (FIRST_SYS_UID - LAST_SYS_UID).
adduser: The user `messagebus' was not created.
dpkg: error processing package dbus (--configure):

But, you can solve the problem with

sudo usermod -l messagebus uid_399 && sudo groupmod -n messagebus gid_399

(before the php-imagick install)

(I chose 399 as just a random choice, it could be anything up to 999)

I still would like it to have ImageMagick and Redis per default (or at least configurable like the webroot). Almost every PHP-project use ImageMagick and/or Redis.

This recipe tells how to use redis quite nicely, php-redis has been added to the web container - https://stackoverflow.com/questions/51476781/can-i-have-redis-available-in-my-ddev-container

I can see how you'd need IMageMagick, does the solution in https://github.com/drud/ddev/issues/949#issuecomment-401846593 do anything for you? It would be interesting to see how much it actually adds in size, I'm worried that it might be significant.

949 Adds php-imagick; hopefully that will help on that end.

We don't plain to add redis directly to the web container, but the Stack Overflow recipe may help you when you need that @jonnitto - php-redis is in the web container and has been for a few releases.

Thanks for letting us know what you need!

I tried to add install the Image Magick in a post-start hook:

APIVersion: v1.2.0
name: sgp-report
type: drupal8
docroot: htdocs
php_version: "7.1"
webserver_type: nginx-fpm
router_http_port: "8060"
router_https_port: "4436"
xdebug_enabled: false
additional_hostnames: []
additional_fqdns: []
provider: default

hooks:
  post-start:
    - exec: "sudo apt-get update"
    - exec: "sudo apt-get install -y php-imagick"

But it does not work, after ddev start I get the following info:

$ ddev start
Starting sgp-report...
Starting ddev-sgp-report-db ... done
Starting ddev-sgp-report-dba ... done
Starting ddev-sgp-report-web ... done

Network ddev_default is external, skipping
Creating ddev-router ... done

Ensuring write permissions for sgp-report
Executing post-start commands...
--- Running exec command: sudo apt-get update ---
--- post-start exec command succeeded, output below ---
Hit http://security.debian.org jessie/updates InRelease
Hit http://nginx.org jessie InRelease
Hit https://deb.nodesource.com jessie InRelease
Hit https://packages.sury.org jessie InRelease
Hit https://dl.yarnpkg.com stable InRelease
Get:1 http://security.debian.org jessie/updates/main amd64 Packages [658 kB]
Ign http://httpredir.debian.org jessie InRelease
Hit http://httpredir.debian.org jessie Release.gpg
Hit http://httpredir.debian.org jessie Release
Get:2 http://nginx.org jessie/nginx amd64 Packages [13.3 kB]
Get:3 https://deb.nodesource.com jessie/main Sources [762 B]
Get:4 https://deb.nodesource.com jessie/main amd64 Packages [1007 B]
Get:5 https://packages.sury.org jessie/main amd64 Packages [58.4 kB]
Get:6 https://dl.yarnpkg.com stable/main amd64 Packages [7477 B]
Get:7 http://httpredir.debian.org jessie/main amd64 Packages [9098 kB]
Fetched 9837 kB in 8s (1193 kB/s)
Reading package lists...


--- Running exec command: sudo apt-get install -y php-imagick ---
debconf: delaying package configuration, since apt-utils is not installed
E: Sub-process /usr/bin/dpkg returned an error code (1)
Failed to start sgp-report: post-start exec failed: Failed to run docker-compose [-f C:\Workspace\Sites\ddev-sgp-report\.ddev\docker-compose.yaml exec -T web sudo apt-get install -y php-imagick], err='exit status 100', stdout='Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  dbus fonts-droid ghostscript gsfonts libavahi-client3 libavahi-common-data
  libavahi-common3 libcap-ng0 libcups2 libcupsfilters1 libcupsimage2
  libdbus-1-3 libgs9 libgs9-common libijs-0.35 libjasper1 libjbig2dec0
  libpaper-utils libpaper1 poppler-data ttf-dejavu-core
Suggested packages:
  dbus-x11 ghostscript-x cups-common libjasper-runtime poppler-utils
  fonts-japanese-mincho fonts-ipafont-mincho fonts-japanese-gothic
  fonts-ipafont-gothic fonts-arphic-ukai fonts-arphic-uming fonts-nanum
The following NEW packages will be installed:
  dbus fonts-droid ghostscript gsfonts libavahi-client3 libavahi-common-data
  libavahi-common3 libcap-ng0 libcups2 libcupsfilters1 libcupsimage2
  libdbus-1-3 libgs9 libgs9-common libijs-0.35 libjasper1 libjbig2dec0
  libpaper-utils libpaper1 php-imagick poppler-data ttf-dejavu-core
0 upgraded, 22 newly installed, 0 to remove and 92 not upgraded.
Need to get 14.2 MB of archives.
After this operation, 53.4 MB of additional disk space will be used.
Get:1 http://security.debian.org/ jessie/updates/main libcups2 amd64 1.7.5-11+deb8u4 [284 kB]
Get:2 http://security.debian.org/ jessie/updates/main libcupsimage2 amd64 1.7.5-11+deb8u4 [117 kB]
Get:3 http://security.debian.org/ jessie/updates/main libgs9-common all 9.06~dfsg-2+deb8u8 [1983 kB]
Get:4 http://security.debian.org/ jessie/updates/main libgs9 amd64 9.06~dfsg-2+deb8u8 [1917 kB]
Get:5 http://security.debian.org/ jessie/updates/main ghostscript amd64 9.06~dfsg-2+deb8u8 [85.4 kB]
Get:6 https://packages.sury.org/php/ jessie/main php-imagick amd64 3.4.3-1+0~20180910184535.6+jessie~1.gbp61e4be [195 kB]
Get:7 http://httpredir.debian.org/debian/ jessie/main fonts-droid all 1:4.4.4r2-6 [3729 kB]
Get:8 http://httpredir.debian.org/debian/ jessie/main libavahi-common-data amd64 0.6.31-5 [98.6 kB]
Get:9 http://httpredir.debian.org/debian/ jessie/main libavahi-common3 amd64 0.6.31-5 [51.1 kB]
Get:10 http://httpredir.debian.org/debian/ jessie/main libdbus-1-3 amd64 1.8.22-0+deb8u1 [170 kB]
Get:11 http://httpredir.debian.org/debian/ jessie/main libavahi-client3 amd64 0.6.31-5 [54.4 kB]
Get:12 http://httpredir.debian.org/debian/ jessie/main libcap-ng0 amd64 0.7.4-2 [13.2 kB]
Get:13 http://httpredir.debian.org/debian/ jessie/main libcupsfilters1 amd64 1.0.61-5+deb8u3 [106 kB]
Get:14 http://httpredir.debian.org/debian/ jessie/main libijs-0.35 amd64 0.35-10 [20.0 kB]
Get:15 http://httpredir.debian.org/debian/ jessie/main libjasper1 amd64 1.900.1-debian1-2.4+deb8u3 [134 kB]
Get:16 http://httpredir.debian.org/debian/ jessie/main libpaper1 amd64 1.1.24+nmu4 [22.0 kB]
Get:17 http://httpredir.debian.org/debian/ jessie/main poppler-data all 0.4.7-1 [1491 kB]
Get:18 http://httpredir.debian.org/debian/ jessie/main dbus amd64 1.8.22-0+deb8u1 [292 kB]
Get:19 http://httpredir.debian.org/debian/ jessie/main libjbig2dec0 amd64 0.13-4~deb8u2 [60.2 kB]
Get:20 http://httpredir.debian.org/debian/ jessie/main gsfonts all 1:8.11+urwcyr1.0.7~pre44-4.2 [3364 kB]
Get:21 http://httpredir.debian.org/debian/ jessie/main libpaper-utils amd64 1.1.24+nmu4 [17.5 kB]
Get:22 http://httpredir.debian.org/debian/ jessie/main ttf-dejavu-core all 2.34-1 [30.7 kB]
Fetched 14.2 MB in 2s (6834 kB/s)
Selecting previously unselected package fonts-droid.
(Reading database ... 20939 files and directories currently installed.)
Preparing to unpack .../fonts-droid_1%3a4.4.4r2-6_all.deb ...
Unpacking fonts-droid (1:4.4.4r2-6) ...
Selecting previously unselected package libavahi-common-data:amd64.
Preparing to unpack .../libavahi-common-data_0.6.31-5_amd64.deb ...
Unpacking libavahi-common-data:amd64 (0.6.31-5) ...
Selecting previously unselected package libavahi-common3:amd64.
Preparing to unpack .../libavahi-common3_0.6.31-5_amd64.deb ...
Unpacking libavahi-common3:amd64 (0.6.31-5) ...
Selecting previously unselected package libdbus-1-3:amd64.
Preparing to unpack .../libdbus-1-3_1.8.22-0+deb8u1_amd64.deb ...
Unpacking libdbus-1-3:amd64 (1.8.22-0+deb8u1) ...
Selecting previously unselected package libavahi-client3:amd64.
Preparing to unpack .../libavahi-client3_0.6.31-5_amd64.deb ...
Unpacking libavahi-client3:amd64 (0.6.31-5) ...
Selecting previously unselected package libcap-ng0:amd64.
Preparing to unpack .../libcap-ng0_0.7.4-2_amd64.deb ...
Unpacking libcap-ng0:amd64 (0.7.4-2) ...
Selecting previously unselected package libcups2:amd64.
Preparing to unpack .../libcups2_1.7.5-11+deb8u4_amd64.deb ...
Unpacking libcups2:amd64 (1.7.5-11+deb8u4) ...
Selecting previously unselected package libcupsimage2:amd64.
Preparing to unpack .../libcupsimage2_1.7.5-11+deb8u4_amd64.deb ...
Unpacking libcupsimage2:amd64 (1.7.5-11+deb8u4) ...
Selecting previously unselected package libcupsfilters1:amd64.
Preparing to unpack .../libcupsfilters1_1.0.61-5+deb8u3_amd64.deb ...
Unpacking libcupsfilters1:amd64 (1.0.61-5+deb8u3) ...
Selecting previously unselected package libijs-0.35:amd64.
Preparing to unpack .../libijs-0.35_0.35-10_amd64.deb ...
Unpacking libijs-0.35:amd64 (0.35-10) ...
Selecting previously unselected package libjasper1:amd64.
Preparing to unpack .../libjasper1_1.900.1-debian1-2.4+deb8u3_amd64.deb ...
Unpacking libjasper1:amd64 (1.900.1-debian1-2.4+deb8u3) ...
Selecting previously unselected package libpaper1:amd64.
Preparing to unpack .../libpaper1_1.1.24+nmu4_amd64.deb ...
Unpacking libpaper1:amd64 (1.1.24+nmu4) ...
Selecting previously unselected package poppler-data.
Preparing to unpack .../poppler-data_0.4.7-1_all.deb ...
Unpacking poppler-data (0.4.7-1) ...
Selecting previously unselected package dbus.
Preparing to unpack .../dbus_1.8.22-0+deb8u1_amd64.deb ...
Unpacking dbus (1.8.22-0+deb8u1) ...
Selecting previously unselected package libjbig2dec0.
Preparing to unpack .../libjbig2dec0_0.13-4~deb8u2_amd64.deb ...
Unpacking libjbig2dec0 (0.13-4~deb8u2) ...
Selecting previously unselected package libgs9-common.
Preparing to unpack .../libgs9-common_9.06~dfsg-2+deb8u8_all.deb ...
Unpacking libgs9-common (9.06~dfsg-2+deb8u8) ...
Selecting previously unselected package libgs9.
Preparing to unpack .../libgs9_9.06~dfsg-2+deb8u8_amd64.deb ...
Unpacking libgs9 (9.06~dfsg-2+deb8u8) ...
Selecting previously unselected package gsfonts.
Preparing to unpack .../gsfonts_1%3a8.11+urwcyr1.0.7~pre44-4.2_all.deb ...
Unpacking gsfonts (1:8.11+urwcyr1.0.7~pre44-4.2) ...
Selecting previously unselected package ghostscript.
Preparing to unpack .../ghostscript_9.06~dfsg-2+deb8u8_amd64.deb ...
Unpacking ghostscript (9.06~dfsg-2+deb8u8) ...
Selecting previously unselected package libpaper-utils.
Preparing to unpack .../libpaper-utils_1.1.24+nmu4_amd64.deb ...
Unpacking libpaper-utils (1.1.24+nmu4) ...
Selecting previously unselected package php-imagick.
Preparing to unpack .../php-imagick_3.4.3-1+0~20180910184535.6+jessie~1.gbp61e4be_amd64.deb ...
Unpacking php-imagick (3.4.3-1+0~20180910184535.6+jessie~1.gbp61e4be) ...
Selecting previously unselected package ttf-dejavu-core.
Preparing to unpack .../ttf-dejavu-core_2.34-1_all.deb ...
Unpacking ttf-dejavu-core (2.34-1) ...
Processing triggers for fontconfig (2.11.0-6.3+deb8u1) ...
Setting up fonts-droid (1:4.4.4r2-6) ...
Setting up libavahi-common-data:amd64 (0.6.31-5) ...
Setting up libavahi-common3:amd64 (0.6.31-5) ...
Setting up libdbus-1-3:amd64 (1.8.22-0+deb8u1) ...
Setting up libavahi-client3:amd64 (0.6.31-5) ...
Setting up libcap-ng0:amd64 (0.7.4-2) ...
Setting up libcups2:amd64 (1.7.5-11+deb8u4) ...
Setting up libijs-0.35:amd64 (0.35-10) ...
Setting up libjasper1:amd64 (1.900.1-debian1-2.4+deb8u3) ...
Setting up libpaper1:amd64 (1.1.24+nmu4) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline

Creating config file /etc/papersize with new version
Setting up poppler-data (0.4.7-1) ...
Setting up dbus (1.8.22-0+deb8u1) ...
adduser: No UID/GID pair is available in the range 100-999 (FIRST_SYS_UID - LAST_SYS_UID).
adduser: The user `messagebus' was not created.
dpkg: error processing package dbus (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up libjbig2dec0 (0.13-4~deb8u2) ...
Setting up libgs9-common (9.06~dfsg-2+deb8u8) ...
Setting up gsfonts (1:8.11+urwcyr1.0.7~pre44-4.2) ...
Setting up libpaper-utils (1.1.24+nmu4) ...
Setting up php-imagick (3.4.3-1+0~20180910184535.6+jessie~1.gbp61e4be) ...
Setting up ttf-dejavu-core (2.34-1) ...
Setting up libcupsfilters1:amd64 (1.0.61-5+deb8u3) ...
Setting up libcupsimage2:amd64 (1.7.5-11+deb8u4) ...
Setting up libgs9 (9.06~dfsg-2+deb8u8) ...
Setting up ghostscript (9.06~dfsg-2+deb8u8) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...
Errors were encountered while processing:
 dbus
', stderr='debconf: delaying package configuration, since apt-utils is not installed
E: Sub-process /usr/bin/dpkg returned an error code (1)', stderr='debconf: delaying package configuration, since apt-utils is not installed
E: Sub-process /usr/bin/dpkg returned an error code (1)'

Well, you might want to try just using webimage: drud/ddev-webserver:20180915_php_imagick instead until the next release and see how it goes for you.

Hope anybody coming here from Google asking the same reads until here.

This now is done via webimage_extra_packages directly in the config.yaml.

For example:

webimage_extra_packages: [php-yaml, php7.3-ldap]

See https://ddev.readthedocs.io/en/stable/users/extend/customizing-images/#adding-extra-debian-packages-with-webimage_extra_packages-and-dbimage_extra_packages

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rickmanelius picture rickmanelius  路  4Comments

juergen-venne picture juergen-venne  路  7Comments

kaystrobach picture kaystrobach  路  6Comments

ptoseklukas picture ptoseklukas  路  6Comments

therobyouknow picture therobyouknow  路  3Comments