Introduction

This is a plugin for the popular Gradle build tool. It enables you to integrate the orchestration management tool docker-compose into your build.gradle. Unlike other docker plugins, docker-compose-gradle-plugin has some unique features:

  • Rich domain language to integration docker-compose into your build
  • Select docker environment using docker-machine
  • Download docker-compose if not installed

Usage

Plugin Activation

To activate the plugin, insert the following code into your build.gradle:

buildscript {
    repositories {
        maven {
            url  "http://dl.bintray.com/nbyl/maven"
        }
    }

    dependencies {
        classpath("com.github.nbyl.gradle:docker-compose-gradle-plugin:0.3.0")
    }
}

apply plugin: 'com.github.nbyl.docker-compose'

Afterwards you can use the provided tasks to activate docker-compose.

Configuration

Download of docker-compose

The plugin can optionally download docker-compose and use. Simple turn the download property on: dockerCompose { download = true }

Tasks

com.github.nbyl.gradle.dockercompose.tasks.DockerComposeBuild

This task calls the build command to build all missing containers.

Property Default Value Description
composeFile   The location of the docker-compose file to use. If not set, it will use the default of docker-compose (docker-compose.yml).
dockerMachineEnvironment   The docker-machine environment to select. See Docker Machine Support for furhter details.

com.github.nbyl.gradle.dockercompose.tasks.DockerComposeDown

This task calls the build command to remove all containers and networks.

Property Default Value Description
composeFile   The location of the docker-compose file to use. If not set, it will use the default of docker-compose (docker-compose.yml).
dockerMachineEnvironment   The docker-machine environment to select. See Docker Machine Support for furhter details.

com.github.nbyl.gradle.dockercompose.tasks.DockerComposeUp

This task calls the up command to start all containers and networks.

Property Default Value Description
composeFile   The location of the docker-compose file to use. If not set, it will use the default of docker-compose (docker-compose.yml).
dockerMachineEnvironment   The docker-machine environment to select. See Docker Machine Support for furhter details.

Docker-Machine Support

The plugin supports selection of the docker host using the provisioning tool docker-machine. If you define a task start using the follwing configuration:

task start(type: DockerComposeUp) {
    dockerMachineEnvironment 'dev'
}

The plugin will read the settings from the docker-machine configuration dev first and use it to connect to the given docker daemon. This way, you can keep the configuration of your docker hosts from the build description.

Development

The code of the docker-compose-gradle-plugin is avaible at GitHub. The current state of the master branch can be visited at Travis CI.

If you see any errors feel free to provide a patch. To do so, simply open a pull request at https://github.com/nbyl/docker-compose-gradle-plugin/pulls. Afterwards Travis will build the code and if the build succeeds your pull request will be merged by the development team.

To create a release the following procedurs needs to be executed:

  • Create a Tag and push it to github: git tag '<version>' && git push --tags
  • Travis will build the release and deploy the artifacts to bintray

License

The plugin is provided under the Apache License Version 2.0