5

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?

Bartosz Bilicki
  • 12,599
  • 13
  • 71
  • 113
  • Check out this SO question. It's very similar and I think it'll answer your question. [Is it possible to customize docker image generated with Spring Native (with buildpack)](https://stackoverflow.com/questions/69447497/is-it-possible-to-customize-docker-image-generated-with-spring-native-with-buil) – Daniel Mikusa Nov 03 '21 at 01:44

1 Answers1

1

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
Michael Piefel
  • 18,660
  • 9
  • 81
  • 112