au.net.causal.maven.plugins.boxdb.db.PostgisDatabase Maven / Gradle / Ivy
package au.net.causal.maven.plugins.boxdb.db;
import au.net.causal.maven.plugins.boxdb.ImageCheckerUtils;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.fabric8.maven.docker.config.RunImageConfiguration;
import java.util.Collection;
import java.util.List;
public class PostgisDatabase extends PostgresDatabase
{
public PostgisDatabase(BoxConfiguration boxConfiguration,
ProjectConfiguration projectConfiguration,
BoxContext context, DockerRegistry dockerRegistry)
{
super(boxConfiguration, projectConfiguration, context, dockerRegistry);
}
@Override
public Collection extends ImageComponent> checkImage()
throws BoxDatabaseException
{
ImageComponent jdbcDriverComponent = ImageCheckerUtils.checkImageUsingMavenDependencies("JDBC driver",
getContext(),
jdbcDriverInfo().getDependencies());
ImageComponent dockerDatabaseComponent = checkDockerDatabaseImage(PostgisFactory.POSTGIS_DOCKER_REPOSITORY);
return ImmutableList.of(jdbcDriverComponent, dockerDatabaseComponent);
}
@Override
protected String dockerImageName()
{
return PostgisFactory.POSTGIS_DOCKER_REPOSITORY + ":" + getBoxConfiguration().getDatabaseVersion();
}
@Override
protected String postgresToolsImageName()
{
//For now, just pick a client that we know will be able to talk to the latest version of Postgis
//Unfortunately we cannot use the postgis image itself because it tries to spin up a whole DB every time
//it is run so we use the base postgres one for running tools
return "postgres:11";
}
@Override
protected void configureRunImage(RunImageConfiguration.Builder builder)
{
super.configureRunImage(builder);
builder.env(ImmutableMap.of("POSTGRES_PASS", getBoxConfiguration().getAdminPassword(),
"POSTGRES_USER", getBoxConfiguration().getAdminUser(),
"ALLOW_IP_RANGE", "0.0.0.0/0"));
}
@Override
public JdbcDriverInfo jdbcDriverInfo()
throws BoxDatabaseException
{
//Add PostGIS artifacts to the existing Postgres ones
JdbcDriverInfo postgresJdbc = super.jdbcDriverInfo();
List dependencies = ImmutableList.builder()
.addAll(postgresJdbc.getDependencies())
.add(new RunnerDependency("net.postgis", "postgis-jdbc", "2.3.0"))
.build();
return new JdbcDriverInfo(dependencies, postgresJdbc.getDriverClassName(), postgresJdbc.getDriverClassName());
}
}