mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 18:51:31 +00:00
Fix wkhtmltopdf bugs
The wkhtmltopdf library does not work with the latest version of alpine. To workaround this, a known working image based on an older alpine image is pulled in and relevant libraries copied to the target image. The `snappy` package required a few updates to support this, including setting the wkhtmltopdf binary path explicitly and to enable access to local files (disabled by default).
This commit is contained in:
@@ -1,4 +1,78 @@
|
|||||||
FROM streamlinehealth/streamline:signalytic
|
################################################################################
|
||||||
|
# Use known working image to pull in working wkhtmltopdf libraries
|
||||||
|
################################################################################
|
||||||
|
|
||||||
# update db init data
|
FROM surnet/alpine-wkhtmltopdf:3.16.2-0.12.6-full as wkhtmltopdf
|
||||||
COPY streamline_initial.sql /docker-entrypoint-initdb.d/
|
FROM php:8.2-fpm-alpine3.17 AS app
|
||||||
|
|
||||||
|
# wkhtmltopdf install dependencies
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
libstdc++ \
|
||||||
|
libx11 \
|
||||||
|
libxrender \
|
||||||
|
libxext \
|
||||||
|
libssl1.1 \
|
||||||
|
ca-certificates \
|
||||||
|
fontconfig \
|
||||||
|
freetype \
|
||||||
|
ttf-droid \
|
||||||
|
ttf-freefont \
|
||||||
|
ttf-liberation \
|
||||||
|
# more fonts
|
||||||
|
;
|
||||||
|
# wkhtmltopdf copy bins from ext image
|
||||||
|
COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/wkhtmltoimage /bin/libwkhtmltox.so /usr/bin/
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Copied from previous Streamline Dockerfile
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Install necessary packages and cleanup
|
||||||
|
RUN set -ex; \
|
||||||
|
apk update && \
|
||||||
|
apk add --no-cache curl gnupg mysql mysql-client pwgen && \
|
||||||
|
docker-php-ext-install pdo pdo_mysql && \
|
||||||
|
rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
|
# Install Composer
|
||||||
|
RUN curl -sS https://getcomposer.org/installer | \
|
||||||
|
php -- --install-dir=/usr/bin/ --filename=composer
|
||||||
|
|
||||||
|
# Set the working directory and copy the application code
|
||||||
|
COPY streamline-src /var/www/html
|
||||||
|
|
||||||
|
COPY my.cnf /etc/mysql/my.cnf
|
||||||
|
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
# Create the 'streamline' user and adjust permissions
|
||||||
|
RUN addgroup -g 1000 streamline && adduser -G streamline -g streamline -s /bin/sh -D streamline && \
|
||||||
|
composer install && \
|
||||||
|
chmod -R 777 /var/www/html/storage/ && \
|
||||||
|
chown -R streamline:streamline /var/www/html && \
|
||||||
|
mkdir -p /docker-entrypoint-initdb.d/
|
||||||
|
|
||||||
|
# Initialize MySQL
|
||||||
|
COPY streamline_initial.sql /docker-entrypoint-initdb.d/
|
||||||
|
|
||||||
|
RUN mkdir /scripts && \
|
||||||
|
mkdir /scripts/pre-exec.d && \
|
||||||
|
mkdir /scripts/pre-init.d && \
|
||||||
|
chmod -R 755 /scripts
|
||||||
|
|
||||||
|
VOLUME ["/var/lib/mysql"]
|
||||||
|
|
||||||
|
# Set the startup script as executable
|
||||||
|
RUN chmod +x /var/www/html/start_up.sh
|
||||||
|
|
||||||
|
# Define the entry point and expose port 80, 3306
|
||||||
|
ENTRYPOINT ["/bin/sh", "/var/www/html/start_up.sh"]
|
||||||
|
|
||||||
|
EXPOSE 80 3306
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Update snappy config to fix issues with wkhtmltopdf
|
||||||
|
################################################################################
|
||||||
|
COPY snappy.php /var/www/html/config/snappy.php
|
||||||
@@ -1,9 +1,33 @@
|
|||||||
# FROM streamlinehealth/streamline:signalytic
|
################################################################################
|
||||||
|
# Use known working image to pull in working wkhtmltopdf libraries
|
||||||
|
# ref: https://stackoverflow.com/questions/56426050/how-to-install-wkhtmltopdf-on-docker-php-fpm-alpine-linux
|
||||||
|
################################################################################
|
||||||
|
|
||||||
# COPY my.cnf /etc/mysql/my.cnf
|
FROM surnet/alpine-wkhtmltopdf:3.16.2-0.12.6-full as wkhtmltopdf
|
||||||
# COPY mysql-init.sh /var/www/html/.docker/mysql/mysql-init.sh
|
FROM php:8.2-fpm-alpine3.17 AS app
|
||||||
|
|
||||||
FROM php:8.2-fpm-alpine
|
# wkhtmltopdf install dependencies
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
libstdc++ \
|
||||||
|
libx11 \
|
||||||
|
libxrender \
|
||||||
|
libxext \
|
||||||
|
libssl1.1 \
|
||||||
|
ca-certificates \
|
||||||
|
fontconfig \
|
||||||
|
freetype \
|
||||||
|
ttf-droid \
|
||||||
|
ttf-freefont \
|
||||||
|
ttf-liberation \
|
||||||
|
# more fonts
|
||||||
|
;
|
||||||
|
# wkhtmltopdf copy bins from ext image
|
||||||
|
COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/wkhtmltoimage /bin/libwkhtmltox.so /usr/bin/
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Copied from previous Dockerfile (v1-rc4)
|
||||||
|
################################################################################
|
||||||
|
|
||||||
# Install necessary packages and cleanup
|
# Install necessary packages and cleanup
|
||||||
RUN set -ex; \
|
RUN set -ex; \
|
||||||
@@ -47,3 +71,9 @@ RUN chmod +x /var/www/html/start_up.sh
|
|||||||
ENTRYPOINT ["/bin/sh", "/var/www/html/start_up.sh"]
|
ENTRYPOINT ["/bin/sh", "/var/www/html/start_up.sh"]
|
||||||
|
|
||||||
EXPOSE 80 3306
|
EXPOSE 80 3306
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Update snappy config to fix issues with wkhtmltopdf
|
||||||
|
################################################################################
|
||||||
|
COPY snappy.php /var/www/html/config/snappy.php
|
||||||
Executable
+56
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$pdfPath = '/usr/bin/wkhtmltopdf';
|
||||||
|
$imagePath = '/usr/bin/wkhtmltoimage';
|
||||||
|
|
||||||
|
return [
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Snappy PDF / Image Configuration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option contains settings for PDF generation.
|
||||||
|
|
|
||||||
|
| Enabled:
|
||||||
|
|
|
||||||
|
| Whether to load PDF / Image generation.
|
||||||
|
|
|
||||||
|
| Binary:
|
||||||
|
|
|
||||||
|
| The file path of the wkhtmltopdf / wkhtmltoimage executable.
|
||||||
|
|
|
||||||
|
| Timout:
|
||||||
|
|
|
||||||
|
| The amount of time to wait (in seconds) before PDF / Image generation is stopped.
|
||||||
|
| Setting this to false disables the timeout (unlimited processing time).
|
||||||
|
|
|
||||||
|
| Options:
|
||||||
|
|
|
||||||
|
| The wkhtmltopdf command options. These are passed directly to wkhtmltopdf.
|
||||||
|
| See https://wkhtmltopdf.org/usage/wkhtmltopdf.txt for all options.
|
||||||
|
|
|
||||||
|
| Env:
|
||||||
|
|
|
||||||
|
| The environment variables to set while running the wkhtmltopdf process.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'pdf' => [
|
||||||
|
'enabled' => true,
|
||||||
|
'binary' => $pdfPath,
|
||||||
|
'timeout' => false,
|
||||||
|
'options' => [
|
||||||
|
'enable-local-file-access' => true
|
||||||
|
],
|
||||||
|
'env' => [],
|
||||||
|
],
|
||||||
|
'image' => [
|
||||||
|
'enabled' => true,
|
||||||
|
'binary' => $imagePath,
|
||||||
|
'timeout' => false,
|
||||||
|
'options' => [
|
||||||
|
'enable-local-file-access' => true
|
||||||
|
],
|
||||||
|
'env' => [],
|
||||||
|
],
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user