Allow customizing JDBC URLs at run-time instead of during container build (FINERACT-773)
In Docker, set JAVA_OPTS instead of FINERACT_TENANTS_URL. Because ARG/ENV in the Dockerfile can't (easily) be changed at run-time. At first I tried to override the ENTRYPOINT with a script which sets JAVA_OPTS based on FINERACT_TENANTS_URL and then delegates to the original /app-entrypoint.sh; that didn't immediately work, so this seems simpler. Including make default tenant JDBC hostname & port configurable at Docker container run instead of build time.
This commit is contained in:
+6
-1
@@ -32,6 +32,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import com.googlecode.flyway.core.Flyway;
|
||||
import com.googlecode.flyway.core.api.FlywayException;
|
||||
import com.googlecode.flyway.core.util.jdbc.DriverDataSource;
|
||||
@@ -90,8 +92,11 @@ public class TenantDatabaseUpgradeService {
|
||||
flyway.setDataSource(tenantDataSource);
|
||||
flyway.setLocations("sql/migrations/list_db");
|
||||
flyway.setOutOfOrder(true);
|
||||
flyway.setPlaceholders(ImmutableMap.of( // FINERACT-773
|
||||
"fineract_default_tenantdb_hostname", System.getProperty("FINERACT_DEFAULT_TENANTDB_HOSTNAME", "localhost"),
|
||||
"fineract_default_tenantdb_port", System.getProperty("FINERACT_DEFAULT_TENANTDB_PORT", "3306")));
|
||||
flyway.migrate();
|
||||
|
||||
tenantDataSourcePortFixService.fixUpTenantsSchemaServerPort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ CREATE TABLE `tenants` (
|
||||
|
||||
LOCK TABLES `tenants` WRITE;
|
||||
/*!40000 ALTER TABLE `tenants` DISABLE KEYS */;
|
||||
INSERT INTO `tenants` VALUES (1,'default','Default Demo Tenant','mifostenant-default','Asia/Kolkata',NULL,NULL,NULL,NULL,'localhost','3306','root','mysql',1);
|
||||
INSERT INTO `tenants` VALUES (1,'default','Default Demo Tenant','mifostenant-default','Asia/Kolkata',NULL,NULL,NULL,NULL,'${fineract_default_tenantdb_hostname}','${fineract_default_tenantdb_port}','root','mysql',1);
|
||||
-- Add tenants to support interoperation multi-tenancy
|
||||
-- INSERT INTO `tenants` VALUES (2,'tn01','Buffalo','tn01','Africa/Bujumbura',NULL,NULL,NULL,NULL,'localhost','3306','root','mysql',1);
|
||||
-- INSERT INTO `tenants` VALUES (3,'tn02','Lion','tn02','Africa/Bujumbura',NULL,NULL,NULL,NULL,'localhost','3306','root','mysql',1);
|
||||
|
||||
Reference in New Issue
Block a user