Skip to content

Commit

Permalink
Merge pull request #160 from jembi/dev-jmpi-771-dockerize-bootstrappe…
Browse files Browse the repository at this point in the history
…r-app

Dockerizing the bootstrapper app
  • Loading branch information
ajinkyagadewar authored Jan 15, 2024
2 parents cf165ad + 435bb35 commit 003b6a4
Show file tree
Hide file tree
Showing 49 changed files with 457 additions and 122 deletions.
5 changes: 4 additions & 1 deletion JeMPI_Apps/JeMPI_Bootstrapper/boostrap.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ POSTGRESQL_IP=127.0.0.1
POSTGRESQL_PORT=5432
POSTGRESQL_USER=postgres
POSTGRESQL_PASSWORD=
POSTGRESQL_PASSWORD=jempi
POSTGRESQL_USERS_DB=
POSTGRESQL_NOTIFICATIONS_DB=
POSTGRESQL_AUDIT_DB=
POSTGRESQL_KC_TEST_DB=
KAFKA_BOOTSTRAP_SERVERS=127.0.0.1
KAFKA_APPLICATION_ID=aId
DGRAPH_HOSTS=127.0.0.1
Expand Down
13 changes: 13 additions & 0 deletions JeMPI_Apps/JeMPI_Bootstrapper/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e
set -u

source $PROJECT_DEVOPS_DIR/conf/images/conf-app-images.sh
source ../build-check-jdk.sh

JAR_FILE=${BOOTSTRAPPER_JAR}
APP_IMAGE=${BOOTSTRAPPER_IMAGE}
APP=bootstrapper

source ../build-app-image.sh
34 changes: 34 additions & 0 deletions JeMPI_Apps/JeMPI_Bootstrapper/checkstyle/suppression.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<suppressions>

<suppress
checks="(JavadocMethod|JavadocVariable|JavadocStyle|JavadocPackage|JavadocType)"
files="().java"
/>

<suppress
checks="(LineLength|AvoidStarImport|MagicNumber)"
files="().java"
/>

<suppress
checks="(VisibilityModifier|HiddenField)"
files="().java"
/>

<suppress
checks="(DesignForExtension)"
files="().java"
/>

<suppress
checks="(MemberName)"
files="BootstrapperConfig.java"
/>

</suppressions>
3 changes: 3 additions & 0 deletions JeMPI_Apps/JeMPI_Bootstrapper/docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.gitignore
!Dockerfile
14 changes: 14 additions & 0 deletions JeMPI_Apps/JeMPI_Bootstrapper/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG JAVA_VERSION

FROM eclipse-temurin:${JAVA_VERSION}-jre

ADD Bootstrapper-1.0-SNAPSHOT-spring-boot.jar /app/Bootstrapper-1.0-SNAPSHOT-spring-boot.jar

RUN printf "#!/bin/bash\n\
cd /app\n\
java_args=\"\${@:1}\" \n\
java --enable-preview -XX:MaxRAMPercentage=80 -XX:+UseZGC -jar /app/Bootstrapper-1.0-SNAPSHOT-spring-boot.jar \$java_args \n" > /bootstrapper.sh

RUN chmod +x /bootstrapper.sh

ENTRYPOINT tail -f /dev/null
39 changes: 37 additions & 2 deletions JeMPI_Apps/JeMPI_Bootstrapper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>JeMPI_Bootstrapper</artifactId>
<artifactId>Bootstrapper</artifactId>
<packaging>jar</packaging>


Expand Down Expand Up @@ -124,7 +124,42 @@
</dependencies>

<build>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<?m2e execute onConfiguration,onIncremental?>
<id>validate</id>
<phase>compile</phase>
<configuration>
<suppressionsLocation>checkstyle/suppression.xml</suppressionsLocation>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${version.org.springframework.boot.spring-boot-maven-plugin}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>spring-boot</classifier>
<mainClass>${start-class}</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
Expand Down
14 changes: 14 additions & 0 deletions JeMPI_Apps/JeMPI_Bootstrapper/push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e
set -u

source $PROJECT_DEVOPS_DIR/conf.env
source $PROJECT_DEVOPS_DIR/conf/images/conf-app-images.sh

APP_IMAGE=$BOOTSTRAPPER_IMAGE

