Docker – from debian to scratch – how to migrate?

  debian-buster, dockerfile

i am trying to build a minimalistic docker image for one of my applicatoins

in my "usual" builds i do not rely on 3rd party applications. This time I need to include a precompiled executeable (xpdf) to the build; My go applications are prebuilt in a builder Docker and then copied over (no dependencies).

my current Dockerimage file looks like this: (working!) application launches

FROM debian:buster-slim
COPY ./bin64/pdftopng .
COPY ./config/xpdfrc .
# ... copy FONT files
# copy Test PDF
COPY ./test.pdf .
RUN chmod +x pdftopng
RUN apt-get update && apt-get install -y libfontconfig1
# execute pdftopng
ENTRYPOINT ["/pdftopng", "-cfg", "xpdfrc", "/test.pdf", "/test.pdf"]

as this results in a image file with over 100mb i tried to use scratch as a base (which usually results in images around 10-20mb)

FROM scratch
# ... copy my binaries to the docker
COPY --from=builder /dist/main /
# copy the XPDF -> pdf to png executeable (linux x64)
COPY ./bin64/pdftopng .
# copy font files (for this example i only copy one)
COPY ./fonts/n021003l.pfb /fonts/n021003l.pfb
# copy config file
COPY ./config/xpdfrc .
# copy test file
COPY ./test.pdf .
# execute the XPDF converter and convert the test.pdf to png
ENTRYPOINT ["/pdftopng", "-cfg", "xpdfrc", "/test.pdf", "test"]

outputs:

standard_init_linux.go:219: exec user process caused: no such file or directory

this error is the result of a missing library (something related to libfontconfig1)
how can i find out which files are missing (as i do have a working container this should be possible)

Source: Dockerfile Questions

LEAVE A COMMENT