'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!
Solution 1:[1]
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"]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | membersound |
