How can a Linux library be added to a Spring Boot image?

53 Views Asked by At

This step would need to be added:

apt install -y libjemalloc-dev

Can this configuration be extended with or without a Dockerfile to include a library, in this case libjemalloc?

      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <image>
            <builder>paketobuildpacks/builder-jammy-base:latest</builder>
            <env>
              <BP_JVM_VERSION>21.*</BP_JVM_VERSION>
            </env>
          </image>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>build-info</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
1

There are 1 best solutions below

0
Andras Hatvani On

Just configure the Spring Boot Maven Plugin as follows:

      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <docker>
            <builderRegistry>
              <username>${env.DOCKER_REPOSITORY_USR}</username>
              <password>${env.DOCKER_REPOSITORY_PWD}</password>
              <url>${env.REPOSITORY_URL}</url>
            </builderRegistry>
          </docker>
          <image>
            <builder>${env.REPOSITORY_URL}/builder-image:snapshot</builder>
            <runImage>${env.REPOSITORY_URL}/builder-image:snapshot</runImage>
            <env>
              <BP_JVM_VERSION>21.*</BP_JVM_VERSION>
            </env>
          </image>
        </configuration>
      </plugin>

Where builder-image is a CNF builder, such as:

FROM paketobuildpacks/builder-jammy-base AS base

USER root

RUN apt update
RUN apt install -y libjemalloc-dev
RUN apt install -y google-perftools

USER cnb