in jetbrains-core/src/software/aws/toolkits/jetbrains/core/docker/ToolkitDockerAdapter.kt [54:118]
open suspend fun hackyBuildDockerfileWithUi(project: Project, pushRequest: DockerfileEcrPushRequest): String? {
val (runConfiguration, _, _) = pushRequest
// use connection specified in run configuration
val server = RemoteServersManager.getInstance().findByName(runConfiguration.serverName, runConfiguration.serverType)
val (serverConnection, dockerRuntime) = EcrUtils.getDockerServerRuntimeInstance(server)
// prep the "deployment" that will build the Dockerfile
val execEnviron = ExecutionEnvironmentBuilder.create(DefaultRunExecutor.getRunExecutorInstance(), runConfiguration).build()
val dockerConfig = (runConfiguration.deploymentConfiguration as DockerDeploymentConfiguration)
val wasBuildOnly = dockerConfig.isBuildOnly
dockerConfig.isBuildOnly = true
// upcasting here to avoid type mismatch/unchecked cast warning on 'deploy' invocation
val task: DeploymentTask<DeploymentConfiguration> = DeploymentTaskImpl(
runConfiguration.deploymentSource,
runConfiguration.deploymentConfiguration,
project,
null,
execEnviron
)
// check we don't have something running
val expectedDeploymentName = dockerRuntime.getDeploymentName(runConfiguration.deploymentSource, runConfiguration.deploymentConfiguration)
if (serverConnection.deployments.firstOrNull { it.name == expectedDeploymentName && it.status == DeploymentStatus.DEPLOYING } != null) {
notifyError(message("ecr.push.title"), message("ecr.push.in_progress"))
return null
}
// unfortunately no callbacks available to grab the Deployment instance
val deploymentPromise = AsyncPromise<Deployment>()
serverConnection.deploy(task) { deploymentName ->
EcrUtils.LOG.debug("Retrieving Deployment associated with '$deploymentName'")
RemoteServersView.getInstance(project).showDeployment(serverConnection, deploymentName)
runInEdt {
deploymentPromise.setResult(serverConnection.deployments.first { it.name == deploymentName })
}
}
// seems gross but this is cleaner than manually attempting to expose the build logs to the user
val deployment = deploymentPromise.await()
// TODO: why doesn't logging to this log handler do anything?
val logHandler = deployment.getOrCreateLogManager(project).mainLoggingHandler
// unfortunately no callbacks available to grab failure
while (deployment.status == DeploymentStatus.DEPLOYING) {
delay(100)
}
if (deployment.status != DeploymentStatus.DEPLOYED) {
notifyError(message("ecr.push.title"), message("ecr.push.failed", deployment.statusText))
return null
}
val runtime = deployment.runtime as? DockerApplicationRuntime
if (runtime == null) {
notifyError(message("ecr.push.title"), message("ecr.push.failed", deployment.statusText))
return null
}
if (!wasBuildOnly) {
EcrUtils.LOG.debug("Configuration specified additional 'run' parameters in Dockerfile that will be ignored")
logHandler.print("Skipping 'Run' portion of Dockerfile build configuration\n")
}
return "sha256:${runtime.imageId}"
}