-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
137 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
.../deployment/src/main/java/io/quarkiverse/temporal/deployment/devui/TemporalContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.quarkiverse.temporal.deployment.devui; | ||
|
||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
// import io.quarkus.devservices.common.ConfigureUtil; | ||
|
||
public class TemporalContainer extends GenericContainer<TemporalContainer> { | ||
|
||
private static final Integer SERVER_EXPOSED_PORT = 7233; | ||
private static final Integer UI_EXPOSED_PORT = 8233; | ||
|
||
private final TemporalDevserviceConfig config; | ||
private String serviceName; | ||
// private String hostname; | ||
|
||
public TemporalContainer(DockerImageName dockerImageName, TemporalDevserviceConfig config) { | ||
super(dockerImageName); | ||
this.config = config; | ||
this.serviceName = "temporal"; | ||
} | ||
|
||
@Override | ||
protected void configure() { | ||
super.configure(); | ||
|
||
withCreateContainerCmdModifier(cmd -> { | ||
cmd.withEntrypoint("/usr/local/bin/temporal"); | ||
cmd.withCmd("server", "start-dev", "--ip", "0.0.0.0"); | ||
}); | ||
|
||
withExposedPorts(SERVER_EXPOSED_PORT, UI_EXPOSED_PORT); | ||
|
||
withLabel("quarkus-devservice-temporal", serviceName); | ||
|
||
withReuse(config.reuse()); | ||
|
||
// hostname = ConfigureUtil.configureSharedNetwork(this, "temporal-" + serviceName); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...ment/src/main/java/io/quarkiverse/temporal/deployment/devui/TemporalDevserviceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.quarkiverse.temporal.deployment.devui; | ||
|
||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
import io.smallrye.config.ConfigMapping; | ||
import io.smallrye.config.WithDefault; | ||
|
||
@ConfigMapping(prefix = "quarkus.temporal.devservice") | ||
@ConfigRoot(phase = ConfigPhase.BUILD_TIME) | ||
public interface TemporalDevserviceConfig { | ||
|
||
/** | ||
* Enable the Temporal Devservice. | ||
*/ | ||
@WithDefault("true") | ||
Boolean enabled(); | ||
|
||
/** | ||
* The image to use for the Temporal Devservice. | ||
*/ | ||
@WithDefault("temporalio/auto-setup") | ||
String image(); | ||
|
||
/** | ||
* The version of the image to use for the Temporal Devservice. | ||
*/ | ||
@WithDefault("latest") | ||
String version(); | ||
|
||
/** | ||
* Whether to reuse the Temporal Devservice. | ||
*/ | ||
@WithDefault("true") | ||
Boolean reuse(); | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
...t/src/main/java/io/quarkiverse/temporal/deployment/devui/TemporalDevserviceProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.quarkiverse.temporal.deployment.devui; | ||
|
||
import java.util.Map; | ||
|
||
import org.testcontainers.utility.DockerImageName; | ||
|
||
import io.quarkus.deployment.IsNormal; | ||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.BuildSteps; | ||
import io.quarkus.deployment.builditem.DevServicesResultBuildItem; | ||
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig; | ||
import io.quarkus.devservices.common.ContainerLocator; | ||
|
||
@BuildSteps(onlyIfNot = IsNormal.class, onlyIf = { GlobalDevServicesConfig.Enabled.class }) | ||
public class TemporalDevserviceProcessor { | ||
|
||
private static final Integer SERVER_EXPOSED_PORT = 7233; | ||
private static final Integer UI_EXPOSED_PORT = 8233; | ||
private static final String DEV_SERVICE_LABEL = "quarkus-devservice-temporal"; | ||
private static final ContainerLocator containerLocator = new ContainerLocator(DEV_SERVICE_LABEL, SERVER_EXPOSED_PORT); | ||
|
||
@BuildStep | ||
public void build(TemporalDevserviceConfig config, BuildProducer<DevServicesResultBuildItem> devServiceProducer) { | ||
if (Boolean.FALSE.equals(config.enabled())) { | ||
return; | ||
} | ||
|
||
var imageStr = config.image() + ":" + config.version(); | ||
var image = DockerImageName.parse(imageStr) | ||
.asCompatibleSubstituteFor(imageStr); | ||
|
||
var serverContainer = new TemporalContainer(image, config); | ||
serverContainer.start(); | ||
|
||
var serverPort = serverContainer.getMappedPort(SERVER_EXPOSED_PORT); | ||
devServiceProducer.produce(new DevServicesResultBuildItem("temporal", serverContainer.getContainerId(), Map.of( | ||
"quarkus.temporal.connection.target", "localhost:" + serverPort))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters