stephanmg
07/15/2020, 3:06 PMGunslingor
07/15/2020, 3:16 PMGunslingor
07/15/2020, 3:18 PMstephanmg
07/15/2020, 3:18 PMstephanmg
07/15/2020, 3:18 PMstephanmg
07/15/2020, 3:18 PMstephanmg
07/15/2020, 3:19 PMGunslingor
07/15/2020, 3:19 PMclientDocker.buildImageCmd().pathToDockerfile()
pathGunslingor
07/15/2020, 3:19 PMstephanmg
07/15/2020, 3:20 PMval file = MyClass::class.java.getResource("database.properties").getFile()
stephanmg
07/15/2020, 3:20 PMGunslingor
07/15/2020, 3:21 PMstephanmg
07/15/2020, 3:22 PMstephanmg
07/15/2020, 3:22 PMstephanmg
07/15/2020, 3:22 PMthis.javaClass.getResource("database.properties").getFile()
stephanmg
07/15/2020, 3:23 PMGunslingor
07/15/2020, 3:24 PMval clientDocker = DockerClass().dockerClient
val result = clientDocker.infoCmd().exec()
val file = DockerClass::class.java.getResource("database.properties").file
This works, now I just need the path of it.stephanmg
07/15/2020, 3:26 PMGunslingor
07/15/2020, 3:26 PMstephanmg
07/15/2020, 3:29 PMGunslingor
07/15/2020, 3:29 PMstephanmg
07/15/2020, 3:30 PMGunslingor
07/15/2020, 3:32 PMstephanmg
07/15/2020, 3:37 PMstephanmg
07/15/2020, 3:37 PMstephanmg
07/15/2020, 3:37 PMGunslingor
07/15/2020, 3:37 PMstephanmg
07/15/2020, 3:38 PMstephanmg
07/15/2020, 3:38 PMstephanmg
07/15/2020, 3:38 PMGunslingor
07/15/2020, 3:38 PMakatkov
07/15/2020, 5:02 PMakatkov
07/15/2020, 5:04 PMGunslingor
07/15/2020, 6:43 PMGunslingor
07/15/2020, 6:43 PMfun main(){
val clientDocker = DockerClass().dockerClient
val result = clientDocker.infoCmd().exec()
DockerClass().main()
//clientDocker.buildImageCmd().pathToDockerfile("?????")
}
akatkov
07/15/2020, 6:49 PMGunslingor
07/15/2020, 6:49 PMGunslingor
07/15/2020, 6:49 PMpackage com.newsworthy.build.containers
import com.github.dockerjava.core.DefaultDockerClientConfig
import com.github.dockerjava.core.DockerClientConfig
import com.github.dockerjava.core.DockerClientImpl
import com.github.dockerjava.httpclient5.ApacheDockerHttpClient
import com.github.dockerjava.transport.DockerHttpClient
import java.io.File
const val projectName: String = "srcBuild"
class DockerClass {
private val config: DockerClientConfig = DefaultDockerClientConfig.createDefaultConfigBuilder()
.withDockerHost("<tcp://localhost:2375>")
//.withDockerTlsVerify(true)
//.withDockerCertPath("/home/user/.docker")
//.withRegistryUsername("admin")
//.withRegistryPassword("password")
//.withRegistryEmail("<mailto:gunslingor@gmail.com|gunslingor@gmail.com>")
//.withRegistryUrl("<https://index.docker.io/v1/>")
.build()
val httpClient: DockerHttpClient = ApacheDockerHttpClient.Builder()
.dockerHost(config.dockerHost)
.sslConfig(config.sslConfig)
.build()
val dockerClient = DockerClientImpl.getInstance(config, httpClient)!!
fun main(){
//val filePath = DockerClass::class.java.getResource("svrDB").file
//val filePath = (this::class).java.getResource("dockerfiles\\svrDb")
//print(filePath)
}
}
fun main(){
val clientDocker = DockerClass().dockerClient
val result = clientDocker.infoCmd().exec()
DockerClass().main()
//clientDocker.buildImageCmd().pathToDockerfile()
}
akatkov
07/15/2020, 6:50 PMsvrDb
file to main/resources instead of test/resources?Gunslingor
07/15/2020, 6:51 PMGunslingor
07/15/2020, 6:51 PMakatkov
07/15/2020, 6:52 PMakatkov
07/15/2020, 6:52 PMsourceSets
in gradle to make it work, but wouldn’t recommend necessarilyakatkov
07/15/2020, 6:54 PMGunslingor
07/15/2020, 6:54 PMDockerClass::class.java.getResource("dockerfile/svrDB")
still comes back nullakatkov
07/15/2020, 6:55 PMdockerfiles
in your screenshotGunslingor
07/15/2020, 6:56 PMakatkov
07/15/2020, 6:57 PMInputStream
to it using getResourceAsStream
akatkov
07/15/2020, 6:58 PMGunslingor
07/15/2020, 6:59 PMakatkov
07/15/2020, 6:59 PMDockerClass::class.java.classLoader.getResource("dockerfiles/svrDB")
Gunslingor
07/15/2020, 7:00 PMakatkov
07/15/2020, 7:00 PMGunslingor
07/15/2020, 7:01 PMGunslingor
07/15/2020, 7:01 PMGunslingor
07/15/2020, 7:02 PMakatkov
07/15/2020, 7:04 PMgetResourceAsStream
, write that to a File (maybe using File.createTempFile
), then you can pass that path to your function and it’ll work in both dev IDE/prod jar scenariosGunslingor
07/15/2020, 7:06 PMakatkov
07/15/2020, 7:07 PMGunslingor
07/15/2020, 7:24 PMstatic("/static") {
files("build/processedResources/jvm/main")
}
Gunslingor
07/15/2020, 7:25 PMakatkov
07/15/2020, 7:25 PMGunslingor
07/15/2020, 7:27 PM