Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbundled binaries #129

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

joeyparis
Copy link

@joeyparis joeyparis commented Mar 4, 2022

After 0.12.5 the gem size more than quadrupled inside because of a change to how wkhtmltopdf generates their binaries. This pull request removes the bundled binaries and instead downloads the appropriate binary from https://wkhtmltopdf.org/downloads.html based on the operating system and CPU architecture.

This pull request reduces the gem size down to just 6.5K. It also adds support for Amazon Linux 2, which did not appear to be working properly before.

Test Confirmed Supported Platforms

Amazon Linux 2
Arch Linux
CentOS 6
CentOS 7
CentOS 8
Debian 9
Debian 10
Rocky Linux 8
Ubuntu 16
Ubuntu 18
Ubuntu 20
macOS (Can't seem to run on M1 mac)

Caveats

  • The list of download URLs is hardcoded from links pulled from the official website. Ideally, it would reference some sort of remote list, but I didn't want to rely on the download page keeping a consistent layout.
  • The binary isn't downloaded until the first time it is called. Some of the binaries can be a decent size making the first call take a decent number of seconds longer, maybe we should implement some sort of preload process

@@ -4,4 +4,8 @@ ENV DEBIAN_FRONTEND noninteractive

RUN pacman -Sy --noconfirm ruby fontconfig freetype2 libjpeg libpng libxext libxrender

WORKDIR /root/wkhtmltopdf_binary_gem
COPY . .
Copy link

Choose a reason for hiding this comment

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

This repo too heavy to copy all into the image. Why you copy it? We could mount directly repo folder to run

Copy link
Author

Choose a reason for hiding this comment

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

This PR is specifically to make this repo not heavy

@natebird
Copy link
Contributor

natebird commented Aug 1, 2022

This would be great. Building a docker image with this gem creates a lot of unnecessary bloat to that base image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants