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);
}
Aggregations