Surnet / docker-wkhtmltopdf

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

/bin/sh: wkhtmltopdf: not found #35

Closed yuertongle-fs closed 1 year ago

yuertongle-fs commented 1 year ago

Below is my Dockerfile

FROM surnet/alpine-wkhtmltopdf:3.15.0-0.12.6-small as wkhtmltopdf
FROM fundingsocietiesdocker/golang:1.18.0-alpine3.15

# Set destination for COPY
WORKDIR /app
USER root

# Install dependencies for wkhtmltopdf
RUN apk add --no-cache \
    libstdc++ \
    libx11 \
    libxrender \
    libxext \
    libssl1.1 \
    ca-certificates \
    fontconfig \
    freetype \
    ttf-dejavu \
    ttf-droid \
    ttf-freefont \
    ttf-liberation \
    # more fonts
  && apk add --no-cache --virtual .build-deps \
    msttcorefonts-installer \
  # Install microsoft fonts
  && update-ms-fonts \
  && fc-cache -f \
  # Clean up when done
  && rm -rf /tmp/* \
  && apk del .build-deps

# Copy wkhtmltopdf files from docker-wkhtmltopdf image
COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/wkhtmltopdf
COPY --from=wkhtmltopdf /bin/libwkhtmltox* /bin/
RUN chmod +x /bin/wkhtmltopdf

#for installing GCC
RUN apk add build-base

# Download Go modules
COPY go.mod .
COPY go.sum .
RUN go mod download

# Copy the source code. Note the slash at the end, as explained in
# https://docs.docker.com/engine/reference/builder/#copy
COPY *.go ./
COPY *.html ./

# Build
RUN go build -o /docker-gs-ping

# This is for documentation purposes only.
# To actually open the port, runtime parameters
# must be supplied to the docker command.
EXPOSE 8080

# (Optional) environment variable that our dockerised
# application can make use of. The value of environment
# variables can also be set via parameters supplied
# to the docker command on the command line.
#ENV HTTP_PORT=8081

# Run
CMD [ "/docker-gs-ping" ]

after I build the image and run it, I got below in the container -> terminal

/app # which wkhtmltopdf
/bin/wkhtmltopdf
/app # 
/app # 
/app # 
/app # wkhtmltopdf
/bin/sh: wkhtmltopdf: not found
jpjonte commented 1 year ago

Same issue here, using this Dockerfile from the readme:

https://github.com/Surnet/docker-wkhtmltopdf#other-images

Edit: Just realized this issue only occurs with my custom base image. If I use the normal alpine image everything works. I'll have to investigate further. So far it looks like an arch issue with my base image.

jpjonte commented 1 year ago

Update: In my case the issue was that the base image wasn't available for the architecture I was building on (arm64). After rebuilding my base image for both amd64 and arm64 I was able to build and use wkhtmltopdf.

@yuertongle-fs are you building on an arm machine? As far as I can tell, your base image fundingsocietiesdocker/golang is only available for amd64. Perhaps that is your issue, too.

yuertongle-fs commented 1 year ago

amd64

Ah, I see. Should be for the machine I'm using. I'm running the docker on Apple M1(ARM-based system)

chdanielmueller commented 1 year ago

Thanks @jpjonte that you did troubleshoot this and post your solution. I'm closing this issue as solved.