diff --git a/extensions/container-image/container-image-docker/deployment/src/main/java/io/quarkus/container/image/docker/deployment/DockerWorking.java b/core/deployment/src/main/java/io/quarkus/deployment/IsDockerWorking.java similarity index 80% rename from extensions/container-image/container-image-docker/deployment/src/main/java/io/quarkus/container/image/docker/deployment/DockerWorking.java rename to core/deployment/src/main/java/io/quarkus/deployment/IsDockerWorking.java index a396ae16e191e..28ae66b7c6402 100644 --- a/extensions/container-image/container-image-docker/deployment/src/main/java/io/quarkus/container/image/docker/deployment/DockerWorking.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/IsDockerWorking.java @@ -1,5 +1,5 @@ -package io.quarkus.container.image.docker.deployment; +package io.quarkus.deployment; import java.io.BufferedReader; import java.io.File; @@ -13,9 +13,19 @@ import io.quarkus.deployment.util.ExecUtil; -public class DockerWorking implements BooleanSupplier { +public class IsDockerWorking implements BooleanSupplier { - private static final Logger LOGGER = Logger.getLogger(DockerWorking.class.getName()); + private static final Logger LOGGER = Logger.getLogger(IsDockerWorking.class.getName()); + + private final boolean silent; + + public IsDockerWorking() { + this(false); + } + + public IsDockerWorking(boolean silent) { + this.silent = silent; + } @Override public boolean getAsBoolean() { @@ -35,7 +45,9 @@ public boolean getAsBoolean() { LOGGER.info("Docker daemon found. Version:" + filter.getOutput()); return true; } else { - LOGGER.warn("Could not determine version of Docker daemon"); + if (!silent) { + LOGGER.warn("Could not determine version of Docker daemon"); + } return false; } } catch (Exception e) { diff --git a/extensions/container-image/container-image-docker/deployment/src/main/java/io/quarkus/container/image/docker/deployment/DockerProcessor.java b/extensions/container-image/container-image-docker/deployment/src/main/java/io/quarkus/container/image/docker/deployment/DockerProcessor.java index 03cd6549e3a33..183064e35b7de 100644 --- a/extensions/container-image/container-image-docker/deployment/src/main/java/io/quarkus/container/image/docker/deployment/DockerProcessor.java +++ b/extensions/container-image/container-image-docker/deployment/src/main/java/io/quarkus/container/image/docker/deployment/DockerProcessor.java @@ -28,6 +28,7 @@ import io.quarkus.container.spi.ContainerImageBuildRequestBuildItem; import io.quarkus.container.spi.ContainerImageInfoBuildItem; import io.quarkus.container.spi.ContainerImagePushRequestBuildItem; +import io.quarkus.deployment.IsDockerWorking; import io.quarkus.deployment.IsNormalNotRemoteDev; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; @@ -50,7 +51,7 @@ public class DockerProcessor { private static final String DOCKER_DIRECTORY_NAME = "docker"; static final String DOCKER_CONTAINER_IMAGE_NAME = "docker"; - private final DockerWorking dockerWorking = new DockerWorking(); + private final IsDockerWorking isDockerWorking = new IsDockerWorking(); @BuildStep public AvailableContainerImageExtensionBuildItem availability() { @@ -75,7 +76,7 @@ public void dockerBuildFromJar(DockerConfig dockerConfig, return; } - if (!dockerWorking.getAsBoolean()) { + if (!isDockerWorking.getAsBoolean()) { throw new RuntimeException("Unable to build docker image. Please check your docker installation"); } @@ -107,7 +108,7 @@ public void dockerBuildFromNativeImage(DockerConfig dockerConfig, return; } - if (!dockerWorking.getAsBoolean()) { + if (!isDockerWorking.getAsBoolean()) { throw new RuntimeException("Unable to build docker image. Please check your docker installation"); } diff --git a/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java b/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java index 449c0d67bdca8..5d7b0b20f097b 100644 --- a/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java +++ b/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java @@ -21,6 +21,7 @@ import io.quarkus.datasource.deployment.spi.DevServicesDatasourceResultBuildItem; import io.quarkus.datasource.runtime.DataSourceBuildTimeConfig; import io.quarkus.datasource.runtime.DataSourcesBuildTimeConfig; +import io.quarkus.deployment.IsDockerWorking; import io.quarkus.deployment.IsNormal; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; @@ -41,6 +42,8 @@ public class DevServicesDatasourceProcessor { static volatile boolean first = true; + private final IsDockerWorking isDockerWorking = new IsDockerWorking(true); + @BuildStep(onlyIfNot = IsNormal.class) DevServicesDatasourceResultBuildItem launchDatabases(CurateOutcomeBuildItem curateOutcomeBuildItem, List installedDrivers, @@ -182,6 +185,11 @@ private DevServicesDatasourceResultBuildItem.DbResult startDevDb(String dbName, + " as it has been disabled in the config"); return null; } + if (!isDockerWorking.getAsBoolean()) { + log.warn("Please configure datasource URL for " + + (dbName == null ? "default datasource" : dbName) + " or get a working docker instance"); + return null; + } Optional defaultDbKind = DefaultDataSourceDbKindBuildItem.resolve( dataSourceBuildTimeConfig.dbKind, diff --git a/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/DevServicesMongoProcessor.java b/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/DevServicesMongoProcessor.java index 182c9a3312207..ec8c830638517 100644 --- a/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/DevServicesMongoProcessor.java +++ b/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/DevServicesMongoProcessor.java @@ -17,6 +17,7 @@ import org.testcontainers.utility.DockerImageName; import io.quarkus.bootstrap.classloading.QuarkusClassLoader; +import io.quarkus.deployment.IsDockerWorking; import io.quarkus.deployment.IsNormal; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; @@ -36,6 +37,8 @@ public class DevServicesMongoProcessor { static volatile Map capturedProperties; static volatile boolean first = true; + private final IsDockerWorking isDockerWorking = new IsDockerWorking(true); + @BuildStep(onlyIfNot = IsNormal.class) public DevServicesMongoResultBuildItem startMongo(List mongoConnections, MongoClientBuildTimeConfig mongoClientBuildTimeConfig, @@ -146,6 +149,13 @@ private StartResult startMongo(String connectionName, CapturedProperties capture return null; } + if (!isDockerWorking.getAsBoolean()) { + log.warn("Please configure datasource URL for " + + (isDefault(connectionName) ? "default datasource" : connectionName) + + " or get a working docker instance"); + return null; + } + String configPrefix = getConfigPrefix(connectionName); // TODO: do we need to check the hosts as well?