docker tag ${APP_IMAGE} ${REGISTRY_NODE_IP}/${APP_IMAGE}
docker push ${REGISTRY_NODE_IP}/${APP_IMAGE}
docker rmi ${REGISTRY_NODE_IP}/${APP_IMAGE}

Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import picocli.CommandLine;
import picocli.CommandLine.Command;

@Command(mixinStandardHelpOptions = true, subcommands = {CLI.class,})
@Command(mixinStandardHelpOptions = true, subcommands = {CLI.class})

public class BootstrapperCLI implements Runnable {

@CommandLine.Option(names = {"-c", "--config"}, description = "Config file")
private String config;

public static void main(String... args) {
public static void main(final String... args) {
int exitCode = new CommandLine(new BootstrapperCLI()).execute(args);
System.exit(exitCode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,32 @@

public class BootstrapperConfig {

public final String POSTGRESQL_IP;
public final String POSTGRESQL_IP;
public final Integer POSTGRESQL_PORT;
public final String POSTGRESQL_USER;
public final String POSTGRESQL_PASSWORD;
public final String POSTGRESQL_DATABASE;
public final String POSTGRESQL_USERS_DB;
public final String POSTGRESQL_NOTIFICATIONS_DB;
public final String POSTGRESQL_AUDIT_DB;
public final String POSTGRESQL_KC_TEST_DB;
public final String KAFKA_BOOTSTRAP_SERVERS;
public final String KAFKA_APPLICATION_ID;
public final String[] DGRAPH_ALPHA_HOSTS;
public final int[] DGRAPH_ALPHA_PORTS;

public BootstrapperConfig(Config parsedConfig) {
public BootstrapperConfig(final Config parsedConfig) {
POSTGRESQL_IP = parsedConfig.getString("POSTGRESQL_IP");
POSTGRESQL_PORT = parsedConfig.getInt("POSTGRESQL_PORT");
POSTGRESQL_USER = parsedConfig.getString("POSTGRESQL_USER");
POSTGRESQL_PASSWORD = parsedConfig.getString("POSTGRESQL_PASSWORD");

POSTGRESQL_DATABASE = parsedConfig.getString("POSTGRESQL_DATABASE");
POSTGRESQL_USERS_DB = parsedConfig.getString("POSTGRESQL_USERS_DB");
POSTGRESQL_NOTIFICATIONS_DB = parsedConfig.getString("POSTGRESQL_NOTIFICATIONS_DB");
POSTGRESQL_AUDIT_DB = parsedConfig.getString("POSTGRESQL_AUDIT_DB");
POSTGRESQL_KC_TEST_DB = parsedConfig.getString("POSTGRESQL_KC_TEST_DB");

KAFKA_BOOTSTRAP_SERVERS = parsedConfig.getString("KAFKA_BOOTSTRAP_SERVERS");
KAFKA_APPLICATION_ID = parsedConfig.getString("KAFKA_APPLICATION_ID");
DGRAPH_ALPHA_HOSTS = parsedConfig.getString("DGRAPH_HOSTS").split(",");
Expand All @@ -38,9 +48,9 @@ public BootstrapperConfig(Config parsedConfig) {
}

public static BootstrapperConfig create(
String filepath,
Logger LOGGER) {
return new BootstrapperConfig(new Builder(LOGGER).withOptionalFile(filepath)
final String filepath,
final Logger logger) {
return new BootstrapperConfig(new Builder(logger).withOptionalFile(filepath)
.withSystemEnvironment()
.withSystemProperties()
.build());
Expand All @@ -53,7 +63,7 @@ private static class Builder {
private final Logger logger;
private Config conf = ConfigFactory.empty();

public Builder(Logger logger) {
Builder(final Logger logger) {
this.logger = logger;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public BaseDataBootstrapperCommand<T> init() throws Exception {
return this;
}

protected Integer execute(Callable<Integer> bootstrapperFunc) {
protected Integer execute(final Callable<Integer> bootstrapperFunc) {
try {
Integer bootstrapperResult = bootstrapperFunc.call();
if (bootstrapperResult != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ public BaseCLICommand init() throws Exception {
}

@Override
protected DataBootstrapper getBootstrapper(String configPath) {
protected DataBootstrapper getBootstrapper(final String configPath) {
return null;
}

protected Integer callMultiple(BaseDataBootstrapperCommand<DataBootstrapper>[] bootstrapperCommands) throws Exception {
protected Integer callMultiple(final BaseDataBootstrapperCommand<DataBootstrapper>[] bootstrapperCommands) throws Exception {
Integer execResult = 0;
for (BaseDataBootstrapperCommand<DataBootstrapper> b : bootstrapperCommands) {
execResult += b.setConfigPath(this.config).init().call();
}
return execResult;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import picocli.CommandLine.Command;

@Command(name = "data", mixinStandardHelpOptions = true, subcommands = {KafkaCLI.class, DgraphCLI.class, PostgresCLI.class,
ResetAllCommand.class, DeleteAllSchemaDataCommand.class
, CreateAllSchemaDataCommand.class})
ResetAllCommand.class, DeleteAllSchemaDataCommand.class, CreateAllSchemaDataCommand.class})
public class CLI {
@CommandLine.Option(names = {"-c", "--config"}, description = "Config file")
private String config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import java.util.concurrent.Callable;

@CommandLine.Command(name = "createAllSchemaData", mixinStandardHelpOptions = true, description = "Create all the required " +
"schema's and data for JeMPI.")
@CommandLine.Command(name = "createAllSchemaData", mixinStandardHelpOptions = true, description = "Create all the required "
+ "schema's and data for JeMPI.")
public class CreateAllSchemaDataCommand extends BaseCLICommand implements Callable<Integer> {
@Override
public Integer call() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import java.util.concurrent.Callable;

@CommandLine.Command(name = "deleteAllSchemaData", mixinStandardHelpOptions = true, description = "Delete all the data and " +
"schema used by JeMPI.")
@CommandLine.Command(name = "deleteAllSchemaData", mixinStandardHelpOptions = true, description = "Delete all the data and "
+ "schema used by JeMPI.")
public class DeleteAllSchemaDataCommand extends BaseCLICommand implements Callable<Integer> {
@Override
public Integer call() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

import java.util.concurrent.Callable;

@CommandLine.Command(name = "resetAll", mixinStandardHelpOptions = true, description = "Deletes all data and schemas associated" +
" with JeMPI, then recreates schemas, " +
"and add initial data.")
@CommandLine.Command(name = "resetAll", mixinStandardHelpOptions = true, description = "Deletes all data and schemas associated"
+ " with JeMPI, then recreates schemas, and add initial data.")
public class ResetAllCommand extends BaseCLICommand implements Callable<Integer> {
@Override
public Integer call() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public abstract class BaseDgraphCommand extends BaseDataBootstrapperCommand<DgraphDataBootstrapper> implements Callable<Integer> {
@Override
protected DgraphDataBootstrapper getBootstrapper(String configPath) {
protected DgraphDataBootstrapper getBootstrapper(final String configPath) {
return new DgraphDataBootstrapper(configPath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

import java.util.concurrent.Callable;

@CommandLine.Command(name = "createAllSchemaData", mixinStandardHelpOptions = true, description = "Create all the required " +
"schema's and data for JeMPI " +
"Dgraph instance.")
@CommandLine.Command(name = "createAllSchemaData", mixinStandardHelpOptions = true, description = "Create all the required "
+ "schema's and data for JeMPI Dgraph instance.")
public class DgraphCreateAllSchemaDataCommand extends BaseDgraphCommand implements Callable<Integer> {
@Override
public Integer call() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

import java.util.concurrent.Callable;

@CommandLine.Command(name = "deleteAll", mixinStandardHelpOptions = true, description = "Delete all the data and schema used by" +
" JeMPI Dgraph instance.")
@CommandLine.Command(name = "deleteAll", mixinStandardHelpOptions = true, description = "Delete all the data and schema used by JeMPI Dgraph instance.")
public class DgraphDeleteAllCommand extends BaseDgraphCommand implements Callable<Integer> {
@Override
public Integer call() throws Exception {
Expand All @@ -14,4 +13,4 @@ public Integer call() throws Exception {
? 0
: 1);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

import java.util.concurrent.Callable;

@CommandLine.Command(name = "resetAll", mixinStandardHelpOptions = true, description = "Deletes all data and schemas associated" +
" with JeMPI Dgraph instance, then " +
"recreates schemas, and add initial data.")
@CommandLine.Command(name = "resetAll", mixinStandardHelpOptions = true, description = "Deletes all data and schemas associated"
+ " with JeMPI Dgraph instance, then recreates schemas, and add initial data.")
public class DgraphResetAllCommand extends BaseDgraphCommand implements Callable<Integer> {
@Override
public Integer call() throws Exception {
Expand Down
Loading

0 comments on commit 003b6a4

Please sign in to comment.