Skip to content

Unbundled binaries - #129

Open
joeyparis wants to merge 9 commits into
zakird:masterfrom
joeyparis:unbundled-binaries
Open

Unbundled binaries#129
joeyparis wants to merge 9 commits into
zakird:masterfrom
joeyparis:unbundled-binaries

Conversation

@joeyparis

@joeyparis joeyparis commented Mar 4, 2022

Copy link
Copy Markdown

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

Comment thread docker-compose.yml
Comment thread test/test_with_docker.rb
RUN pacman -Sy --noconfirm ruby fontconfig freetype2 libjpeg libpng libxext libxrender

WORKDIR /root/wkhtmltopdf_binary_gem
COPY . .

Copy link
Copy Markdown

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
Copy Markdown
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

natebird commented Aug 1, 2022

Copy link
Copy Markdown
Contributor

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