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:
Michael Vorburger
2019-11-26 06:06:59 +01:00
parent 01518b0f32
commit edc9e030e1
7 changed files with 26 additions and 18 deletions
@@ -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();
}
}
}
@@ -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);