diff --git a/embedded-artifactory/README.adoc b/embedded-artifactory/README.adoc index 8a737c86b..859ce4a8c 100644 --- a/embedded-artifactory/README.adoc +++ b/embedded-artifactory/README.adoc @@ -16,7 +16,7 @@ * `embedded.artifactory.enabled` `(true|false, default is true)` * `embedded.artifactory.reuseContainer` `(true|false, default is false)` -* `embedded.artifactory.dockerImage` `(default is 'releases-docker.jfrog.io/jfrog/artifactory-oss:7.77.12')` +* `embedded.artifactory.dockerImage` `(default is 'releases-docker.jfrog.io/jfrog/artifactory-oss:7.98.9')` ** Release notes on https://www.jfrog.com/confluence/display/JFROG/Artifactory+Release+Notes[jfrog.com] * `embedded.artifactory.networkAlias` `(default is 'artifactory')` * `embedded.artifactory.username` `(default is 'admin')` diff --git a/embedded-artifactory/pom.xml b/embedded-artifactory/pom.xml index e2a357cae..8ae77ca26 100644 --- a/embedded-artifactory/pom.xml +++ b/embedded-artifactory/pom.xml @@ -22,6 +22,10 @@ com.playtika.testcontainers embedded-toxiproxy + + org.testcontainers + postgresql + io.rest-assured @@ -46,4 +50,4 @@ - \ No newline at end of file + diff --git a/embedded-artifactory/src/main/java/com/playtika/testcontainer/artifactory/ArtifactoryProperties.java b/embedded-artifactory/src/main/java/com/playtika/testcontainer/artifactory/ArtifactoryProperties.java index b34370d49..2d1e60c4b 100644 --- a/embedded-artifactory/src/main/java/com/playtika/testcontainer/artifactory/ArtifactoryProperties.java +++ b/embedded-artifactory/src/main/java/com/playtika/testcontainer/artifactory/ArtifactoryProperties.java @@ -27,6 +27,6 @@ public ArtifactoryProperties() { public String getDefaultDockerImage() { // Please don`t remove this comment. // renovate: datasource=docker - return "releases-docker.jfrog.io/jfrog/artifactory-oss:7.77.12"; + return "releases-docker.jfrog.io/jfrog/artifactory-oss:7.98.9"; } } diff --git a/embedded-artifactory/src/main/java/com/playtika/testcontainer/artifactory/EmbeddedArtifactoryBootstrapConfiguration.java b/embedded-artifactory/src/main/java/com/playtika/testcontainer/artifactory/EmbeddedArtifactoryBootstrapConfiguration.java index 4b5ed31d0..5811bbfad 100644 --- a/embedded-artifactory/src/main/java/com/playtika/testcontainer/artifactory/EmbeddedArtifactoryBootstrapConfiguration.java +++ b/embedded-artifactory/src/main/java/com/playtika/testcontainer/artifactory/EmbeddedArtifactoryBootstrapConfiguration.java @@ -16,6 +16,7 @@ import org.springframework.core.env.MapPropertySource; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.Network; +import org.testcontainers.containers.PostgreSQLContainer; import org.testcontainers.containers.ToxiproxyContainer; import org.testcontainers.containers.wait.strategy.HttpWaitStrategy; import org.testcontainers.containers.wait.strategy.WaitStrategy; @@ -32,7 +33,7 @@ @ConditionalOnExpression("${embedded.containers.enabled:true}") @AutoConfigureAfter(DockerPresenceBootstrapConfiguration.class) @ConditionalOnProperty(name = "embedded.artifactory.enabled", matchIfMissing = true) -@EnableConfigurationProperties(ArtifactoryProperties.class) +@EnableConfigurationProperties({ArtifactoryProperties.class, PostgreSQLProperties.class}) public class EmbeddedArtifactoryBootstrapConfiguration { private static final String ARTIFACTORY_NETWORK_ALIAS = "artifactory.testcontainer.docker"; @@ -69,14 +70,33 @@ ToxiproxyContainer.ContainerProxy artifactoryContainerProxy(ToxiproxyContainer t @Bean(name = ARTIFACTORY_BEAN_NAME, destroyMethod = "stop") public GenericContainer artifactory(ConfigurableEnvironment environment, ArtifactoryProperties properties, + PostgreSQLProperties postgresqlProperties, WaitStrategy artifactoryWaitStrategy, Optional network) { + PostgreSQLContainer postgresql = + new PostgreSQLContainer<>(ContainerUtils.getDockerImageName(postgresqlProperties)) + .withNetwork(Network.SHARED) + .withUsername(postgresqlProperties.getUser()) + .withPassword(postgresqlProperties.getPassword()) + .withDatabaseName(postgresqlProperties.getDatabase()) + .withInitScript(postgresqlProperties.initScriptPath) + .withNetworkAliases(properties.getNetworkAlias(), ARTIFACTORY_NETWORK_ALIAS) + .withNetworkAliases(ARTIFACTORY_NETWORK_ALIAS); + + network.ifPresent(postgresql::withNetwork); + configureCommonsAndStart(postgresql, postgresqlProperties, log); + GenericContainer container = new GenericContainer<>(ContainerUtils.getDockerImageName(properties)) .withExposedPorts(properties.getRestApiPort(), properties.getGeneralPort()) .withNetwork(Network.SHARED) .withNetworkAliases(properties.getNetworkAlias(), ARTIFACTORY_NETWORK_ALIAS) + .withEnv("username", postgresqlProperties.user) + .withEnv("password", postgresqlProperties.password) + .withEnv("url", "jdbc:postgresql://localhost:5432/" + postgresqlProperties.database) + .withEnv("type", "postgresql") + .withEnv("driver", "org.postgresql.Driver") .waitingFor(artifactoryWaitStrategy); network.ifPresent(container::withNetwork); diff --git a/embedded-artifactory/src/main/java/com/playtika/testcontainer/artifactory/PostgreSQLProperties.java b/embedded-artifactory/src/main/java/com/playtika/testcontainer/artifactory/PostgreSQLProperties.java new file mode 100644 index 000000000..eaa8f7c80 --- /dev/null +++ b/embedded-artifactory/src/main/java/com/playtika/testcontainer/artifactory/PostgreSQLProperties.java @@ -0,0 +1,30 @@ +package com.playtika.testcontainer.artifactory; + +import com.playtika.testcontainer.common.properties.CommonContainerProperties; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springframework.boot.context.properties.ConfigurationProperties; + +@Data +@EqualsAndHashCode(callSuper = true) +@ConfigurationProperties("embedded.artifactory.postgresql") +public class PostgreSQLProperties extends CommonContainerProperties { + static final String BEAN_NAME_EMBEDDED_POSTGRESQL = "embeddedPostgreSql"; + + String user = "artifactory"; + String password = "artifactory"; + String database = "artifactory"; + String startupLogCheckRegex; + /** + * The SQL file path to execute after the container starts to initialize the database. + */ + String initScriptPath; + + // https://hub.docker.com/_/postgres + @Override + public String getDefaultDockerImage() { + // Please don`t remove this comment. + // renovate: datasource=docker + return "postgres:17-alpine"; + } +}