Open GigiaJ opened 2 years ago
I think this can be solved via updating sourceSets and setting where to output the compile manually to /build/scripts - we already have ADD ./build/scripts root/.config/OsrsBot/Scripts/Sources/
in Dockerfile
sourceSets {
main {
java.getDestinationDirectory().set(file(getBotScriptDirectory(this)))
java.getDestinationDirectory().set(file("build/scripts"))
}
}
Alternatively we could also just do ADD ./build/libs root/.config/OsrsBot/Scripts/Precompiled/
in the Dockerfile
Updated docker gradle commands
task dockerBuild(type: Exec) {
commandLine 'docker', 'build', '-t', 'bot-image', '.'
}
task dockerRun(dependsOn: dockerBuild, type: Exec) {
commandLine 'docker', 'run', '-e', 'DISPLAY=host.docker.internal:0', '-t', '--rm', 'bot-image'
}
If you want to build the image and run it after every compile
compileJava {
finalizedBy(tasks.dockerRun)
}
Currently, the docker instructions are added, the docker file is added, and the client does run within the container, but we need to add to the Dockerfile the script directory. Currently this is a bit of an issue since we generate the script output directory straight to the user home directory. Docker is unable to actually view anything outside the working directory. This means we should instead build into the standard build directory AND the script directory. This will have to be implemented in Gradle via task that triggers on build.