spring-guides/gs-spring-boot-docker

Invalid or corrupt jarfile /application.jar

Mauro1924 opened this issue · 0 comments

My docker file:

`FROM mcr.microsoft.com/playwright/java:v1.33.0-focal
RUN apt-get update && apt-get install -y --no-install-recommends vim xvfb
ARG jar_module
ARG jar_path=$jar_module
ARG build_dir=target
ARG env

ENV ENVIRONMENT=$env
JAVA_BASE_OPTS='-server -Dfile.encoding=UTF-8 -Duser.timezone=Europe/Berlin'
JAVA_ADDITIONAL_OPTS='
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/nfs/system
-XX:NativeMemoryTracking=summary -XX:+UseContainerSupport
-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n
-Djava.rmi.server.hostname=127.0.0.1
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9090
-Dcom.sun.management.jmxremote.rmi.port=9090
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.local.only=false '
JAVA_MEM_OPTS='-XX:InitialRAMPercentage=75 -XX:MaxRAMPercentage=75 -XshowSettings'
COPY docker/pom.xml pom.xml
RUN mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install-deps"
COPY ${jar_path}/${build_dir}/${jar_module}.jar /application.jar

RUN echo '#!/bin/bash \n xvfb-run --auto-servernum --server-num=1 java -Dspring.profiles.active=$ENVIRONMENT $JAVA_BASE_OPTS $JAVA_MEM_OPTS $JAVA_ADDITIONAL_OPTS -jar /$1 $2 $3 $4 $5 $6' > /entrypoint.sh
RUN ["chmod", "+x", "entrypoint.sh"]

ENTRYPOINT ["/entrypoint.sh", "application.jar"]`

My pom.xml:

`

4.0.0

<groupId>org.example</groupId>
<artifactId>examples</artifactId>
<version>0.1-SNAPSHOT</version>
<name>Playwright Client Examples</name>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
    <dependency>
        <groupId>com.microsoft.playwright</groupId>
        <artifactId>playwright</artifactId>
        <version>1.33.0</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.10.1</version>
            <!-- References to interface static methods are allowed only at source level 1.8 or above -->
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

`

My gradle file:

`plugins {
id 'org.springframework.boot' version '2.6.4'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'jacoco'

}

sourceCompatibility = "17"

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenLocal()
maven {
url check24atMavenRepositoryUrl
}
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:2021.0.1"
}
}

dependencies {
implementation platform(project(":platform"))
annotationProcessor platform(project(":platform"))
testImplementation platform(project(":platform"))

implementation 'at.c24.infra:java-service-starter'
implementation project(":clients:service-generic-apptrack")

implementation 'org.springframework.boot:spring-boot-starter-web'

implementation('org.springframework.boot:spring-boot-starter-actuator') {
    exclude group: 'io.micrometer', module: 'micrometer-core'
}

implementation 'com.microsoft.playwright:playwright:1.33.0'

implementation "org.apache.httpcomponents:httpclient"
implementation 'ch.qos.logback:logback-core'
implementation "commons-io:commons-io"
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'

implementation 'org.springdoc:springdoc-openapi-ui'

implementation 'org.mapstruct:mapstruct'

compileOnly 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
annotationProcessor "org.mapstruct:mapstruct-processor"

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
testImplementation 'org.mockito:mockito-core'

}`

When building the docker file it works, but if I wanna run it, it gives me the error message. Please any suggestions what is wrong in the files?