Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Fix inline PDF preview in expensereport #148

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ RUN apt-get update -y \
default-mysql-client \
postgresql-client \
cron \
libmagickwand-dev \
ghostscript \
&& apt-get autoremove -y \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) calendar intl mysqli pdo_mysql gd soap zip \
Expand All @@ -72,6 +74,15 @@ RUN apt-get update -y \
&& mv ${PHP_INI_DIR}/php.ini-production ${PHP_INI_DIR}/php.ini \
&& rm -rf /var/lib/apt/lists/*

# Install Imagick for expense report inline pdf preview
RUN pecl install imagick
RUN docker-php-ext-enable imagick

# Set Imagick security policy to allow pdf conversion
COPY update-imagemagick-policy.sh /usr/local/bin/update-imagemagick-policy.sh
RUN chmod +x /usr/local/bin/update-imagemagick-policy.sh
RUN /usr/local/bin/update-imagemagick-policy.sh

# Get Dolibarr
RUN curl -fLSs https://github.com/Dolibarr/dolibarr/archive/${DOLI_VERSION}.tar.gz |\
tar -C /tmp -xz && \
Expand Down
9 changes: 9 additions & 0 deletions update-imagemagick-policy.sh
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you don't need to create a separate script. The xml path will be always the same, you can run sed command directly in Dockerfile.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for futural compatibility. The configuration folder depends on the version of Imagick. For example, in the current docker container, it is /etc/ImageMagick-6

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# look for the path of policy.xml of ImageMagick
POLICY_XML=$(find /etc -name "policy.xml" | grep -m 1 'ImageMagick')

# If policy.xml is found ,change it to allow pdf conversion
if [ ! -z "$POLICY_XML" ]; then
sed -i '/<policy domain="coder" rights="none" pattern="PDF" \/>/c\<policy domain="coder" rights="read|write" pattern="PDF" \/>' "$POLICY_XML"
fi
Loading