Skip to content

Instantly share code, notes, and snippets.

@danhyun
Last active November 28, 2017 19:36
Show Gist options
  • Save danhyun/cfa1635a971820644ac8b38edc875faa to your computer and use it in GitHub Desktop.
Save danhyun/cfa1635a971820644ac8b38edc875faa to your computer and use it in GitHub Desktop.
gradle + docker + blockdiag
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.bmuschko:gradle-docker-plugin:3.2.1'
}
}
// use fully qualified class name
apply plugin: com.bmuschko.gradle.docker.DockerRemoteApiPlugin
// import task classes
import com.bmuschko.gradle.docker.tasks.container.*
import com.bmuschko.gradle.docker.tasks.image.*
repositories {
mavenCentral()
}
task pullBlockDiagImage(type: DockerPullImage) {
repository = 'manabu/blockdiag-docker'
tag = "0.2.0"
}
task createBlockDiagContainer(type: DockerCreateContainer) {
dependsOn pullBlockDiagImage
targetImageId { "manabu/blockdiag-docker:0.2.0" }
binds = [(projectDir.toString()) : '/work']
cmd = ["/bin/sh", "-c", "blockdiag *.diag"]
}
task startBlockDiagContainer(type: DockerStartContainer) {
dependsOn createBlockDiagContainer
targetContainerId { createBlockDiagContainer.containerId }
}
task removeBlockDiagContainer(type: DockerRemoveContainer) {
targetContainerId { createBlockDiagContainer.containerId }
}
task generateBlockDiag(type: DockerWaitContainer) {
dependsOn startBlockDiagContainer
targetContainerId { createBlockDiagContainer.containerId }
finalizedBy removeBlockDiagContainer
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment