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

doesn't work on Alpine #53

Open
pierresomos opened this issue Jul 2, 2019 · 16 comments
Open

doesn't work on Alpine #53

pierresomos opened this issue Jul 2, 2019 · 16 comments

Comments

@pierresomos
Copy link

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

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

@pierresomos
Copy link
Author

@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
Copy link

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

@cesc1989
Copy link

cesc1989 commented Oct 23, 2019

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

webaholik commented Nov 8, 2019

Anyone experiencing this issue with latest?

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

INSTALL
gem install wkhtmltopdf-binary

@james-prodigy
Copy link

also having issues, managed to get it to work following these instructions:
wkhtmltopdf/wkhtmltopdf#3265 (comment)

@matheusvetor
Copy link

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

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

@pedrofurtado
Copy link
Contributor

pedrofurtado commented Jul 23, 2021

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

@reiz
Copy link
Contributor

reiz commented Oct 17, 2021

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

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
Copy link
Contributor

reiz commented Jan 2, 2022

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

amanfrinati commented Jul 17, 2023

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

PedroAugustoRamalhoDuarte commented Aug 25, 2023

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

jotolo commented Aug 29, 2024

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.

khalilgharbaoui/wkhtmltopdf-binary-edge-alpine#4 (comment)

@amanfrinati
Copy link

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.

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

No branches or pull requests