zakird / wkhtmltopdf_binary_gem

Ruby gem containing easily installable access to wkhtmltopdf application
https://rubygems.org/gems/wkhtmltopdf-binary
Apache License 2.0
182 stars 347 forks source link

doesn't work on Alpine #53

Open pierresomos opened 5 years ago

pierresomos commented 5 years ago

I'm using docker image ruby:2.6.3-alpine and this gem didn't work. To work, you have to install by apk add wkhtmltopdf

mariusz-blaszczak commented 5 years ago

Just installing the wkhtmltopdf did not help me. I followed this instructions and it helped me: https://stackoverflow.com/a/56971343/847670

pierresomos commented 5 years ago

@blaszczakphoto hi, after you have installed, did wkhtmltopdf command available on OS? I have got this error because in my $PATH there wasn't /usr/bin path

mariusz-blaszczak commented 5 years ago

yes, it was available in the console. I could type wkhtmltopdf and to the help instructions.

cesc1989 commented 4 years ago

I can confirm this as of today.

I was using the gem for production environment in a ruby:2.5.3-alpine Docker image and it would not work.

Left the gem for development and installed wkhtmltopdf in the image and now it's working.

If using gem wicked_pdf we need to specify the exe_path where wkhtmltopdf is now installed.

webaholik commented 4 years ago

Anyone experiencing this issue with latest?

GEMFILE gem 'wkhtmltopdf-binary', '~> 0.12.5'

INSTALL gem install wkhtmltopdf-binary

james-prodigy commented 4 years ago

also having issues, managed to get it to work following these instructions: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3265#issuecomment-542653586

matheusvetor commented 4 years ago

Assuming your gems are located in /bundle, you could add after bundle install:

RUN apk add wkhtmltopdf
RUN cd /bundle/ruby/*/gems/wkhtmltopdf-binary-*/bin && ln -s /usr/bin/wkhtmltopdf wkhtmltopdf_"$(. /etc/os-release 2> /dev/null && echo ${ID}_${VERSION_ID})"_amd64

It's ugly but works like a charm

khalilgharbaoui commented 4 years ago

https://github.com/khalilgharbaoui/wkhtmltopdf-binary-edge-alpine for version 0.12.5 on alpine

pedrofurtado commented 3 years ago

@unixmonkey Maybe we can close this issue 🤝 The other gems/repos are good alternatives, as mentioned by guys🥇

reiz commented 2 years ago

On Alpine Linux 3.14.2 you don't need the wkhtmltopdf-binary gem because it can be installed natively. I added the gem to the development group because I only need it on Mac OS X:

group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'rspec-rails'
  gem 'wkhtmltopdf-binary', '~> 0.12.6.5'
end

On Alpine Linux 3.14.2 the wkhtmltopd can be added like this natively:

apk add wkhtmltopdf;

With that it's globally available.

martinjozef commented 2 years ago

Hi There, since Alpine 3.15 this library has now been removed from their package repository. Having this project now support alpine is more important than ever, since a lot of applications now run in alpine docker containers. Thank you!

reiz commented 2 years ago

That's very bad news :-( In the Alpine release notes they recommend to use weasyprint, an alternative to wkhtmltopdf. Does anybody has experience with it?

amanfrinati commented 1 year ago

That's very bad news :-( In the Alpine release notes they recommend to use weasyprint, an alternative to wkhtmltopdf. Does anybody has experience with it?

Thanks for the suggestion, I will try it now. The package wkhtmltopdf was remove from Alpine starting from the version 3.15.

PedroAugustoRamalhoDuarte commented 1 year ago

This works for me in alpine 3.18 without using the binary gem:

############################ wkhtmltopdf binary ###############################
FROM surnet/alpine-wkhtmltopdf:3.18.0-0.12.6-small as wkhtmltopdf

############################ COPY APPLICATION FILES ###############################
FROM ruby:3.2.2-alpine as production
ARG RAILS_ENV='production'

ENV RAILS_ENV=$RAILS_ENV
ENV RAKE_ENV=$RAILS_ENV

RUN apk add --update 
                     fontconfig \
                     freetype \
                     libx11 \
                     ttf-dejavu \
                     libxrender

 COPY --from=wkhtmltopdf /bin/wkhtmltopdf /usr/bin/wkhtmltopdf
jotolo commented 1 month ago

If someone else is having these issues and need to use the binary you use one of these solutions. @PedroAugustoRamalhoDuarte That's the way to go IMHO.

https://github.com/khalilgharbaoui/wkhtmltopdf-binary-edge-alpine/issues/4#issuecomment-2318355270

amanfrinati commented 1 month ago

This works for me in alpine 3.18 without using the binary gem:

############################ wkhtmltopdf binary ###############################
FROM surnet/alpine-wkhtmltopdf:3.18.0-0.12.6-small as wkhtmltopdf

############################ COPY APPLICATION FILES ###############################
FROM ruby:3.2.2-alpine as production
ARG RAILS_ENV='production'

ENV RAILS_ENV=$RAILS_ENV
ENV RAKE_ENV=$RAILS_ENV

RUN apk add --update 
                     fontconfig \
                     freetype \
                     libx11 \
                     ttf-dejavu \
                     libxrender

 COPY --from=wkhtmltopdf /bin/wkhtmltopdf /usr/bin/wkhtmltopdf

Yeah @PedroAugustoRamalhoDuarte, I mean that the wkhtmltopdf package is no more present above Alpine 3.14. The solution that you suggest is also right for me: I got the binary from the same image repository.