Surnet / docker-wkhtmltopdf

wkhtmltopdf for multiple base images
https://hub.docker.com/u/surnet/
MIT License
360 stars 65 forks source link

Progress stuck on 10% when running on Mac #24

Closed alchermd closed 2 years ago

alchermd commented 2 years ago

My specs:

image

Minimal steps to reproduce:

$ docker run -it surnet/alpine-python-wkhtmltopdf:3.8.5-0.12.6-small-alpine12 sh
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
/ # wkhtmltopdf google.com google.pdf
Loading pages (1/6)
[======>                                                     ] 10%

I just tried the same on a Linux laptop (Linux Mint 20.1 Cinnamon), as well as in this Mac (in the host, not the container) and was able to execute without any hiccups:

$ wkhtmltopdf --version
wkhtmltopdf 0.12.6 (with patched qt)
$ wkhtmltopdf google.com google.pdf
Loading pages (1/6)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done

Upon further debugging, executing the non-python version of this image seems to work just fine:

$ docker run -it --entrypoint sh surnet/alpine-wkhtmltopdf:3.13.5-0.12.6-small
/ # wkhtmltopdf google.com test.pdf
Loading pages (1/6)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done

For completion's sake here's my project's Docker related information:

My Dockerfile:

FROM surnet/alpine-python-wkhtmltopdf:3.8.5-0.12.6-small-alpine12

# set work directory
WORKDIR /usr/src/web

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install psycopg2 dependencies
RUN apk update \
  && apk add postgresql-dev gcc python3-dev musl-dev \
# install Pillow dependencies
     gcc jpeg-dev zlib-dev

# install dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt

# copy project
COPY . .

# run entrypoint.sh
ENTRYPOINT ["/usr/src/web/entrypoint.sh"]

My docker-compose.yml file

version: '3.7'

services:
  web:
    build: ./web
    command: python manage.py runserver 0.0.0.0:80
    volumes:
      - ./web/:/usr/src/web/
      - media_volume:/usr/src/web/media
    ports:
      - 8000:80
    env_file:
      - ./env/.env.dev
  db:
    image: postgres:12.0-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    environment:
      - POSTGRES_DB=<snip>
      - POSTGRES_USER=<snip>
      - POSTGRES_PASSWORD=<snip>
volumes:
  postgres_data:
  media_volume:

Steps to replicate on my project:

$ docker-compose up -d --build
$ docker-compose exec web sh
/usr/src/ # ./wkhtmltopdf google.com test.pdf
Loading pages (1/6)
[======>                                                     ] 10%

Please let me know if I need to provide more information. Thank you for this project!

chdanielmueller commented 2 years ago

Please try with version 3.9.5-0.12.6-small On this page you can see all the versions which support the arm64 architecture which at the moment is just this specific version: https://hub.docker.com/r/surnet/alpine-python-wkhtmltopdf/tags

alchermd commented 2 years ago

Thank you @chdanielmueller , this works!

chdanielmueller commented 2 years ago

Great! Thanks for the feedback