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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'release' }}
needs: validate
uses: mekomsolutions/shared-github-workflow/.github/workflows/maven-publish.yml@main
with:
maven-args: "-Pdocker" # Build embedded docker images
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>
20 changes: 16 additions & 4 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 @@ -227,7 +240,6 @@
<includeArtifactIds>referenceapplication-distro</includeArtifactIds>
</configuration>
</execution>

<execution>
<id>Unpack OpenMRS Ref App frontend configuration</id>
<phase>generate-resources</phase>
Expand All @@ -249,14 +261,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
231 changes: 231 additions & 0 deletions maven-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,235 @@

</plugins>
</build>
<profiles>
<profile>
<id>docker</id>
rbuisson marked this conversation as resolved.
Show resolved Hide resolved
<properties>
<!-- Ozone Docker embedded version-->
<ozoneDockerEmbedded>1.0.0-SNAPSHOT</ozoneDockerEmbedded>
<!-- Docker image properties-->
<docker.tag>${project.groupId}-${project.artifactId}-${project.version}</docker.tag>
rbuisson marked this conversation as resolved.
Show resolved Hide resolved
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<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}/embedded-build-tmp/docker-embedded</outputDirectory>
<includeArtifactIds>ozone-docker-embedded</includeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
<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.build.directory}/scripts/openmrs/docker-embedded/generate-docker-embedded-compose.groovy</script>
</scripts>
</configuration>
</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}/embedded-build-tmp/docker-embedded</directory>
<filtering>true</filtering>
<includes>
<include>docker-compose-embedded.yaml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<!-- Copy Docker Embedded compose file to run directory -->
<id>Copy Ozone</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/embedded-build-tmp/distro</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>
${project.build.directory}/${project.artifactId}-${project.version}/distro</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
<name>ozone-embedded-openmrs-backend:${docker.tag}</name>
<build>
<dockerFile>
${project.build.directory}/embedded-build-tmp/docker-embedded/openmrs/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/embedded-build-tmp/distro</contextDir>
</build>
</image>
<image>
<name>ozone-embedded-openmrs-frontend:${project.version}</name>
<build>
<dockerFile>
${project.build.directory}/embedded-build-tmp/docker-embedded/frontend/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/embedded-build-tmp/</contextDir>
</build>
</image>
<image>
<name>ozone-embedded-proxy:${docker.tag}</name>
<build>
<dockerFile>
${project.build.directory}/embedded-build-tmp/docker-embedded/proxy/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/embedded-build-tmp/</contextDir>
</build>
</image>
<image>
<name>ozone-embedded-odoo:${docker.tag}</name>
<build>
<dockerFile>
${project.build.directory}/embedded-build-tmp/docker-embedded/odoo/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/embedded-build-tmp/distro</contextDir>
</build>
</image>
<image>
<name>ozone-embedded-senaite:${docker.tag}</name>
<build>
<dockerFile>
${project.build.directory}/embedded-build-tmp/docker-embedded/senaite/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/embedded-build-tmp/distro</contextDir>
</build>
</image>
<image>
<name>ozone-embedded-erpnext:${docker.tag}</name>
<build>
<dockerFile>
${project.build.directory}/embedded-build-tmp/docker-embedded/erpnext/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/embedded-build-tmp/distro</contextDir>
</build>
</image>
<image>
<name>ozone-embedded-eip-erpnext-openmrs:${docker.tag}</name>
<build>
<dockerFile>
${project.build.directory}/embedded-build-tmp/docker-embedded/eip-erpnext-openmrs/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/embedded-build-tmp/distro</contextDir>
</build>
</image>
<image>
<name>ozone-embedded-eip-odoo-openmrs:${docker.tag}</name>
<build>
<dockerFile>
${project.build.directory}/embedded-build-tmp/docker-embedded/eip-odoo-openmrs/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/embedded-build-tmp/distro</contextDir>
</build>
</image>
<image>
<name>ozone-embedded-eip-openmrs-senaite:${docker.tag}</name>
<build>
<dockerFile>
${project.build.directory}/embedded-build-tmp/docker-embedded/eip-openmrs-senaite/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/embedded-build-tmp/distro</contextDir>
</build>
</image>
<image>
<name>ozone-embedded-postgresql:${project.version}</name>
<build>
<dockerFile>
${project.build.directory}/embedded-build-tmp/docker-embedded/postgresql/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/embedded-build-tmp/distro</contextDir>
</build>
</image>
<image>
<name>ozone-embedded-mysql:${project.version}</name>
<build>
<dockerFile>
${project.build.directory}/embedded-build-tmp/docker-embedded/mysql/Dockerfile</dockerFile>
<contextDir>
${project.build.directory}/embedded-build-tmp/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>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.ozonehis</groupId>
<artifactId>ozone-docker-embedded</artifactId>
<type>zip</type>
<version>${ozoneDockerEmbedded}</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
15 changes: 11 additions & 4 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 @@ -59,7 +61,6 @@
<version>${ozoneDockerComposeVersion}</version>
</dependency>
</dependencies>

<build>
<plugins>

Expand Down Expand Up @@ -134,7 +135,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 +212,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,17 @@
import java.nio.file.Paths
import java.io.File
import java.text.SimpleDateFormat
import groovy.text.*
import groovy.json.JsonBuilder

myver = "${project.groupId}-${project.artifactId}-${project.version}"

def dockerComposeTemplate = Paths.get("${project.build.directory}", "/embedded-build-tmp", "docker-embedded", "docker-compose-embedded.yaml.template").toFile()
def binding = ['dockertag' : myver ]
def engine = new SimpleTemplateEngine()
def template = engine.createTemplate(dockerComposeTemplate)
def writable = template.make(binding)

def dockerComposePath = Paths.get("${project.build.directory}", "/embedded-build-tmp", "docker-embedded", "docker-compose-embedded.yaml").toAbsolutePath().toString()
def myFile = new File(dockerComposePath)
myFile.write(writable.toString())
3 changes: 3 additions & 0 deletions scripts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
<resource>
<directory>${project.basedir}/../scripts</directory>
<includes>
<include>
openmrs/docker-embedded/generate-docker-embedded-compose.groovy
</include>
<include>
openmrs/frontend_assembly/build-openmrs-frontend.groovy
</include>
Expand Down
Loading