Merge pull request #648 from vorburger/FINERACT-773_Dockerfile-JDBC-URL
Make it possible to customize JDBC URLs in Docker Image at run-time instead of at build (FINERACT-773)
This commit is contained in:
+2
-1
@@ -62,4 +62,5 @@ script:
|
|||||||
# @see https://docs.travis-ci.com/user/job-lifecycle/#customizing-the-build-phase
|
# @see https://docs.travis-ci.com/user/job-lifecycle/#customizing-the-build-phase
|
||||||
- ./gradlew --console=plain licenseMain licenseTest licenseIntegrationTest test && ./gradlew --console=plain integrationTest
|
- ./gradlew --console=plain licenseMain licenseTest licenseIntegrationTest test && ./gradlew --console=plain integrationTest
|
||||||
# We must stop mysql the mysql system service to avoid port 3306 conflicts (unless we run the mysql in docker-compose on another port; req. FINERACT-773)
|
# We must stop mysql the mysql system service to avoid port 3306 conflicts (unless we run the mysql in docker-compose on another port; req. FINERACT-773)
|
||||||
- sudo service mysql stop && docker-compose build && docker-compose up -d && sleep 30s && http --verify=no --timeout 240 --check-status get https://localhost:8443/fineract-provider/actuator/health
|
- sudo service mysql stop && docker-compose build && docker-compose up -d && sleep 30s && http --verify=no --timeout 240 --check-status get https://localhost:8443/fineract-provider/actuator/health || docker logs fineract_fineract-server_1
|
||||||
|
# The || docker logs lets use see the root cause in case of failures
|
||||||
|
|||||||
+7
-7
@@ -21,23 +21,23 @@ RUN mkdir fineract
|
|||||||
COPY . fineract
|
COPY . fineract
|
||||||
|
|
||||||
WORKDIR fineract
|
WORKDIR fineract
|
||||||
ARG mysqlserver=fineractmysql
|
RUN ./gradlew clean -x rat -x test war
|
||||||
RUN sed -i "s/localhost/${mysqlserver}/" ./fineract-provider/src/main/resources/sql/migrations/list_db/V1__mifos-platform-shared-tenants.sql
|
|
||||||
RUN ./gradlew clean -x test war
|
|
||||||
|
|
||||||
|
# =========================================
|
||||||
|
|
||||||
FROM bitnami/tomcat:7.0.94 as fineract
|
FROM bitnami/tomcat:7.0.94 as fineract
|
||||||
|
|
||||||
USER root
|
|
||||||
ARG mysqlserver=fineractmysql
|
|
||||||
RUN apt-get update -qq && apt-get install -y wget
|
|
||||||
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/jre
|
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/jre
|
||||||
|
|
||||||
|
USER root
|
||||||
|
RUN apt-get update -qq && apt-get install -y wget
|
||||||
|
|
||||||
COPY --from=builder /fineract/build/libs/fineract-provider.war /opt/bitnami/tomcat/webapps
|
COPY --from=builder /fineract/build/libs/fineract-provider.war /opt/bitnami/tomcat/webapps
|
||||||
|
|
||||||
RUN keytool -genkey -keyalg RSA -alias tomcat -keystore /opt/bitnami/tomcat/tomcat.keystore -keypass xyz123 -storepass xyz123 -noprompt -dname "CN=Fineract, OU=Fineract, O=Fineract, L=Unknown, ST=Unknown, C=Unknown"
|
RUN keytool -genkey -keyalg RSA -alias tomcat -keystore /opt/bitnami/tomcat/tomcat.keystore -keypass xyz123 -storepass xyz123 -noprompt -dname "CN=Fineract, OU=Fineract, O=Fineract, L=Unknown, ST=Unknown, C=Unknown"
|
||||||
COPY ./docker/server.xml /opt/bitnami/tomcat/conf
|
COPY ./docker/server.xml /opt/bitnami/tomcat/conf
|
||||||
RUN sed -i "s/fineractmysql/${mysqlserver}/" /opt/bitnami/tomcat/conf/server.xml
|
|
||||||
RUN chmod 664 /opt/bitnami/tomcat/conf/server.xml
|
RUN chmod 664 /opt/bitnami/tomcat/conf/server.xml
|
||||||
WORKDIR /opt/bitnami/tomcat/lib
|
WORKDIR /opt/bitnami/tomcat/lib
|
||||||
|
# org.drizzle.jdbc.DrizzleDriver is used in docker/server.xml for jdbc/mifosplatform-tenants DataSource
|
||||||
|
# (But note that connections to individual tenant DBs may use another driver...)
|
||||||
RUN wget http://central.maven.org/maven2/org/drizzle/jdbc/drizzle-jdbc/1.4/drizzle-jdbc-1.4.jar
|
RUN wget http://central.maven.org/maven2/org/drizzle/jdbc/drizzle-jdbc/1.4/drizzle-jdbc-1.4.jar
|
||||||
|
|||||||
@@ -95,13 +95,11 @@ The [`docker-compose.yml`](docker-compose.yml) will build the `fineract` contain
|
|||||||
|
|
||||||
https://hub.docker.com/r/apache/fineract has a pre-built container of this project, built continuously.
|
https://hub.docker.com/r/apache/fineract has a pre-built container of this project, built continuously.
|
||||||
|
|
||||||
You can use a MySQL database from a different or remote server by passing the server's IP address to the docker fineract build process like this:
|
You must specify the MySQL tenants database JDBC URL by passing it to the `fineract` container via environment
|
||||||
|
variables; please consult the [`docker-compose.yml`](docker-compose.yml) for exact details how to specify those.
|
||||||
docker build --build-arg mysqlserver=<MySQL server IP> -t fineract:latest .
|
_(Note that in previous versions, the `mysqlserver` environment variable used at `docker build` time instead of at
|
||||||
|
`docker run` time did something similar; this has changed in [FINERACT-773](https://issues.apache.org/jira/browse/FINERACT-773)),
|
||||||
The run it:
|
and the `mysqlserver` environment variable is now no longer supported.)_
|
||||||
|
|
||||||
docker run -d fineract:latest
|
|
||||||
|
|
||||||
|
|
||||||
Version
|
Version
|
||||||
|
|||||||
@@ -42,3 +42,7 @@ services:
|
|||||||
- 8443:8443
|
- 8443:8443
|
||||||
depends_on:
|
depends_on:
|
||||||
- fineractmysql
|
- fineractmysql
|
||||||
|
environment:
|
||||||
|
- JAVA_OPTS=-Dfineract_tenants_url=jdbc:mysql:thin://fineractmysql:3306/mifosplatform-tenants -Djava.awt.headless=true -XX:+UseG1GC -Dfile.encoding=UTF-8
|
||||||
|
- FINERACT_DEFAULT_TENANTDB_HOSTNAME=fineractmysql
|
||||||
|
- FINERACT_DEFAULT_TENANTDB_PORT=3306
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@
|
|||||||
name="jdbc/mifosplatform-tenants"
|
name="jdbc/mifosplatform-tenants"
|
||||||
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
|
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
|
||||||
driverClassName="org.drizzle.jdbc.DrizzleDriver"
|
driverClassName="org.drizzle.jdbc.DrizzleDriver"
|
||||||
url="jdbc:mysql:thin://fineractmysql:3306/mifosplatform-tenants"
|
url="${fineract_tenants_url}"
|
||||||
username="root"
|
username="root"
|
||||||
password="mysql"
|
password="mysql"
|
||||||
initialSize="3"
|
initialSize="3"
|
||||||
|
|||||||
+6
-1
@@ -32,6 +32,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import com.googlecode.flyway.core.Flyway;
|
import com.googlecode.flyway.core.Flyway;
|
||||||
import com.googlecode.flyway.core.api.FlywayException;
|
import com.googlecode.flyway.core.api.FlywayException;
|
||||||
import com.googlecode.flyway.core.util.jdbc.DriverDataSource;
|
import com.googlecode.flyway.core.util.jdbc.DriverDataSource;
|
||||||
@@ -90,8 +92,11 @@ public class TenantDatabaseUpgradeService {
|
|||||||
flyway.setDataSource(tenantDataSource);
|
flyway.setDataSource(tenantDataSource);
|
||||||
flyway.setLocations("sql/migrations/list_db");
|
flyway.setLocations("sql/migrations/list_db");
|
||||||
flyway.setOutOfOrder(true);
|
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();
|
flyway.migrate();
|
||||||
|
|
||||||
tenantDataSourcePortFixService.fixUpTenantsSchemaServerPort();
|
tenantDataSourcePortFixService.fixUpTenantsSchemaServerPort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ CREATE TABLE `tenants` (
|
|||||||
|
|
||||||
LOCK TABLES `tenants` WRITE;
|
LOCK TABLES `tenants` WRITE;
|
||||||
/*!40000 ALTER TABLE `tenants` DISABLE KEYS */;
|
/*!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
|
-- 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 (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);
|
-- 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