简体   繁体   中英

Java development in docker container without local JDK?

Is it possible to create a docker container that runs a local ( spring-boot ) java project, without having to install a JDK on the local development machine?

I mean: would I have to add the sourcecode directory to the container as mount, and build the app there? Because, if I don't have a local JDK, I cannot build a final app.jar that I could share to the container.

My goal is to create a container that can be used for developtmend, without the developer requiring to install a local JDK.

Examples I could found have been like:

FROM eclipse-temurin:11
RUN mkdir /opt/app
COPY japp.jar /opt/app
CMD ["java", "-jar", "/opt/app/japp.jar"]

Problem: this requires build of the application, which is only possible if JDK/JRE is installed locally. But that's what I'm trying to prevent!

Dockerfile :

FROM maven:3-eclipse-temurin-11 as dependencies
COPY pom.xml .
RUN mvn -B dependency:go-offline

FROM dependencies as dev
COPY src src
ENTRYPOINT ["mvn", "spring-boot:run"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM