To prove the advantages of Alpaquita containers vs the default way to run Java applications, we ran multiple tests that you can replicate.
Install the pack utility. Check this guide for the instructions.
Edit pom.xml
:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<name>paketo-maven</name>
<builder>bellsoft/buildpacks.builder:musl</builder>
</image>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Build the image with Maven: mvn spring-boot:build-image
Launch the container: docker run paketo-maven
Install the pack utility. Check this guide for the instructions.
Edit pom.xml
:
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.6'
id 'io.spring.dependency-management' version '1.1.0'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
bootBuildImage {
imageName = "paketo-gradle"
builder = "bellsoft/buildpacks.builder:musl"
}
Build the image with Maven: gradle bootBuildImage
Launch the container: docker run paketo-gradle
Install the pack utility. Check this guide for the instructions.
Edit pom.xml
:
plugins {
java
id("org.springframework.boot") version "3.0.6"
id("io.spring.dependency-management") version "1.1.0"
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.bootBuildImage {
imageName.set("paketo-gradle-kotlin")
builder.set("bellsoft/buildpacks.builder:musl")
}
Build the image with Maven: gradle bootBuildImage
Launch the container: docker run paketo-gradle-kotlin
If you don't have a project ready for testing, visit Spring Initilizr and create it there. It will contain all the dependencies, so all you will have to do is add the configuration for bootBuildImage
, or run pack with required parameters.
In this example, we use Spring Petclinic as the application we put into the buildpack. You can use your app instead when you are ready.
The following code will return a copy of Petclinic from the most recent commit at the time of writing of this tutorial:
curl -L https://github.com/spring-projects/spring-petclinic/archive/a5cbb8505a1df3c348c06607933a07fc8c87c222.zip --output spring-petclinic-main.zip
unzip ./spring-petclinic-main.zip
mv ./spring-petclinic-a5cbb8505a1df3c348c06607933a07fc8c87c222 ./spring-petclinic-main
cd ./spring-petclinic-main && ./mvnw package
After you finish building your container, you can check out its size, the version of Alpaquita inside, and the contents of the package. See for yourself how Packeto buildpacks creates the production-ready Docker images with Alpaquita inside!
This is the list of useful Docker commands that may help.
To check how much disk space the image takes, run
docker image ls demo-app
The result should be similar to the output below:
REPOSITORY TAG IMAGE ID CREATED SIZE demo-app latest 24ac5ac02b2a 43 years ago 152MB
To find out the OS version in package, run
docker run --rm -it --entrypoint /bin/cat demo-app /etc/os-release
For our image, the result should be:
NAME="BellSoft Alpaquita Linux Stream" ID=alpaquita ID_LIKE=alpine VERSION_ID=23 PRETTY_NAME="BellSoft Alpaquita Linux Stream 23 (musl)" HOME_URL="https://bell-sw.com/" BUG_REPORT_URL="https://bell-sw.com/support/" LIBC_TYPE=musl
Last but not least, let’s see what is inside the container built by Paketo without unpacking it. Run the following command (which is built into the Paketo):
pack inspect demo-app
If you used the Petclinic app, the result will likely be the following:
Inspecting image: demo-app REMOTE: (not present) LOCAL: Stack: io.buildpacks.stacks.alpaquita-musl Base Image: Reference: 116beca369efbba0a9dfff7361b7ce7c302cac684904ddc365e7d6ba82505f58 Top Layer: sha256:7caddaa60b9c1ca8f0dfa5882f96239493ef54e94e5e8c47ddf84745186eff35 Run Images: bellsoft/buildpacks.alpaquita-run:musl Buildpacks: ID VERSION HOMEPAGE bellsoft/buildpacks/liberica 1.0.0 https://github.com/bell-sw/buildpacks/liberica paketo-buildpacks/syft 1.26.0 https://github.com/paketo-buildpacks/syft paketo-buildpacks/gradle 6.11.0 https://github.com/paketo-buildpacks/gradle paketo-buildpacks/maven 6.13.0 https://github.com/paketo-buildpacks/maven paketo-buildpacks/executable-jar 6.6.1 https://github.com/paketo-buildpacks/executable-jar paketo-buildpacks/spring-boot 5.23.0 https://github.com/paketo-buildpacks/spring-boot Processes: TYPE SHELL COMMAND ARGS WORK DIR web (default) java -jar /workspace/spring-petclinic-3.0.0.jar /workspace executable-jar java -jar /workspace/spring-petclinic-3.0.0.jar /workspace task java -jar /workspace/spring-petclinic-3.0.0.jar /workspace