Building docker image with spring boot 2.4.1 failes with "Missing 'io.buildpacks.stack.id' stack label" when behind a firewall - spring

I'm, trying to build a docker image with ./mvnw -DskipTests spring-boot:build-image using spring boot 2.4.1 and java 11 (openjdk version "11.0.9" 2020-10-20 LTS) on RHEL7.
I do this on a host behind a strict firewall so I have to fetch the build- and runimage from a private repo. I have configured the spring-boot-maven-plugin to use this repo:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<docker>
<builderRegistry>
<username>my-username</username>
<password>xxx</password>
<url>https://my-mirror.com</url>
<email>kaj.hejer#usit.uio.no</email>
</builderRegistry>
</docker>
<image>
<builder>my-mirror.com/library/docker.io-paketobuildpacks-builder:base</builder>
<runImage>my-mirror.com/library/docker.io-paketobuildpacks-run:base</runImage>
<name>my-mirror.com/my-group/my-app:latest</name>
<verboseLogging>true</verboseLogging>
</image>
</configuration>
</plugin>
The build fails with
[INFO] > Pulling builder image 'my-mirror.com/library/docker.io-paketobuildpacks-builder:base' 100%
[INFO] > Pulled builder image 'my-mirror.com/library/docker.io-paketobuildpacks-builder#sha256:cf90221a33966e42f8b1960123dea4406c65fc6a410142ded573ed850ccc313b'
[INFO] > Pulling run image 'my-mirror.com/library/docker.io-paketobuildpacks-run:base' 100%
[INFO] > Pulled run image 'my-mirror.com/library/docker.io-paketobuildpacks-run#sha256:56fb7587103da155db6d4f9434fd7e2f9e45d7540a062847fd84e9132a28101b'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.090 s
[INFO] Finished at: 2020-12-17T08:36:48+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.1:build-image (default-cli) on project my-app: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.1:build-image failed: Missing 'io.buildpacks.stack.id' stack label -> [Help 1]
[ERROR]
When I try to build a docker image the same way but without the configuration block for the spring-boot-maven-plugin on my mac which is not behind a firewall it works just fine.
Can it be SELinux releated in some way? sudo journalctl -f don't list anything when running the mvnw command.
Thanks in advance for any input or ideas!
-Kaj :)

On https://github.com/spring-projects/spring-boot/issues/24641 we found that I used the tag base instead of base-cnb. With tag base-cnb it worked fine.
Now I got a [creator] ERROR: failed to initialize docker client: failed to connect to docker socket: dial unix /var/run/docker.sock: connect: permission denied but that is not related to this question.

Related

spring boot maven plugin build-image is not working

I created demo project from start.spring.io with spring boot version 3.0.1 and java version 17.
I tried to execute below command on terminal to build Docker image
mvn spring-boot:build-image -Dspring-boot.build-image.imageName=testtesttest
It resulted in error
[INFO] [creator] $BPL_JVM_THREAD_COUNT 250 the number of threads in memory calculation
[INFO] [creator] $JAVA_TOOL_OPTIONS the JVM launch flags
[INFO] [creator] Using Java version 18 extracted from MANIFEST.MF
[INFO] [creator] No valid JRE available, providing matching JDK instead. Using a JDK at runtime has security implications.
[INFO] [creator] : Contributing to layer
[INFO] [creator] Warning: Dependency has no SHA256. Skipping cache.
[INFO] [creator] Downloading from
[INFO] [creator] unable to invoke layer creator
[INFO] [creator] unable to get dependency
[INFO] [creator] unable to download
[INFO] [creator] unable to request
[INFO] [creator] Get "": unsupported protocol scheme ""
[INFO] [creator] ERROR: failed to build: exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.756 s
[INFO] Finished at: 2023-01-02T15:18:19+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.1:build-image (default-cli) on project demo: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:3.0.1:build-image failed: Builder lifecycle 'creator' failed with status code 51 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
I am using openjdk (version "18.0.2" 2022-07-19) on mac. Not able to figure it out. Can you please help.
Looks like the default image builder doesn't yet support Mac M1 processor. I had to add an alternative builder for maven plugin in my pom.xml as shown below:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<builder>dashaun/builder:tiny</builder>
</image>
</configuration>
</plugin>

create spring boot 2.7 'mvn spring-boot:build-image' with podman on macOS failed

I try to create an image with mvn spring-boot:build-image using podman but got
[INFO] --- spring-boot-maven-plugin:2.7.0:build-image (default-cli) # sample-spring-service ---
[INFO] Building image 'docker.io/library/sample-spring-service:1.0.0-SNAPSHOT'
[INFO]
[INFO] > Pulling builder image 'docker.io/paketobuildpacks/builder:base' 100%
[INFO] > Pulled builder image 'docker.io/paketobuildpacks/builder#sha256:94e65320ba1682bc68cbbf1d4f63693bb62cc06c7077bfa3e3bccac7fdc10628'
[INFO] > Pulling run image 'docker.io/paketobuildpacks/run:base-cnb' 100%
[INFO] > Pulled run image 'docker.io/paketobuildpacks/run#sha256:3e889016680c0e2ef1e8b1bfdad2d6d34966c860a53ccfcfb3e269d48ed65fed'
[INFO] > Executing lifecycle version v0.14.1
[INFO] > Using build cache volume 'pack-cache-744ddec35876.build'
[INFO]
[INFO] > Running creator
[INFO] [creator] ERROR: initializing analyzer: getting previous image: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info": dial unix /var/run/docker.sock: connect: permission denied
podman info:
host:
arch: amd64
buildahVersion: 1.26.1
cgroupControllers:
...
version:
APIVersion: 4.1.0
Built: 1651853754
BuiltTime: Fri May 6 18:15:54 2022
GitCommit: ""
GoVersion: go1.18
Os: linux
OsArch: linux/amd64
Version: 4.1.0
I already tried a lot. Set permissions on socket, run podman with root. The same with docker is working well.
podman create alpine ls works fine.
In my pom.xml I tried:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<docker>
<!-- <host>unix:///Users/mike/.local/share/containers/podman/machine/podman-machine-default/podman.sock</host>
<host>unix:///run/user/1000/podman/podman.sock</host>
-->
<bindHostToBuilder>true</bindHostToBuilder>
</docker>
</configuration>
</plugin>
Any idea?
Update:
If I enable this line in pom.xml:
unix:///run/user/1000/podman/podman.sock
I get:
[INFO] --- spring-boot-maven-plugin:2.7.0:build-image (default-cli) # sample-spring-service ---
[INFO] Building image 'docker.io/library/sample-spring-service:1.0.0-SNAPSHOT'
[INFO]
[INFO] I/O exception (java.io.IOException) caught when processing request to {}->docker://localhost:2376: com.sun.jna.LastErrorException: [2] No such file or directory
[INFO] Retrying request to {}->docker://localhost:2376
[INFO] I/O exception (java.io.IOException) caught when processing request to {}->docker://localhost:2376: com.sun.jna.LastErrorException: [2] No such file or directory
[INFO] Retrying request to {}->docker://localhost:2376
[INFO] I/O exception (java.io.IOException) caught when processing request to {}->docker://localhost:2376: com.sun.jna.LastErrorException: [2] No such file or directory
[INFO] Retrying request to {}->docker://localhost:2376
[INFO] > Pulling builder image 'docker.io/paketobuildpacks/builder:base' 100%
For anyone who runs into a similar issue with spring boot build-image, for example when using remote docker hosts
From what I understand:
the pull is done using your docker parameters in pom.xml or environment variables like DOCKER_HOST
Once the pull has been completed, creator will start a new container and run the next commands in this newly container
The connection to docker in the new container might not work, as the DOCKER_HOST might need to be different for access to docker within a new container. Within the "creator" container, /var/run/docker.sock is automatically mounted from the host system.
If you enable bindHostToBuilder, it'll pass the DOCKER_HOST (or the parameter in pom.xml) to the new container, but that might not be the correct docker hostname that is accessible from within the new container.
For me the solution was to not use bindHostToBuilder, but ensure that /var/run/docker.sock exists on the host system so that it can be mapped within the "creator" container, even though the pull happens with a different DOCKER_HOST (a remote docker)

