I am using Gitlab CI AutoDev tool for build docker image for spring boot app with MySQL.
project and docker image working fine with windows localhost. but I am deploying the same image from gitlab registry to centos PVS. I getting error as Invalid or corrupt jarfile /app.jar.
Dockerfile
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
ADD ${JAR_FILE} TECHLAVIYA.jar
ENTRYPOINT [“java”,"-Djava.security.egd=file:/dev/./urandom","-jar","/TECHLAVIYA.jar"]
docker-compose.yml
version: ‘3’
services:
docker-mysql:
image: mysql:latest
environment:
- MYSQL_ROOT_PASSWORD=12345
- MYSQL_DATABASE=TechlaviyaDB
- MYSQL_PASSWORD=12345
phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
-
docker-mysql
environment:
PMA_HOST: docker-mysql
PMA_PORT: 3306
ports: -
'8081:80’
docker-webapp:
image: registry.gitlab.com/techlaviya/techlaviya/master:fb9e0213d6d4f385161e29561e626090a780e517
depends_on: -
docker-mysql
ports: -
8080:8080
environment: -
DATABASE_HOST=docker-mysql
-
DATABASE_USER=root
-
DATABASE_PASSWORD=12345
-
DATABASE_NAME=TechlaviyaDB
-
DATABASE_PORT=3306
.pom file
4.0.0
com.techlaviya.lfee
techlaviya
0.0.1-SNAPSHOT
jar
techlaviya
Demo project for Spring Boot
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.6.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>org.springframework.mobile</groupId>
<artifactId>spring-mobile-device</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
TECHLAVIYA
org.springframework.boot
spring-boot-maven-plugin
com.spotify
dockerfile-maven-plugin
1.3.6
default
build
push
${docker.image.prefix}/${project.artifactId}
target/${project.build.finalName}.jar
</plugin>
<!-- end::plugin[] -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>