From 8c09761f41fa8f2141567d403ef010364eb3a693 Mon Sep 17 00:00:00 2001 From: Wikum Weerakutti Date: Fri, 6 Sep 2024 12:39:24 +0300 Subject: [PATCH] O3-3427: Update SDK to follow updated /distro_root structure --- .../openmrs/maven/plugins/BuildDistro.java | 34 +++++++++++++++---- .../resources/build-distro/docker-compose.yml | 9 +++-- .../build-distro/web/Dockerfile-jre11 | 10 ++++++ .../build-distro/web/Dockerfile-jre11-bundled | 4 +++ .../build-distro/web/Dockerfile-jre8 | 27 ++++----------- .../build-distro/web/Dockerfile-jre8-bundled | 23 ++----------- 6 files changed, 55 insertions(+), 52 deletions(-) create mode 100644 maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre11 create mode 100644 maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre11-bundled diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java index dc7144259..8afdb1aab 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/BuildDistro.java @@ -333,13 +333,28 @@ private String buildDistro(File targetDirectory, Artifact distroArtifact, Distro downloadOWAs(targetDirectory, distroProperties, owasDir); } + + boolean isAbovePlatform2point0 = isAbovePlatformVersion(new Version(distroProperties.getPlatformVersion()), 2, 0); + if(isAbovePlatform2point0) { + File openmrsCoreDir = new File(web, "openmrs_core"); + openmrsCoreDir.mkdir(); + new File(web, "openmrs.war").renameTo(new File(openmrsCoreDir, "openmrs.war")); + new File(web, "modules").renameTo(new File(web, "openmrs_modules")); + new File(web, "frontend").renameTo(new File(web, "openmrs_spa")); + new File(web, "configuration").renameTo(new File(web, "openmrs_config")); + new File(web, "owa").renameTo(new File(web, "openmrs_owas")); + } + wizard.showMessage("Creating Docker Compose configuration...\n"); String distroVersion = adjustImageName(distroProperties.getVersion()); writeDockerCompose(targetDirectory, distroVersion); writeReadme(targetDirectory, distroVersion); - copyBuildDistroResource("setenv.sh", new File(web, "setenv.sh")); - copyBuildDistroResource("startup.sh", new File(web, "startup.sh")); - copyBuildDistroResource("wait-for-it.sh", new File(web, "wait-for-it.sh")); + if(!isAbovePlatform2point0) { + copyBuildDistroResource("setenv.sh", new File(web, "setenv.sh")); + copyBuildDistroResource("startup.sh", new File(web, "startup.sh")); + copyBuildDistroResource("wait-for-it.sh", new File(web, "wait-for-it.sh")); + } + copyBuildDistroResource(".env", new File(targetDirectory, ".env")); copyDockerfile(web, distroProperties); distroProperties.saveTo(web); @@ -429,9 +444,9 @@ private void copyDockerfile(File targetDirectory, DistroProperties distroPropert } else { if (isPlatform2point5AndAbove(platformVersion)) { if (bundled) { - copyBuildDistroResource("Dockerfile-tomcat8-bundled", new File(targetDirectory, "Dockerfile")); + copyBuildDistroResource("Dockerfile-jre11-bundled", new File(targetDirectory, "Dockerfile")); } else { - copyBuildDistroResource("Dockerfile-tomcat8", new File(targetDirectory, "Dockerfile")); + copyBuildDistroResource("Dockerfile-jre11", new File(targetDirectory, "Dockerfile")); } } else { @@ -445,10 +460,15 @@ private void copyDockerfile(File targetDirectory, DistroProperties distroPropert } private boolean isPlatform2point5AndAbove(Version platformVersion) { - return platformVersion.getMajorVersion() > 2 - || (platformVersion.getMajorVersion() == 2 && platformVersion.getMinorVersion() >= 5); + return isAbovePlatformVersion(platformVersion, 2, 5); + } + + private boolean isAbovePlatformVersion(Version platformVersion, int majorVersion, int minorVersion) { + return platformVersion.getMajorVersion() > majorVersion + || (platformVersion.getMajorVersion() == majorVersion && platformVersion.getMinorVersion() >= minorVersion); } + /** * name of sql dump file is unknown, so wipe all files with 'sql' extension */ diff --git a/maven-plugin/src/main/resources/build-distro/docker-compose.yml b/maven-plugin/src/main/resources/build-distro/docker-compose.yml index 66093e599..d732501e9 100644 --- a/maven-plugin/src/main/resources/build-distro/docker-compose.yml +++ b/maven-plugin/src/main/resources/build-distro/docker-compose.yml @@ -2,12 +2,12 @@ version: "3.7" services: db: - image: mariadb:10.8.2 + image: mariadb:10.11.7 command: "mysqld --character-set-server=utf8 --collation-server=utf8_general_ci" environment: MYSQL_DATABASE: openmrs - MYSQL_USER: ${OPENMRS_DB_USER:-openmrs} - MYSQL_PASSWORD: ${OPENMRS_DB_PASSWORD:-openmrs} + MYSQL_USER: ${OMRS_DB_USER:-openmrs} + MYSQL_PASSWORD: ${OMRS_DB_PASSWORD:-openmrs} MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-openmrs} volumes: - db-data:/var/lib/mysql @@ -24,8 +24,7 @@ services: OMRS_CONFIG_AUTO_UPDATE_DATABASE: "true" OMRS_CONFIG_CREATE_TABLES: "true" OMRS_CONFIG_CONNECTION_SERVER: db - OMRS_CONFIG_CONNECTION_URL: ${OPENMRS_DB_URL:-jdbc:mysql://localhost:3306/openmrs} - OMRS_CONFIG_CONNECTION_DATABASE: ${OPENMRS_DB_NAME:-openmrs} + OMRS_CONFIG_CONNECTION_DATABASE: openmrs OMRS_CONFIG_CONNECTION_USERNAME: ${OPENMRS_DB_USER:-openmrs} OMRS_CONFIG_CONNECTION_PASSWORD: ${OPENMRS_DB_PASSWORD:-openmrs} healthcheck: diff --git a/maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre11 b/maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre11 new file mode 100644 index 000000000..3f64cec22 --- /dev/null +++ b/maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre11 @@ -0,0 +1,10 @@ +# Docker configuration automatically generated by openmrs SDK + +FROM openmrs/openmrs-core:nightly-amazoncorretto-11 + +COPY openmrs_core/openmrs.war /openmrs/distribution/openmrs_core/ +COPY openmrs-distro.properties /openmrs/distribution/ +COPY openmrs_modules /openmrs/distribution/openmrs_modules +COPY openmrs_owas /openmrs/distribution/openmrs_owas +COPY openmrs_config /openmrs/distribution/openmrs_config +COPY openmrs_spa /openmrs/distribution/openmrs_spa \ No newline at end of file diff --git a/maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre11-bundled b/maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre11-bundled new file mode 100644 index 000000000..c761c4ee0 --- /dev/null +++ b/maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre11-bundled @@ -0,0 +1,4 @@ +FROM openmrs/openmrs-core:nightly-amazoncorretto-11 + +COPY openmrs_core/openmrs.war /openmrs/distribution/openmrs_core/ +COPY openmrs-distro.properties /openmrs/distribution/ \ No newline at end of file diff --git a/maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre8 b/maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre8 index 8421eb3ab..bf9f4a1f1 100644 --- a/maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre8 +++ b/maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre8 @@ -1,23 +1,10 @@ -FROM tomcat:7-jre8 - # Docker configuration automatically generated by openmrs SDK -COPY openmrs.war /usr/local/tomcat/webapps/openmrs.war -COPY modules /usr/local/tomcat/.OpenMRS/modules -COPY owa /usr/local/tomcat/.OpenMRS/owa - -COPY setenv.sh /usr/local/tomcat/bin/setenv.sh - -COPY wait-for-it.sh /usr/local/tomcat/wait-for-it.sh -COPY startup.sh /usr/local/tomcat/startup.sh - -RUN sed -i '/Connector port="8080"/a URIEncoding="UTF-8" relaxedPathChars="[]|" relaxedQueryChars="[]|{}^\`"<>"' /usr/local/tomcat/conf/server.xml - -RUN chmod +x /usr/local/tomcat/wait-for-it.sh -RUN chmod +x /usr/local/tomcat/startup.sh - -# For documentation purpose only -COPY openmrs-distro.properties /root/openmrs-distro.properties -COPY Dockerfile /root/Dockerfile +FROM openmrs/openmrs-core:nightly-amazoncorretto-8 -CMD ["/usr/local/tomcat/startup.sh"] +COPY openmrs_core/openmrs.war /openmrs/distribution/openmrs_core/ +COPY openmrs-distro.properties /openmrs/distribution/ +COPY openmrs_modules /openmrs/distribution/openmrs_modules +COPY openmrs_owas /openmrs/distribution/openmrs_owas +COPY openmrs_config /openmrs/distribution/openmrs_config +COPY openmrs_spa /openmrs/distribution/openmrs_spa \ No newline at end of file diff --git a/maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre8-bundled b/maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre8-bundled index 8157b3078..bcab3abec 100644 --- a/maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre8-bundled +++ b/maven-plugin/src/main/resources/build-distro/web/Dockerfile-jre8-bundled @@ -1,21 +1,4 @@ -FROM tomcat:7-jre8 +FROM openmrs/openmrs-core:nightly-amazoncorretto-8 -# Docker configuration automatically generated by openmrs SDK - -COPY openmrs.war /usr/local/tomcat/webapps/openmrs.war - -COPY setenv.sh /usr/local/tomcat/bin/setenv.sh - -COPY wait-for-it.sh /usr/local/tomcat/wait-for-it.sh -COPY startup.sh /usr/local/tomcat/startup.sh - -RUN sed -i '/Connector port="8080"/a URIEncoding="UTF-8" relaxedPathChars="[]|" relaxedQueryChars="[]|{}^\`"<>"' /usr/local/tomcat/conf/server.xml - -RUN chmod +x /usr/local/tomcat/wait-for-it.sh -RUN chmod +x /usr/local/tomcat/startup.sh - -# For documentation purpose only -COPY openmrs-distro.properties /root/openmrs-distro.properties -COPY Dockerfile /root/Dockerfile - -CMD ["/usr/local/tomcat/startup.sh"] +COPY openmrs_core/openmrs.war /openmrs/distribution/openmrs_core/ +COPY openmrs-distro.properties /openmrs/distribution/ \ No newline at end of file