Search in sources :

Example 1 with Dockerfile

use of com.bmuschko.gradle.docker.tasks.image.Dockerfile in project curiostack by curioswitch.

the class CurioDatabasePlugin method addTasks.

private static void addTasks(Project project) {
    ImmutableDatabaseExtension config = project.getExtensions().getByType(DatabaseExtension.class);
    FlywayExtension flyway = project.getExtensions().getByType(FlywayExtension.class);
    flyway.user = "dbadmin";
    flyway.password = config.devAdminPassword();
    flyway.schemas = new String[] { config.dbName() };
    Dockerfile generateDevDbDockerfile = project.getTasks().create("generateDevDbDockerfile", Dockerfile.class);
    generateDevDbDockerfile.from("mysql:5.7");
    generateDevDbDockerfile.environmentVariable("MYSQL_DATABASE", config.dbName());
    generateDevDbDockerfile.environmentVariable("MYSQL_USER", config.devAdminUser());
    String devAdminPassword = config.devAdminPassword();
    if (devAdminPassword != null) {
        generateDevDbDockerfile.environmentVariable("MYSQL_PASSWORD", devAdminPassword);
        // Root privilege needs to be exposed to create users other than MYSQL_USER.
        generateDevDbDockerfile.environmentVariable("MYSQL_ROOT_PASSWORD", devAdminPassword);
    }
    DockerBuildImage buildDevDbDockerImage = project.getTasks().create("buildDevDbDockerImage", DockerBuildImage.class);
    buildDevDbDockerImage.dependsOn(generateDevDbDockerfile);
    buildDevDbDockerImage.setInputDir(generateDevDbDockerfile.getDestFile().getParentFile());
    buildDevDbDockerImage.setTag(config.devDockerImageTag());
    GcloudTask pushDevDbDockerImage = project.getTasks().create("pushDevDbDockerImage", GcloudTask.class);
    pushDevDbDockerImage.dependsOn(buildDevDbDockerImage);
    pushDevDbDockerImage.setArgs(ImmutableList.of("docker", "--", "push", config.devDockerImageTag()));
    project.getTasks().create("deployDevDb", DeployDevDbPodTask.class).dependsOn(pushDevDbDockerImage);
}
Also used : Dockerfile(com.bmuschko.gradle.docker.tasks.image.Dockerfile) GcloudTask(org.curioswitch.gradle.plugins.gcloud.tasks.GcloudTask) DeployDevDbPodTask(org.curioswitch.gradle.plugins.gcloud.tasks.DeployDevDbPodTask) DockerBuildImage(com.bmuschko.gradle.docker.tasks.image.DockerBuildImage) FlywayExtension(org.flywaydb.gradle.FlywayExtension)

Aggregations

DockerBuildImage (com.bmuschko.gradle.docker.tasks.image.DockerBuildImage)1 Dockerfile (com.bmuschko.gradle.docker.tasks.image.Dockerfile)1 DeployDevDbPodTask (org.curioswitch.gradle.plugins.gcloud.tasks.DeployDevDbPodTask)1 GcloudTask (org.curioswitch.gradle.plugins.gcloud.tasks.GcloudTask)1 FlywayExtension (org.flywaydb.gradle.FlywayExtension)1