Skip to content

Instantly share code, notes, and snippets.

@rwese
Last active February 6, 2024 05:43
Show Gist options
  • Save rwese/2d94963ac37e31d014bac6ff3020cfee to your computer and use it in GitHub Desktop.
Save rwese/2d94963ac37e31d014bac6ff3020cfee to your computer and use it in GitHub Desktop.
Nextcloud - docker - fpm-alpine dockerfile add tesseract-ocr and fix svg support and default_phone_region
# add tesseract
# add php-imagick
# add py-pluggy, a not documented, dependency for ocrmypdf
#
# by default english is installed as an ocr language for tesseract on alpine
# adds tesseract-ocr-data-deu, change to your local language or remove
#
# This `pecl install imagick || true` is a workaround as imagick was installed
# on some image verions but pecl fails if already installed
#
# /usr/src/nextcloud/config/ is the directory from which the settings are
# rsynced to the new volume, on first start of the container.
# every .config.php file is loaded in succession and the $CONFIG array is merged
#
ARG IMAGE_VERSION
FROM nextcloud:${IMAGE_VERSION}-fpm-alpine
ARG DEFAULT_PHONE_REGION US
RUN echo "Version: ${IMAGE_VERSION}, Region: ${DEFAULT_PHONE_REGION}"
RUN apk update \
&& apk add --no-cache wget \
&& apk add --no-cache --update tesseract-ocr \
&& apk add --no-cache tesseract-ocr-data-deu \
&& apk add --no-cache ocrmypdf \
&& apk add --no-cache py3-pip
RUN set -ex \
&& apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS imagemagick-dev libtool \
&& export CFLAGS="$PHP_CFLAGS" CPPFLAGS="$PHP_CPPFLAGS" LDFLAGS="$PHP_LDFLAGS" \
&& pecl install imagick || true \
&& docker-php-ext-enable imagick \
&& apk add --no-cache --virtual .imagick-runtime-deps imagemagick \
&& apk del .phpize-deps
RUN apk add --no-cache py3-pluggy
RUN printf "<?php\n\
\$CONFIG = [ \n\
'default_phone_region' => '${DEFAULT_PHONE_REGION}', \n\
]; \n\
" >> /usr/src/nextcloud/config/default_phone_region.config.php
@rwese
Copy link
Author

rwese commented Feb 25, 2022

docker-compose.yml

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        IMAGE_VERSION: 23
        DEFAULT_PHONE_REGION: US

@znedw
Copy link

znedw commented Feb 6, 2024

pip install pluggy throws error: externally-managed-environment

replaced with apk add --no-cache py3-pluggy

@rwese
Copy link
Author

rwese commented Feb 6, 2024

Thanks @znedw, distribution got smarter about handling their dependencies and so did python, I am glad it does work at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment