ADD failed: stat /var/lib/docker/tmp/docker-builder : : no such file or directory - spring-boot

I am new to Docker/Spring Boot. I am trying do the auto builds from GITHUB repo.
Below is my GitHub repo :
https://github.com/rajatgupta828/TestApplication
And below is my docker repo :
https://hub.docker.com/repository/docker/rajatgupta56/apptest
When I am building image from my local after Maven Build, it is working fine, But when I am trying to auto build using GITHUB I am getting below logs :
Cloning into '.'...
Warning: Permanently added the RSA host key for IP address '140.82.113.3' to the list of known hosts.
Reset branch 'master'
Your branch is up-to-date with 'origin/master'.
KernelVersion: 4.4.0-1060-aws
Components: [{u'Version': u'18.03.1-ee-3', u'Name': u'Engine', u'Details': {u'KernelVersion': u'4.4.0-1060-aws', u'Os': u'linux', u'BuildTime': u'2018-08-30T18:42:30.000000000+00:00', u'ApiVersion': u'1.37', u'MinAPIVersion': u'1.12', u'GitCommit': u'b9a5c95', u'Arch': u'amd64', u'Experimental': u'false', u'GoVersion': u'go1.10.2'}}]
Arch: amd64
BuildTime: 2018-08-30T18:42:30.000000000+00:00
ApiVersion: 1.37
Platform: {u'Name': u''}
Version: 18.03.1-ee-3
MinAPIVersion: 1.12
GitCommit: b9a5c95
Os: linux
GoVersion: go1.10.2
Starting build of index.docker.io/rajatgupta56/apptest:0.0.1-SNAPSHOT...
Step 1/8 : FROM openjdk:8-jdk-alpine
---> a3562aa0b991
Step 2/8 : LABEL maintainer="Rajatgupta828#gmail.com"
---> Running in 4e55966615dc
Removing intermediate container 4e55966615dc
---> 670b63467701
Step 3/8 : VOLUME /tmp/${pwd}
---> Running in 3a33ba4471a8
Removing intermediate container 3a33ba4471a8
---> 182122656d6a
Step 4/8 : WORKDIR /
Removing intermediate container 9344531c842f
---> ae012d63578d
Step 5/8 : EXPOSE 8080
---> Running in 0be952ee63fc
Removing intermediate container 0be952ee63fc
---> 5065a1cd7212
Step 6/8 : ARG JAR_FILE=target/ApplicationTest-0.0.1-SNAPSHOT.jar
---> Running in a6def98cd21d
Removing intermediate container a6def98cd21d
---> 5a77e9b6d578
Step 7/8 : ADD ${JAR_FILE} appliation-test.jar
ADD failed: stat /var/lib/docker/tmp/docker-builder579146423/target/ApplicationTest-0.0.1-SNAPSHOT.jar: no such file or directory
My POM File is :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.application</groupId>
<artifactId>ApplicationTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>ApplicationTest</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>dev</id>
<properties>
<activatedProperties>dev</activatedProperties>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>prod</id>
<properties>
<activatedProperties>prod</activatedProperties>
</properties>
</profile>
</profiles>
</project>
And my DockerFile is :
# Start with a base image containing Java runtime
FROM openjdk:8-jdk-alpine
#Add Maintainer Info
LABEL maintainer="Rajatgupta828#gmail.com"
# Add a volume pointing to /tmp
VOLUME /tmp/${pwd}
WORKDIR /
# Make port 8080 available to the world outside this container
EXPOSE 8080
# The application's jar file
ARG JAR_FILE=target/ApplicationTest-0.0.1-SNAPSHOT.jar
# Add the application's jar to the container
ADD ${JAR_FILE} appliation-test.jar
# Run the jar file
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/appliation-test.jar"]
I am following below tutorial :
https://www.callicoder.com/spring-boot-docker-example/
Dockerfile is located in my root library :
My Project

Related

Error: Invalid or corrupt jarfile /app.jar

