Docker
- gradle plugin
π‘ This plugin gives helpful gradle tasks for working with docker containers for projects with any types and languages.
-
You only need to have
docker-compose.yml
file in root of your project -
In your
build.gradle.kts
file:
plugins {
id("online.colaba.docker") version "1.4.1"
}
gradle deploy
this task is equivalent to
docker-compose up --build --force-recreate --detach
command.
deploy
- compose up project fromdocker-compose.yml
file (default with recreate & rebuild)deployDev
- compose up docker container fromdocker-compose.dev.yml
filerecompose
,recomposeDev
- compose up after removing current docker-servicestop
,remove
- stop/remove docker containerlogs
,docker
- print current docker-services
Name of service for all tasks equals to ${project.name}. You can customize options of each task.
tasks{
docker{
exec = "rm -f ${project.name}"
}
}
tasks{
val remove by registering(Docker::class) { exec = "rm -f ${project.name}" }
val deploy by existing(Docker::class){
dependsOn(remove)
recreate = false
composeFile = "docker-compose.dev.yml"
}
}
gradle deploy
π« Example
- Structure:
[project]
| - build.gradle.kts
| - docker-compose.yml
| - docker-compose.dev.yml (optional)
docker-compose.dev.yml
,Dockerfile
&Dockerfile.dev
files are optionals
With docker plugin
you have additional bonus task for executing a command line process on local PC [linux/windows]:
tasks{
execute{
command = "echo ${project.name}"
}
}