Creating Springboot image with Docker took box on windows 10 using spotify maven plugin

I use docker tool box in my windows 10 home laptop. Trying to create a docker image using the springboot project I have been working on. Followed the tutorial at https://spring.io/guides/gs/spring-boot-docker/
Have been struggling with the error for past three days
Apr 03, 2019 11:52:57 AM com.spotify.docker.client.shaded.org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://192.168.99.100:2376: Connection reset by peer: socket write error
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 46.027 s
[INFO] Finished at: 2019-04-03T11:52:57+05:30
[INFO] Final Memory: 63M/433M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.4.9:build (default-cli) on project IssueTracker: Could not build image: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: com.spotify.docker.client.shaded.org.apache.http.client.ClientProtocolException: Cannot retry request with a non-repeatable request entity: Connection reset by peer: socket write error -> [Help 1]
Many websites I look up said this could be something related to disabling TLS. I tried to expose the host, disable the tls but still the issue persists. Any help will be appreciated.
The following is my maven plugin config
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.9</version>
<configuration>
<repository>${docker.image.prefix}/${project.artifactId}</repository>
</configuration>
</plugin>
Did you try to run this maven goal inside "Docker Quickstart Terminal"?

How to use external sonar server for jHipster project

I am currently developing a spring boot application with jHipster and I want to use an existing sonar server from my company to analyze the code. JHipster only describes a way to use a build in sonar server from a docker container. Unfortunately that is not an option for me since my machine is running on Windows Server 2012, that is not supported by docker.
I already tried to start the maven build by adding the server url as a build parameter to the maven build, but it is ignoring it.
mvn clean test sonar:sonar -Dsonar.host.url=http://server-ip:server-port/ -Dsonar.login=login -Dsonar.password=pw
I am relatively new to the topic and was using the given command by the jhipster reference page (https://jhipster.github.io/code-quality/), so the test profile should be the correct one for this purpose.
When I run the command it ignores the given url paramter and still tries to use localhost where it expects the sonar in a docker container.
08:31:53.473 INFO - Create JDBC datasource for
jdbc:h2:tcp://localhost/sonar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 55.017 s
[INFO] Finished at: 2017-06-12T08:31:53+00:00
[INFO] Final Memory: 65M/392M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project project: Fail to connect to database: Cannot load JDBC driver class 'org.h2.Driver' -> [
Help 1]
Since jHipster generates and configures a lot in the background I have no idea if I am missing something vital here. Maybe a configuration file I have to adjust? I really appreciate the help.
The pom.xml was generated by jHipster and the maven plugin is configured as followed:
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar-maven-plugin.version}</version>
</plugin>
The version is set in the properties as:
<sonar-maven-plugin.version>3.2</sonar-maven-plugin.version>
I tried setting up my project on a linux vm with a running local docker sonar instance as suggested by the jHipster team and it was running fine, it is just very inconvenient for me since I have an available company sonar instance running in the intranet.
I also tried modifying my settings.xml as suggested and that was ignored, though it lead to a different looking error message:
[INFO] --- sonar-maven-plugin:3.2:sonar (default-cli) # project ---
[INFO] User cache: C:\Users\Administrator\.sonar\cache
[ERROR] SonarQube server [http://localhost:9000] can not be reached
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:12 min
[INFO] Finished at: 2017-06-14T11:29:22+00:00
[INFO] Final Memory: 57M/408M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project project: Unable to execute SonarQube: Fail to download libraries from server: Status r
eturned by url [http://localhost:9000/batch_bootstrap/index] is not valid: [404] -> [Help 1]
Everything is explained in the sonar docs : https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Maven
You should edit the settings.xml file in you ~/.m2directory with the following:
<settings>
<pluginGroups>
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://myserver:9000
</sonar.host.url>
</properties>
</profile>
</profiles>
</settings>
Try to add the following line into the properties section of your pom.xml file.
<sonar.host.url>http://1.2.3.4:9000/</sonar.host.url>
With the IP address corresponding to your sonarqube server.

Bamboo Maven Glassfish Deploy

I've been trying to set up continuous integration and deployment for a Java EE application.
Continuous integration is working however the deployment always fail.
I tried 3 things in the maven parameter ${local.glassfish.passfile}:
path to domain-password
path to.gfclient/pass
password string
One last thing I tried was:
hardcoded value inside pom.xml
Ear pom.xml configuration:
<plugin>
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
<version>2.1</version>
<configuration>
<glassfishDirectory>${local.glassfish.home}</glassfishDirectory>
<user>${local.glassfish.user}</user>
<passwordFile>${local.glassfish.passfile}</passwordFile>
<domain>
<name>${local.glassfish.domain}</name>
<adminPort>${local.glassfish.adminPort}</adminPort>
<httpPort>${local.glassfish.httpPort}</httpPort>
</domain>
<components>
<component>
<name>${project.artifactId}</name>
<artifact>target/${project.build.finalName}.ear</artifact>
</component>
</components>
<debug>true</debug>
<terse>false</terse>
<echo>true</echo>
</configuration>
</plugin>
Running mvn glassfish:deploy inside the ear folder via the terminal successfully deploys the ear artefact to the server.
Bamboo Error log:
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ear 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-glassfish-plugin:2.1:undeploy (default-cli) # ear ---
[INFO] Deprecated syntax, instead use:
[INFO] asadmin --echo --terse=false --interactive=false --user admin --passwordfile /home/guest/.gfclient/pass --host localhost --port 55004 undeploy [options] ...
[INFO] asadmin --host localhost --port 55004 --user admin --passwordfile /home/guest/.gfclient/pass --interactive=false --echo=true --terse=false undeploy --keepreposdir=false --isredeploy=false --cascade=false --_ignorecascade=false --_classicstyle=false ear
[INFO] Command undeploy failed.
[ERROR] Authentication failed for user: admin
[ERROR] (Usually, this means invalid user name and/or password)
[ERROR] Undeployment of ear failed.
[ERROR] For more detail on what might be causing the problem try running maven with the --debug option
[ERROR] or setting the maven-glassfish-plugin "echo" property to "true".
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.699 s
[INFO] Finished at: 2014-03-06T17:39:50+00:00
[INFO] Final Memory: 8M/19M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.glassfish.maven.plugin:maven-glassfish-plugin:2.1:undeploy (default-cli) on project ear: Undeployment of ear failed. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Failing task since return code of [/home/guest/apache-maven-3.2.1/bin/mvn glassfish:undeploy] was 1 while expected 0
Finished task 'Maven Glassfish Undeploy'
Note that I ran the "asadmin login" command after I changed the admin password in order to update the pass file.
guest#foo:~$ asadmin --port 55004 login
Enter admin user name [Enter to accept default]> admin
Enter admin password>
Admin login information for host [localhost] and port [55004] is being overwritten with credentials provided. This is because the --savelogin option was used during create-domain command.
Login information relevant to admin user name [admin] for host [localhost] and admin port [55004] stored at [/home/guest/.gfclient/pass] successfully.
Make sure that this file remains protected. Information stored in this file will be used by administration commands to manage associated domain.
Command login executed successfully.
Also, Glassfish version is 4.0, Maven version is 3.2.1.
If you have used the asadmin login command you don't need to specify the user and password in the undeploy and deploy command as it will use the credentials that you've set using the login command.
There is a Bamboo plugin that allows to deploy an war file to Glassfish Application Server.
https://marketplace.atlassian.com/apps/1219234/tasks-for-glassfish-server

Resources