fix: use PostgreSQL service container in CI instead of Testcontainers
CI — Build, Lint & Security Scan / backend (push) Failing after 48s
CI — Build, Lint & Security Scan / frontend (push) Failing after 1m7s
CI — Build, Lint & Security Scan / image-scan (push) Has been skipped
CI — Build, Lint & Security Scan / secrets-scan (push) Failing after 42s
Deploy to TrueNAS / deploy (push) Successful in 2m52s

Testcontainers can't network properly on TrueNAS act-runner (host network vs bridge). Added postgres:16-alpine service container to CI workflow and made AbstractIntegrationTest conditionally skip Testcontainers when CI_POSTGRES_URL env var is present.
This commit is contained in:
Patrick Plate
2026-06-19 16:14:06 +02:00
parent ade9673f02
commit 51a9d1db58
2 changed files with 40 additions and 7 deletions
@@ -42,16 +42,31 @@ import java.util.UUID;
public abstract class AbstractIntegrationTest {
@Container
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16-alpine")
.withDatabaseName("cannamanage_test")
.withUsername("test")
.withPassword("test");
static PostgreSQLContainer<?> postgres = shouldUseTestcontainers()
? new PostgreSQLContainer<>("postgres:16-alpine")
.withDatabaseName("cannamanage_test")
.withUsername("test")
.withPassword("test")
: null;
@DynamicPropertySource
static void configureProperties(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", postgres::getJdbcUrl);
registry.add("spring.datasource.username", postgres::getUsername);
registry.add("spring.datasource.password", postgres::getPassword);
if (postgres != null) {
registry.add("spring.datasource.url", postgres::getJdbcUrl);
registry.add("spring.datasource.username", postgres::getUsername);
registry.add("spring.datasource.password", postgres::getPassword);
} else {
registry.add("spring.datasource.url", () -> System.getenv("CI_POSTGRES_URL"));
registry.add("spring.datasource.username", () -> System.getenv("CI_POSTGRES_USER"));
registry.add("spring.datasource.password", () -> System.getenv("CI_POSTGRES_PASSWORD"));
}
}
/**
* Use Testcontainers locally; skip when CI provides PostgreSQL via service container.
*/
private static boolean shouldUseTestcontainers() {
return System.getenv("CI_POSTGRES_URL") == null;
}
@LocalServerPort