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

Building from sources ERR005 #538

Closed
reypm-provest opened this issue Jan 31, 2025 · 4 comments
Closed

Building from sources ERR005 #538

reypm-provest opened this issue Jan 31, 2025 · 4 comments
Assignees
Labels
investigating Investigating the issue

Comments

@reypm-provest
Copy link

reypm-provest commented Jan 31, 2025

Coming from #537 I am trying to get htmldoc build from sources using Docker containers and this is what my Dockerfile looks like:

#syntax=docker/dockerfile:1.4

#syntax=docker/dockerfile:1.4

FROM alpine:3.21 AS htmldoc
RUN apk add --no-cache --upgrade  \
    build-base \
    gcc \
    binutils \
    binutils-doc \
    gcc-doc \
    g++ \
    make \
    autoconf \
    automake \
    libtool \
    imagemagick \
    imagemagick-dev \
    lcms2 \
    fontconfig \
    freetype \
    zlib \
    zlib-dev  \
    libpng-dev  \
    freetype-dev \
    jpeg-dev \
    openssl-dev \
    wget \
    tar \
    git \
    cups-dev

RUN git clone https://github.com/michaelrsweet/htmldoc
RUN cd htmldoc && \
    ./configure && \
    make && \
    make install

After build the htmldoc in a stage I am using the binary in another image as follow:

FROM php:8.3-fpm-alpine as php_web
RUN apk add --no-cache --upgrade \
    unzip \
    zip \
    curl \
    wget \
    git \
    tzdata \
    gcompat \
    poppler-utils \
    util-linux \
    libdmtx \
    libdmtx-libs \
    cups-libs \
    libpng \
    libjpeg \
    ghostscript \
    nano

COPY --from=htmldoc /usr/local/bin/htmldoc /usr/local/bin/htmldoc
COPY --from=htmldoc /htmldoc/data /usr/local/share/htmldoc/data
COPY --from=htmldoc /htmldoc/fonts /usr/local/share/htmldoc/fonts

EXPOSE 9000
ENTRYPOINT ["php-fpm", "--nodaemonize"]

running htmldoc --version inside that image returns 1.9.21 which means the binary gets build and is copied over to the destination image, generate a PDF is "working" but I cannot get image served through http/https to be part of the generated PDF. This is how the HTML looks like:

This is an example HTML that is not working for me at the moment:

<!DOCTYPE html>
<html>
<head>Hunting a bug with images and htmldoc</head>
<body>
  <p>Before</p>
  <img align="left" src="http://localhost/script.php?generate_image=1" />
  <img align="left" src="http://service-name/script.php?generate_image=1" />
  <img align="left" src="http://172.0.0.2/script.php?generate_image=1" />

  <img align="left" src="https://localhos/script.php?generate_image=1" />
  <img align="left" src="https://service-name/script.php?generate_image=1" />
  <img align="left" src="https://172.0.0.2/script.php?generate_image=1" />
  <p>After</p>
</body>
</html>

None of the above links work and I end up with the following "error" in the docker logs:

web-app-fpm-1 | ERR010: Unable to connect to localhost:80 - Host is down
web-app-fpm-1 | PAGES: 1

This is the command I am using to generate the PDF from the command line:

/usr/local/bin/htmldoc -t pdf13 -f /tmp/tmp.pdf --webpage --no-title --linkstyle underline --size Letter --left .1in --right .1in --top 0.1in --bottom 0.05in --header ... --footer ... --nup 1 --tocheader .t. --tocfooter ..i --portrait --color --no-pscommands --no-xrxcomments --compression=1 --jpeg=0 --fontsize 11.0 --fontspacing 1.2 --headingfont Courier --bodyfont Courier --headfootsize 24.0 --headfootfont Courier-Bold --charset iso-8859-1 --links --no-embedfonts --pagemode document --pagelayout single --firstpage p1 --pageeffect none --pageduration 10 --effectduration 1.0 --no-encryption --permissions all  --owner-password \"\" --user-password \"\" --browserwidth 680 /tmp/test.html

is there any way to debug this to check if a library is missing or what is the root cause?

@michaelrsweet
Copy link
Owner

The updated error message shows that HTMLDOC is unable to connect to the server:

Unable to connect to localhost:80 - Host is down

As I am unfamiliar with Alpine Linux, does it provide any firewall or kernel security features (SELinux, AppArmor, etc.)? Are there messages getting logged to any of the system logs about HTMLDOC?

@michaelrsweet michaelrsweet self-assigned this Feb 1, 2025
@michaelrsweet michaelrsweet added the investigating Investigating the issue label Feb 1, 2025
@reypm-provest
Copy link
Author

does it provide any firewall or kernel security features (SELinux, AppArmor, etc.)

yes, there are firewall for AlpineLinux but none of them comes enabled by default and I am not enabling it either.

Are there messages getting logged to any of the system logs about HTMLDOC?

no as far as I can tell.

Is there a way to add more verbose debugging so we can check what is going on here?

@michaelrsweet
Copy link
Owner

Is there a way to add more verbose debugging so we can check what is going on here?

The "host is down" message (EHOSTUNREACH) is the one coming from the connect call inside libcups. This means that there is something preventing HTMLDOC from making the connection to the specific address - you'd probably also see a problem pinging the address (something you could test).

@reypm-provest
Copy link
Author

Ok, turns out that I was wrongly connecting to the wrong Docker container, PHP-FPM does not run any web server, I have Apache running in a different container. Pointing the URL to the Apache container makes that error go away. This is working as expected. Closing this

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

No branches or pull requests

2 participants