Docker: Add ImageMagick PHP extension to support "Theming of icons"

Created on 14 Feb 2018  路  16Comments  路  Source: nextcloud/docker

The current docker image doesn't provide the dependencies for "Theming of icons":

https://docs.nextcloud.com/server/13/admin_manual/configuration_server/theming.html#theming-of-icons

Please add the ImageMagick PHP extension and ImageMagick SVG support to the container to support custom favicons in settings/admin/theming of Nextcloud.

enhancement

Most helpful comment

Here our Dockerfile code to add Imagemagick.

FROM nextcloud:13.0.1-fpm

RUN apt-get update; \
    apt-get install -y --no-install-recommends \
        sudo \
        libmagickwand-dev \
        libmagickcore-extra \
    ; \
    pecl install imagick; \
    docker-php-ext-enable imagick; \
    apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
    rm -rf /var/lib/apt/lists/*

All 16 comments

Here our Dockerfile code to add Imagemagick.

FROM nextcloud:13.0.1-fpm

RUN apt-get update; \
    apt-get install -y --no-install-recommends \
        sudo \
        libmagickwand-dev \
        libmagickcore-extra \
    ; \
    pecl install imagick; \
    docker-php-ext-enable imagick; \
    apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
    rm -rf /var/lib/apt/lists/*

Don't forget to cleanup the dpkg cache after the installation of the packages.

@suntorytimed please add the cleanup Dockerfile code. Did you mean this, like in the Nextcloud Dockerfile?

RUN apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
    rm -rf /var/lib/apt/lists/*

@phlegx yes, something like this. It should be part of the RUN command that executes apt-get. You could also add

apt-get clean

Docker provides some best practices (https://docs.docker.com/develop/develop-images/dockerfile_best-practices/) They state that it is not necessary to run apt-get clean, because the official image does this already, but I do it anyways just to be safe.

I also tend to split my commands in several RUNs so more snapshots are created and can be reused. I would also avoid installing sudo if you don't need it for specific tasks:

FROM nextcloud:13.0.1-fpm

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        libmagickwand-dev \
        libmagickcore-extra \
        && apt-get clean \
        && rm -rf /var/lib/apt/lists/*
RUN pecl install imagick
RUN docker-php-ext-enable imagick

EDIT: And instead of ; use && to separate your commands. This way the next command will only be executed if the previous one was successful.

What could make this be added to official images? Do you expect a merge request?

Hello, I'm getting this error:

E: Package 'libmagickcore-extra' has no installation candidate

maybe try libmagickcore-6.q16-3-extra or libmagickcore-6.q16hdri-3-extra instead?

Or maybe it is not needed at all. in the full dockerfile example it is not listed either.

@rubo77 work with libmagickcore-6.q16-3-extra

thanks!

What is the extra package for?

Should we add it to the "full" docker file?

As I can understand, this package is a dependence for compiling imagick's php extension: docker-php-ext-enable imagick

It seems that it does not work. Tested with nextcloud 15.0.2.

The "extra" package (for svg support) is still missing in the official images.

575 only added imagick (supports "most used" image file types like png,jpg,bmp for previews).

See #594 .

Thanks! I didn't notice the second MR.

I think this should not be closed until theming of icons is complete.

This issue still isn't resolved (16.0.4) so shouldn't be closed. The SVG support is missing, as @fuse314 mentioned.

In nextcloud 17, imagemagick svg support is used to convert various elements like folder icons. the package is missing in the official nextcloud:17-fpm image. The folders and my logo were black after the upgrade to 17.

my workaround:

docker-compose exec nextcloud bash
apt install libmagickcore-6.q16-6-extra
./occ repair # clean frontend caches
docker-compose restart
Was this page helpful?
0 / 5 - 0 ratings