Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OZ-668: Add Ability to run Ozone in a single and standalone (distro-embedded) Docker Compose file #83

Merged
merged 14 commits into from
Sep 3, 2024
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ jobs:
secrets:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
7 changes: 4 additions & 3 deletions assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
http://maven.apache.org/xsd/assembly-1.1.2.xsd"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"
>
<id>zip-distro-dir</id>
<formats>
Expand All @@ -15,6 +13,9 @@
<fileSet>
<outputDirectory>.</outputDirectory>
<directory>${project.build.directory}/${project.artifactId}-${project.version}</directory>
<excludes>
<exclude>docker-embedded/**</exclude>
rbuisson marked this conversation as resolved.
Show resolved Hide resolved
</excludes>
</fileSet>
</fileSets>
</assembly>
31 changes: 28 additions & 3 deletions distro/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<dependencyReportClassifier>dependencies</dependencyReportClassifier>
</properties>


rbuisson marked this conversation as resolved.
Show resolved Hide resolved
<modules>
<module>configs/superset</module>
</modules>
Expand All @@ -64,7 +65,6 @@
<type>zip</type>
<version>${referenceapplicationDistroVersion}</version>
</dependency>

<!-- Odoo addons-->
<dependency>
<groupId>net.mekomsolutions.odoo</groupId>
Expand Down Expand Up @@ -113,6 +113,19 @@
<type>zip</type>
</dependency>

<dependency>
<groupId>com.ozonehis</groupId>
<artifactId>ozone-docker-embedded</artifactId>
<type>zip</type>
<version>1.0.0-SNAPSHOT</version>
</dependency>
rbuisson marked this conversation as resolved.
Show resolved Hide resolved

<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-templates</artifactId>
<version>3.0.22</version>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -228,6 +241,18 @@
</configuration>
</execution>

<execution>
<id>Unpack Ozone Docker Embedded to a tempoarary location</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludeTransitive>true</excludeTransitive>
<outputDirectory>${project.build.directory}/docker-embedded</outputDirectory>
<includeArtifactIds>ozone-docker-embedded</includeArtifactIds>
</configuration>
</execution>
rbuisson marked this conversation as resolved.
Show resolved Hide resolved
<execution>
<id>Unpack OpenMRS Ref App frontend configuration</id>
<phase>generate-resources</phase>
Expand All @@ -249,14 +274,14 @@
</goals>
<configuration>
<excludeTransitive>true</excludeTransitive>
<outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/configs/superset</outputDirectory>
<outputDirectory>
${project.build.directory}/${project.artifactId}-${project.version}/configs/superset</outputDirectory>
<includeArtifactIds>ozone-superset-configs</includeArtifactIds>
</configuration>
</execution>

</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
Expand Down
193 changes: 190 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.ozonehis</groupId>
<artifactId>maven-commons</artifactId>
Expand Down Expand Up @@ -58,8 +60,172 @@
<type>zip</type>
<version>${ozoneDockerComposeVersion}</version>
</dependency>
<dependency>
<groupId>com.ozonehis</groupId>
<artifactId>ozone-docker-embedded</artifactId>
<type>zip</type>
<version>1.0.0-SNAPSHOT</version>
</dependency>
rbuisson marked this conversation as resolved.
Show resolved Hide resolved
</dependencies>

<profiles>
<profile>
<id>docker</id>
<properties>
<!-- Docker image properties-->
<docker.repo.name>ozone-embedded</docker.repo.name>
<docker.repo>mekomsolutions</docker.repo>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<executions>
<execution>
<id>Generate Docker Compose Embedded yaml</id>
<goals>
<goal>execute</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<scripts>
<script>
file://${project.basedir}/scripts/openmrs/docker-embedded/generate-docker-embedded-compose.groovy</script>
</scripts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
<name>mekomsolutions/ozone-embedded-openmrs-3-backend:${project.version}</name>
<build>
<dockerFile>
${project.build.directory}/${project.artifactId}-${project.version}/docker-embedded/docker/openmrs/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/${project.artifactId}-${project.version}/distro</contextDir>
</build>
</image>
<image>
<name>mekomsolutions/ozone-embedded-openmrs-3-frontend:${project.version}</name>
<build>
<dockerFile>
${project.build.directory}/${project.artifactId}-${project.version}/docker-embedded/docker/frontend/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/${project.artifactId}-${project.version}/</contextDir>
</build>
</image>
<image>
<name>mekomsolutions/ozone-embedded-odoo:${project.version}</name>
<build>
<dockerFile>
${project.build.directory}/${project.artifactId}-${project.version}/docker-embedded/docker/odoo/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/${project.artifactId}-${project.version}/distro</contextDir>
</build>
</image>
<image>
<name>mekomsolutions/ozone-embedded-senaite:${project.version}</name>
<build>
<dockerFile>
${project.build.directory}/${project.artifactId}-${project.version}/docker-embedded/docker/senaite/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/${project.artifactId}-${project.version}/distro</contextDir>
</build>
</image>
<image>
<name>mekomsolutions/ozone-embedded-erpnext:${project.version}</name>
<build>
<dockerFile>
${project.build.directory}/${project.artifactId}-${project.version}/docker-embedded/docker/erpnext/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/${project.artifactId}-${project.version}/distro</contextDir>
</build>
</image>
<image>
<name>mekomsolutions/ozone-embedded-eip-erpnext-openmrs:${project.version}</name>
<build>
<dockerFile>
${project.build.directory}/${project.artifactId}-${project.version}/docker-embedded/docker/eip-erpnext-openmrs/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/${project.artifactId}-${project.version}/distro</contextDir>
</build>
</image>
<image>
<name>mekomsolutions/ozone-embedded-eip-odoo-openmrs:${project.version}</name>
<build>
<dockerFile>
${project.build.directory}/${project.artifactId}-${project.version}/docker-embedded/docker/eip-odoo-openmrs/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/${project.artifactId}-${project.version}/distro</contextDir>
</build>
</image>
<image>
<name>mekomsolutions/ozone-embedded-eip-openmrs-senaite:${project.version}</name>
<build>
<dockerFile>
${project.build.directory}/${project.artifactId}-${project.version}/docker-embedded/docker/eip-openmrs-senaite/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/${project.artifactId}-${project.version}/distro</contextDir>
</build>
</image>
</images>
<buildx>
<platforms>
<platform>linux/amd64</platform>
<platform>linux/arm64</platform>
</platforms>
</buildx>
</configuration>
<executions>
<execution>
<id>Build embedded docker images</id>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<!-- Copy Docker Embedded compose file to run directory -->
<id>Copy Docker Embedded compose file</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/${project.artifactId}-${project.version}/run/docker</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>
${project.build.directory}/${project.artifactId}-${project.version}/docker-embedded/docker</directory>
rbuisson marked this conversation as resolved.
Show resolved Hide resolved
<filtering>true</filtering>
<includes>
<include>docker-compose-embedded.yaml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<plugins>

Expand Down Expand Up @@ -94,6 +260,21 @@
<includeArtifactIds>ozone-distro</includeArtifactIds>
</configuration>
</execution>

<execution>
<id>Copy Ozone Docker Embedded Files</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludeTransitive>true</excludeTransitive>
<outputDirectory>
${project.build.directory}/${project.artifactId}-${project.version}/docker-embedded</outputDirectory>
rbuisson marked this conversation as resolved.
Show resolved Hide resolved
<includeArtifactIds>ozone-docker-embedded</includeArtifactIds>
</configuration>
</execution>

</executions>
</plugin>

Expand Down Expand Up @@ -134,7 +315,7 @@
<resource>
<directory>${project.basedir}/scripts</directory>
<filtering>false</filtering>
</resource>
</resource>
<resource>
<directory>${project.basedir}/scripts</directory>
<includes>
Expand Down Expand Up @@ -211,4 +392,10 @@
</plugin>
</plugins>
</build>
</project>
<pluginRepositories>
<pluginRepository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</pluginRepository>
</pluginRepositories>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.nio.file.Paths
import java.io.File
import java.text.SimpleDateFormat
import groovy.text.*
import groovy.json.JsonBuilder

Date now = new Date()
SimpleDateFormat timestamp = new SimpleDateFormat("yyyyMMdd.HHmmss")
myver = "${project.version}"
log.info("Docker repository name is " + project.properties['docker.repo.name'])
log.info("Docker image tag is " + myver)
def dockerComposeTemplate = Paths.get("${project.build.directory}/${project.artifactId}-${project.version}","docker-embedded","docker", "docker-compose-embedded.yaml.template").toFile()

def binding = ['dockertag' : myver, 'dockerreponame' : project.properties['docker.repo.name'] ]

def engine = new SimpleTemplateEngine()
def template = engine.createTemplate(dockerComposeTemplate)
def writable = template.make(binding)

def dockerComposePath = Paths.get("${project.build.directory}/${project.artifactId}-${project.version}","docker-embedded","docker", "docker-compose-embedded.yaml").toAbsolutePath().toString()
def myFile = new File(dockerComposePath)
myFile.write(writable.toString())