Skip to content

Commit

Permalink
FIX : tentative multiples build avec graalvm
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-maraval committed Oct 2, 2024
1 parent 58a1beb commit f971088
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 28 deletions.
33 changes: 26 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,31 @@
FROM maven:3-eclipse-temurin-17 as build-image
WORKDIR /build/
# Installation et configuration de la locale FR
RUN apt update && DEBIAN_FRONTEND=noninteractive apt -y install locales
RUN sed -i '/fr_FR.UTF-8/s/^# //g' /etc/locale.gen && \
locale-gen
ENV LANG fr_FR.UTF-8
ENV LANGUAGE fr_FR:fr
ENV LC_ALL fr_FR.UTF-8
RUN set -xeu && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates `# stays, not having this is just not useful` \
curl \
&& \
mkdir /graalvm && \
curl -fsSL "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.9/graalvm-community-jdk-17.0.9_linux-x64_bin.tar.gz" \
| tar -zxC /graalvm --strip-components 1 && \
find /graalvm -name "*src.zip" -printf "Deleting %p\n" -exec rm {} + && \
{ test ! -d /graalvm/legal || tar czf /graalvm/legal.tgz /graalvm/legal/; } && \
{ test ! -d /graalvm/legal || rm -r /graalvm/legal; } && \
rm -rf /graalvm/man `# does not exist in java11 package` && \
echo Cleaning up... && \
apt-get remove -y \
curl \
&& \
apt-get autoremove -y && \
apt-get clean && rm -r "/var/lib/apt/lists"/* && \
# PATH is set via ENV below. However, `bash -l` will source `/etc/profile` and set $PATH on its own.
echo 'PATH="/graalvm/bin:$PATH"' | install --mode 0644 /dev/stdin /etc/profile.d/graal-on-path.sh && \
echo OK

ENV PATH=/graalvm/bin:$PATH JAVA_HOME=/graalvm

# On lance la compilation Java
# On débute par une mise en cache docker des dépendances Java
Expand Down Expand Up @@ -92,7 +111,7 @@ RUN chmod +x /scripts/itemBatchTraiterLigneFichierRecouv.sh
COPY ./docker/batch/itemBatchTraiterLigneFichierSupp.sh /scripts/itemBatchTraiterLigneFichierSupp.sh
RUN chmod +x /scripts/itemBatchTraiterLigneFichierSupp.sh

COPY --from=build-image /build/batch/target/*.jar /scripts/item-batch.jar
COPY --from=build-image /build/batch/target/* /scripts/
RUN chmod +x /scripts/item-batch.jar

COPY ./docker/batch/docker-entrypoint.sh /docker-entrypoint.sh
Expand Down
58 changes: 53 additions & 5 deletions batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,72 @@
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>fr.abes.item.batch.Application</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>java</id>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>fr.abes.item.batch.Application</mainClass>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.22</version>
<version>0.10.1</version>
<extensions>true</extensions>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<configuration>
<mainClass>fr.abes.item.batch.Application</mainClass>
</configuration>
<phase>package</phase>
</execution>
</executions>

</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>fr.abes.item.batch.Application</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
6 changes: 1 addition & 5 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<version>3.0.1-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<groupId>fr.abes.item</groupId>
<artifactId>core</artifactId>
<dependencies>
<dependency>
Expand Down Expand Up @@ -89,10 +88,7 @@
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.22</version>
<configuration>
<skip>true</skip>
</configuration>
<version>0.10.1</version>
</plugin>
</plugins>
</build>
Expand Down
2 changes: 1 addition & 1 deletion docker/batch/itemBatchTraiterLigneFichierExemp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
LANG=fr_FR.UTF-8
if [[ $(pgrep -cf "traiterLigneFichierExemp") < 1 ]];
then
java -XX:MaxRAMPercentage=80 org.springframework.boot.loader.JarLauncher --spring.batch.job.name=traiterLigneFichierExemp --server.port=8082
java -jar -XX:MaxRAMPercentage=80 item-batch.jar --spring.batch.job.name=traiterLigneFichierExemp --server.port=8082
fi
8 changes: 2 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,15 @@
<profiles>
<profile>
<id>native</id>
<modules>
<module>batch</module>
<module>web</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.22</version>
<version>0.10.1</version>
<executions>
<execution>
<id>native</id>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
Expand Down
57 changes: 53 additions & 4 deletions web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,73 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>fr.abes.item.web.ModifDeMasseApplication</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>java</id>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>fr.abes.item.web.ModifDeMasseApplication</mainClass>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.22</version>
<version>0.10.1</version>
<extensions>true</extensions>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<configuration>
<mainClass>fr.abes.item.web.ModifDeMasseApplication</mainClass>
</configuration>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>fr.abes.item.web.ModifDeMasseApplication</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>

0 comments on commit f971088

Please sign in to comment.