Help, I'm trying to upload the spring boot application to fly.io
2022-12-27T18:13:45Z [info]Preparing to run: `java -jar /app.jar` as root
2022-12-27T18:13:45Z [info]2022/12/27 18:13:45 listening on [fdaa:1:12ef:a7b:a0:3feb:41aa:2]:22 (DNS: [fdaa::3]:53)
2022-12-27T18:13:45Z [info]Error: Invalid or corrupt jarfile /app.jar
2022-12-27T18:13:46Z [info]Starting clean up.
--> v45 failed - Failed due to unhealthy allocations - not rolling back to stable job version 45 as current job has same specification and deploying as v46
--> Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/
Error abort
FROM ibm-semeru-runtimes:open-17-jre-focal
EXPOSE 8080
ARG JAR_FILE= ./target/*.jar
COPY ${JAR_FILE} /app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.7</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.tasf</groupId>
<artifactId>prueba</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>prueba</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
buid
BUILD SUCCESS
Total time: 10.109 s
Finished at: 2022-12-27T13:20:04-05:00
he requested profile "pom.xml" could not be activated because it does not exist.
the .dockerignore file was ignoring the /target path

Heroku Git Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1: java 11

I am trying to deploy my spring application to heroku.
I wanted to use heroku git as in tutorial on heroku.
I did:
git add .
git commit -am "make it better"
git push heroku master
but I am getting error:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project projectName: Fatal error compiling: invalid target release: 11 -> [Help 1]
So I spent about 2 hourse to solve it by any dependencies and changes in properties but nothing help.
When I run mvn clean install in Intelijj Build is success - without ny error.
That error only appears in cmd when I want to push it to master...
Shortcut of my pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<version>0.0.1-SNAPSHOT</version>
<name>projectName</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
…
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.22</version>
</dependency>
…
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

Fabric8 Docker Maven plugin not working for compose.yml on Multi module project

I trying to use Fabric8 docker-maven-plugin, though I was successful in configuring plugin for individual module and run docker:build docker:start Maven goal without using docker-compose.yml, however I needed externalize ports and link the different module, hence I intended to use docker-compose.yml. Below is my project structure.
--kp-parent
|
--- docker-compose.yml
--- pom.xml
|
---- rest1
| |
| -- .maven-dockerignore
| -- pom.xml
| -- Dockerfile
---- rest2
| |
| -- .maven-dockerignore
| -- pom.xml
| -- Dockerfile
Here are my configurations
Dockerfile[both rest1 and rest2 use identical file except the different port]
FROM openjdk:8-jdk-alpine
MAINTAINER 'Karthik Prasad'
ARG IMAGE_VERSION
ARG JAR_FILE
ENV JAVA_OPTS=""
LABEL version = IMAGE_VERSION
VOLUME /tmp
ADD /maven/${JAR_FILE}.jar app.jar
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
EXPOSE 8000
.maven-dockerignore[In both child modules identical file]
target/**
pom.xml [Both rest1 and rest2 pom files are same except the artifcatid and name of the project]
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>rest2</artifactId>
<packaging>jar</packaging>
<name>rest2</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>com.kp.swasthik</groupId>
<artifactId>kp-docker-multimodule-fabric8-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- https://mvnrepository.com/artifact/io.fabric8/docker-maven-plugin -->
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
<images>
<image>
<external>
<type>compose</type>
<basedir>../</basedir>
<ignoreBuild>true</ignoreBuild>
</external>
</image>
</images>
</configuration>
</plugin>
</plugins>
</build>
</project>
parent pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.kp.swasthik</groupId>
<artifactId>kp-docker-multimodule-fabric8-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>kp-docker-multimodule-fabric8-parent</name>
<description>Microservice Parent Pom file</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<modules>
<module>rest1</module>
<module>rest2</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<docker.image.prefix>kp-ms</docker.image.prefix>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.22.1</version>
<configuration>
<skip>true</skip>
<images>
<image>
<alias>${project.artifactId}</alias>
<name>${docker.image.prefix}/${project.artifactId}:${project.version}</name>
<build>
<dockerFileDir>${project.basedir}</dockerFileDir>
<assembly>
<inline>
<id>default</id>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</inline>
</assembly>
</build>
</image>
</images>
<buildArgs>
<IMAGE_VERSION>${project.version}</IMAGE_VERSION>
<JAR_FILE>${project.artifactId}-${project.version}</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
And finally docker-compose.yml
version: '2'
services:
rest1:
image: kp-ms/rest1:0.0.1-SNAPSHOT
ports:
- 8000:8000
rest2:
image: kp-ms/rest2:0.0.1-SNAPSHOT
ports:
- 8001:8001
links:
- rest1
When I run the docker:build docker:start I get below error.
[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.22.1:start (default-cli) on project rest1: I/O Error: Unable to pull 'kp-ms/rest2:0.0.1-SNAPSHOT' : repository kp-ms/rest2 not found: does not exist or no pull access (Not Found: 404) -> [Help 1]
[ERROR]
However If I remove rest2 section in docker-compose.yml, build goes fine and I'm able to find the container start successfully.
Another problem I noticed is that even if do not give image name in docker-compose.yml build fails with error image is null. However I'm not sure why I need to provide image can't the plugin map from plugin configuration as I had provided alias. As you can notice I'm trying to generate image name dynamically.

Maven error - Spring Surf Alfresco

To construct a project Spring Surf on Alfresco, I used the command:
mvn archetype:generate -DarchetypeCatalog=https://artifacts.alfresco.com/nexus/content/groups/public-snapshots/archetype-catalog.xml
I gave groupId=surfcmistest and artifactId=surfcmistest-1.0-SNAPSHOT. Then, on the folder surfcmistest-1.0-SNAPSHOT created by the project, I try to make build and package with Maven. I run:
mvn install
and I obtain the error:
Failed to execute goal on project surfcmistest-1.0-SNAPSHOT: Could not resolve dependencies for project surfcmistest:surfcmistest-1.0-SNAPSHOT:war:1.0-SNAPSHOT: Failed to collect dependencies at org.springframework.extensions.surf:spring-surf:jar:5.1-BF-SNAPSHOT: Failed to read artifact descriptor for org.springframework.extensions.surf:spring-surf:jar:5.1-BF-SNAPSHOT: Failure to find org.alfresco:alfresco-parent:pom:5.1-BF-SNAPSHOT in https://artifacts.alfresco.com/nexus/content/groups/public-snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of Alfresco-Artifacts has elapsed or updates are forced -> [Help 1]
My pom.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>surfcmistest</groupId>
<artifactId>surfcmistest-1.0-SNAPSHOT</artifactId>
<packaging>war</packaging>
<name>sample-app Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>Alfresco-Artifacts</id>
<name>Alfresco Artifacts SNAPSHOTS</name>
<url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.extensions.surf</groupId>
<artifactId>spring-surf</artifactId>
<version>5.1-BF-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.extensions.surf</groupId>
<artifactId>spring-surf-api</artifactId>
<version>5.1-BF-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.tuckey</groupId>
<artifactId>urlrewritefilter</artifactId>
<version>4.0.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.2.v20140723</version>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<scanTargets>
<scanTarget>src/main/webapp</scanTarget>
</scanTargets>
</configuration>
</plugin>
</plugins>
</build>
<version>1.0-SNAPSHOT</version>
</project>
What is my error?
The error message you are getting is:
resolution will not be reattempted until the update interval of Alfresco-Artifacts has elapsed or updates are forced
This is a very classic error and it is resolved by running Maven with the -U option.
You should restart from scratch and follow this procedure:
Remove your whole m2 repository (the default location is ~/.m2/repository) and remove any directory created by an earlier execution of the maven-archetype-plugin.
Run the command:
mvn archetype:generate -DarchetypeCatalog=https://artifacts.alfresco.com/nexus/content/groups/public-snapshots/archetype-catalog.xml
Choose the option org.springframework.extensions.surf:spring-surf-archetype (for me, it was option 1 but it can change).
Choose the version 5.1-SNAPSHOT, which was option 4 for me (but again, this can change)
Select a groupId, an artifactId, a version, a package and confirm all those properties by pressing Y.
Go into the newly created directory (it will be named after the artifactId you chose earlier) and run the following Maven command:
mvn -U clean install

maven copy plugin for spring-boot

I have created a Spring Boot application where I have few Javascript & Html files in the path src/main/resources/public/app.
My project folder structure is :
/project
-/src/main
-- /java
-- / resources
--- /application.properties
--- /public
---- /app
----- /index.html
----- /bower-components
----- /scripts
----- /views/**.html
----- /images
----- /styles
----/dist
-----/index.html
-----/vendor.ZXASF.js
-----/scripts.QASD.js
When I run the Javascript minification task, I generate a dist [distribution] folder as shown above. Now my requirement is, I want to tell maven which folder to include in the JAR file when mvn clean install is run. If I run in "DEBUG" mode, the folder src/main/resources/app folder needs to included in the JAR file. When I run in "DEPLOY" mode, the src/main/resources/dist folder needs to be included. Please note, the path of these folders in the JAR file should be as per the project folder structure. I tried with several options but no luck till now. My pm.xml is as below:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>spring-boot-demo</groupId>
<artifactId>spring-boot-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>spring-boot-demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>demo.SpringBootDemoApplication</start-class>
<java.version>1.7</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Thanks

Resources