Skip to content

Instantly share code, notes, and snippets.

@arthurtsang
Created February 8, 2015 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthurtsang/36ed4c105e5ec79fee4c to your computer and use it in GitHub Desktop.
Save arthurtsang/36ed4c105e5ec79fee4c to your computer and use it in GitHub Desktop.
ratpack + gradle + docker
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'io.ratpack:ratpack-gradle:0.9.13'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.0'
classpath 'com.bmuschko:gradle-docker-plugin:2.0'
}
}
apply plugin: "io.ratpack.ratpack-java"
apply plugin: "com.github.johnrengelman.shadow"
version = '1.0'
import com.bmuschko.gradle.docker.tasks.image.Dockerfile
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.DockerTagImage
import com.bmuschko.gradle.docker.tasks.image.DockerPushImage
import com.bmuschko.gradle.docker.tasks.container.DockerCreateContainer
import com.bmuschko.gradle.docker.tasks.container.DockerStartContainer
import com.bmuschko.gradle.docker.tasks.container.DockerStopContainer
def registryUrl = 'localhost:5000'
docker {
url = 'unix:///var/run/docker.sock'
registry {
url = 'http://' + registryUrl + '/v1'
}
}
task buildDocker(type: DockerBuildImage) {
dependsOn shadowJar
inputDir = project.projectDir
tag = "propel/$project.name:$project.version"
}
task tagDocker(type: DockerTagImage) {
dependsOn buildDocker
force = true
imageId = buildDocker.getTag()
repository = "$registryUrl/$project.name"
tag = "$project.version"
}
task pushDocker(type: DockerPushImage ) {
dependsOn tagDocker
imageName = "$registryUrl/$project.name"
}
task createDocker(type: DockerCreateContainer) {
dependsOn buildDocker
imageId = buildDocker.getTag()
}
task runDocker(type: DockerStartContainer) {
dependsOn createDocker
targetContainerId { createDocker.getContainerId() }
}
task stopDocker(type: DockerStopContainer) {
dependsOn createDocker
targetContainerId { createDocker.getContainerId() }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment