Java application
git clone https://github.com/spring-projects/spring-petclinic.git
cd spring-petclinic
# java 17
sudo apt update && sudo apt-get install openjdk-17-jdk -y
java --version
# maven
sudo apt-get install maven -y
mvn --version
# maven command to build code (run where the pom.xml file present)
mvn clean package -DskipTests
### out put will be target folder and jar/war file
java -jar target/spring-petclinic-4.0.0-SNAPSHOT.jar
FROM ubuntu:latest
RUN apt-get update && apt-get install openjdk-17-jdk -y
WORKDIR app
ENV JAVA_TOOL_OPTIONS="-Djdk.disableLastCgroup=true"
COPY ./**/spring-petclinic-4.0.0-SNAPSHOT.jar .
RUN chmod 755 spring-petclinic-4.0.0-SNAPSHOT.jar
CMD ["java", "-jar", "spring-petclinic-4.0.0-SNAPSHOT.jar"]
docker run –cgroupns=host -e JAVA_TOOL_OPTIONS=“–add-opens=java.base/jdk.internal.platform=ALL-UNNAMED” -dit –name spring-ubuntu-1 -p8081:8080 spring:1.2-ubuntu
Task
- create new dockerfile and take base image ubuntu
- install pre-request java17, maven and git
- In RUN clone repo and build maven code.
- cmd should be run jar file
