buildpackspring-boot-gradle-pluginpaketo

Spring Boot in Docker build by buildpack cannot load Font


My Spring Boot application runs in Docker and is build by gradlew bootBuildImage. When run in Docker container application cannot load fonts

Caused by: java.lang.NullPointerException
    at java.desktop/sun.awt.FontConfiguration.getVersion(Unknown Source)

Root cause seems to be missing fontconfig and ttf-dejavu packages. When using Dockerfile, one can easily install those packages using apk add, yum, apt-get, etc

But https://github.com/paketo-buildpacks/spring-boot and https://github.com/paketo-buildpacks/bellsoft-liberica do not have option to install additional packages.

Is there buildpack (or configuration option) that will build Docker images with font support?


Solution

  • You can manipulate the image after the fact. A sample Dockerfile would look like this:

    FROM backend:latest
    
    USER root # root for apt
    RUN apt-get update && \
        apt-get install --assume-yes fontconfig && \
        rm -rf /var/lib/apt/lists/* /var/cache/debconf/*
    
    USER 1000:1000 # back to cnb user