ELI5 Gradle and Docker

Hey guys, I think I just have a fundamental misunderstanding of gradle and docker. I have this codebase at work that builds with gradle and sets up a docker container locally. I was having trouble with the gradle build and it was failing the build. I reached out to another developer and they mentioned that I need to build the project with Java 11 (I had Java 22). I was able to build successfully then by doing ./gradlew -D org.gradle.java.home='<path-to-jdk-11>' I'm confused though because shouldn't docker be handling the dependencies (separate from a package manager, I know) and help build the project regardless of what version certain dependencies like Java are on my system? I tried explaining my question to them and they basically said that gradle is separate from docker which I kind of understand but it just doesn't make sense to me why I have to have specific depencency versions on my machine when it builds a docker container? Hopefully that makes sense
9 Replies
ἔρως
ἔρως4mo ago
for one, it isnt a docker dependency, but a gradle dependency if gradle runs outside of docker, docker cant do much about it
vince
vince4mo ago
Hm I guess that's where I'm misunderstanding then - isn't docker's whole thing to avoid these different dependency versions by creating containers that allows any computer to run a project regardless of dependencies / environment? What's the point of having a separate build step with gradle outside of docker? Could it just be moved inside the docker container?
ἔρως
ἔρως4mo ago
if everything is in docker, yes but outside? it cant do anything thats like expecting your neighbour to cook, and the food magically appears on your plate instead
vince
vince4mo ago
Got it, so I guess the question now is, why isn't it inside the docker container? Obviously there could be infinite reasons depending on the business requirements, but wouldn't it just be simpler to put it in the docker container?
ἔρως
ἔρως4mo ago
that is a good question one that im not qualified to answer
vince
vince4mo ago
Dang alright thanks Epic! I'll just leave it as a mystery for now lol. Just doesn't seem to make a whole lot of sense to me having the 2 separated since I feel like that's the whole point of docker haha
ἔρως
ἔρως4mo ago
i think you can get to a docker shell into the docker image and install java and gradle there, but dont quote me on that this is why i use virtual machines: tear it down, start over - easy
vince
vince4mo ago
This is a codebase that we aren't really owners of so I can't go and do that unfortunately (but probably fortunately lol) sounds like an absolute headache
ἔρως
ἔρως4mo ago
from what ive seen, it is an headache virtual machines are easier "apt install blah" - done
Want results from more Discord servers?
Add your server