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:
2024-05-01 17:03:14 -07:00
parent 5e1cb0d8b4
commit a47c7b3d98
3 changed files with 167 additions and 7 deletions
+34 -4
View File
@@ -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
# COPY mysql-init.sh /var/www/html/.docker/mysql/mysql-init.sh
FROM surnet/alpine-wkhtmltopdf:3.16.2-0.12.6-full as wkhtmltopdf
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
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"]
EXPOSE 80 3306
################################################################################
# Update snappy config to fix issues with wkhtmltopdf
################################################################################
COPY snappy.php /var/www/html/config/snappy.php