Skip to content

Commit

Permalink
Merge pull request #117 from usdot-jpo-ode/jpo-utils-update
Browse files Browse the repository at this point in the history
Jpo utils update
  • Loading branch information
John-Wiens authored Nov 14, 2024
2 parents 8a2cfe2 + 1857f90 commit d092f9b
Show file tree
Hide file tree
Showing 8 changed files with 249 additions and 35 deletions.
62 changes: 37 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,54 @@ FROM maven:3.8-eclipse-temurin-21-alpine as jbuilder

WORKDIR /home

ARG MAVEN_GITHUB_TOKEN
ARG MAVEN_GITHUB_ORG

ENV MAVEN_GITHUB_TOKEN=$MAVEN_GITHUB_TOKEN
ENV MAVEN_GITHUB_ORG=$MAVEN_GITHUB_ORG

# Copy only the files needed to avoid putting all sorts of junk from your local env on to the image
COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/pom.xml ./jpo-ode/
COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-common/pom.xml ./jpo-ode/jpo-ode-common/
COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-common/src ./jpo-ode/jpo-ode-common/src
COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-plugins/pom.xml ./jpo-ode/jpo-ode-plugins/
COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-plugins/src ./jpo-ode/jpo-ode-plugins/src
COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-core/pom.xml ./jpo-ode/jpo-ode-core/
COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-core/src ./jpo-ode/jpo-ode-core/src/
COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-svcs/pom.xml ./jpo-ode/jpo-ode-svcs/
COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-svcs/src ./jpo-ode/jpo-ode-svcs/src

COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-geojsonconverter/pom.xml ./jpo-geojsonconverter/
COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-geojsonconverter/src ./jpo-geojsonconverter/src

COPY ./jpo-conflictmonitor/jpo-conflictmonitor/pom.xml ./jpo-conflictmonitor/
COPY ./jpo-conflictmonitor/jpo-conflictmonitor/src ./jpo-conflictmonitor/src
# COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/pom.xml ./jpo-ode/
# COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-common/pom.xml ./jpo-ode/jpo-ode-common/
# COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-common/src ./jpo-ode/jpo-ode-common/src
# COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-plugins/pom.xml ./jpo-ode/jpo-ode-plugins/
# COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-plugins/src ./jpo-ode/jpo-ode-plugins/src
# COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-core/pom.xml ./jpo-ode/jpo-ode-core/
# COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-core/src ./jpo-ode/jpo-ode-core/src/
# COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-svcs/pom.xml ./jpo-ode/jpo-ode-svcs/
# COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-ode/jpo-ode-svcs/src ./jpo-ode/jpo-ode-svcs/src

# COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-geojsonconverter/pom.xml ./jpo-geojsonconverter/
# COPY ./jpo-conflictmonitor/jpo-geojsonconverter/jpo-geojsonconverter/src ./jpo-geojsonconverter/src

# COPY ./jpo-conflictmonitor/jpo-conflictmonitor/pom.xml ./jpo-conflictmonitor/
# COPY ./jpo-conflictmonitor/jpo-conflictmonitor/src ./jpo-conflictmonitor/src

COPY ./jpo-conflictvisualizer-api/pom.xml ./jpo-conflictvisualizer-api/
COPY ./jpo-conflictvisualizer-api/src ./jpo-conflictvisualizer-api/src
COPY ./jpo-conflictvisualizer-api/settings.xml ./jpo-conflictvisualizer-api/

WORKDIR /home/jpo-conflictvisualizer-api
RUN mvn -s settings.xml dependency:resolve

WORKDIR /home/jpo-ode
COPY ./jpo-conflictvisualizer-api/src ./src
RUN mvn -s settings.xml install -DskipTests

RUN mvn install -DskipTests
# WORKDIR /home/jpo-ode

WORKDIR /home/jpo-geojsonconverter
# RUN mvn install -DskipTests

RUN mvn clean install -DskipTests
# WORKDIR /home/jpo-geojsonconverter

WORKDIR /home/jpo-conflictmonitor
# RUN mvn clean install -DskipTests

RUN mvn clean install -DskipTests
# WORKDIR /home/jpo-conflictmonitor

WORKDIR /home/jpo-conflictvisualizer-api
# RUN mvn clean install -DskipTests

# WORKDIR /home/jpo-conflictvisualizer-api

RUN mvn clean package -DskipTests
ENTRYPOINT ["tail", "-f", "/dev/null"]
# RUN mvn clean package -DskipTests
# ENTRYPOINT ["tail", "-f", "/dev/null"]


# # === RUNTIME IMAGE for Java and ACM ===
Expand Down
1 change: 0 additions & 1 deletion jpo-conflictmonitor
Submodule jpo-conflictmonitor deleted from eb1912
73 changes: 67 additions & 6 deletions jpo-conflictvisualizer-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<sonar.language>java</sonar.language>
<!-- <thymeleaf.version>3.0.3.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.2.1</thymeleaf-layout-dialect.version> -->
<!-- Allow override of github organization when publishing artifacts to github -->
<github_organization>usdot-jpo-ode</github_organization>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -107,27 +109,42 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>usdot.jpo.ode</groupId>
<artifactId>jpo-ode-core</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>usdot.jpo.ode</groupId>
<artifactId>jpo-ode-plugins</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>usdot.jpo.ode</groupId>
<artifactId>jpo-ode-svcs</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>usdot.jpo.ode</groupId>
<artifactId>jpo-geojsonconverter</artifactId>
<version>1.4.2-SNAPSHOT</version>
<classifier>jpo-geojsonconverter</classifier>
<version>1.4.2</version>
<!-- Allow using newer streams version than geojsonconverter -->
<exclusions>
<exclusion>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams-test-utils</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>usdot.jpo.ode</groupId>
<artifactId>jpo-conflictmonitor</artifactId>
<version>1.4.1-SNAPSHOT</version>
<classifier>jpo-conflictmonitor</classifier>
<version>1.4.1</version>
<!-- <classifier>jpo-conflictmonitor</classifier> -->
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down Expand Up @@ -290,5 +307,49 @@
</plugin>
</plugins>
</build>
<!-- profile to output only source code and not include any spring boot dependencies in
published jar -->
<profiles>
<profile>
<id>package-jar</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>
us.dot.its.jpo.ode.api.ConflictApiApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>repackage</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<!-- GitHub Artifact publishing configuration -->
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/${github_organization}/jpo-conflictmonitor</url>
</repository>
</distributionManagement>

</project>
54 changes: 54 additions & 0 deletions jpo-conflictvisualizer-api/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<activeProfiles>
<activeProfile>default</activeProfile>
</activeProfiles>
<servers>
<server>
<id>github_jpo_ode</id>
<username>jpo_conflictmonitor</username>
<password>${env.MAVEN_GITHUB_TOKEN}</password>
</server>
<server>
<id>github_jpo_geojsonconverter</id>
<username>jpo_conflictmonitor</username>
<password>${env.MAVEN_GITHUB_TOKEN}</password>
</server>
<server>
<id>github_jpo_conflictmonitor</id>
<username>jpo_conflictmonitor</username>
<password>${env.MAVEN_GITHUB_TOKEN}</password>
</server>
</servers>
<profiles>
<profile>
<id>default</id>
<repositories>
<repository>
<id>github_jpo_ode</id>
<name>GitHub JPO ODE</name>
<url>https://maven.pkg.github.com/${env.MAVEN_GITHUB_ORG}/jpo-ode</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>github_jpo_geojsonconverter</id>
<name>GitHub JPO GeojsonConverter</name>
<url>https://maven.pkg.github.com/${env.MAVEN_GITHUB_ORG}/jpo-geojsonconverter</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>github_jpo_conflictmonitor</id>
<name>GitHub JPO ConflictMonitor</name>
<url>https://maven.pkg.github.com/${env.MAVEN_GITHUB_ORG}/jpo-conflictmonitor</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,29 @@ public class MongoConfig extends AbstractMongoClientConfiguration{
@Value("${spring.data.mongodb.password}")
private String password;

@Value("${spring.data.mongodb.authenticationDatabase}")
private String authenticationDatabase;

@Value("${spring.data.mongodb.uri}")
private String overrideURI;

@Override
protected String getDatabaseName() {
return db;
}

@Override
public void configureClientSettings(MongoClientSettings.Builder builder) {
// customization hook
String uri = "mongodb://"+username+":"+password+"@"+host+":"+port+"/"+db;

String uri = "";

if(overrideURI != null && !overrideURI.isEmpty() && !overrideURI.equals("null")){
uri = overrideURI;
}else{
uri = "mongodb://"+username+":"+password+"@"+host+":"+port+"/"+db + "?authSource="+authenticationDatabase;
}


// String uri = "mongodb://"+host+":"+port+"/"+db;
System.out.println("Connecting to MongoDB at: " + uri);
builder.applyConnectionString(new ConnectionString(uri));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ public ResponseEntity<List<UserCreationRequest>> findUserCreationRequests(

logger.info("Requesting New User Creation");
Response response = keycloak.realm(realm).users().create(user);
logger.info(response.getStatus() + " " + response.getHeaders());

if (response.getStatus() == 201) {
logger.info("User Creation Successful");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ spring.data.mongodb.host=${DB_HOST_IP:localhost}
spring.data.mongodb.port=27017
spring.data.mongodb.username=${CM_MONGO_API_USERNAME:api}
spring.data.mongodb.password=${CM_MONGO_API_PASSWORD:api}
spring.data.mongodb.authenticationDatabase=${CM_MONGO_AUTH_DB:CV}
spring.data.mongodb.uri=${CM_MONGO_URI:null}


cmServerURL = ${CM_SERVER_URL:http://localhost:8082}
mongoTimeoutMs = ${CM_MONGO_TIMEOUT_MS:5000}
Expand Down
72 changes: 72 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
@@ -1 +1,73 @@
# Set the HOST IP of where the containers are running
DOCKER_HOST_IP=

# Set to the directory where the source code is. Generally the location of this file.
DOCKER_HOST_DIR=

KAFKA_BOOTSTRAP_SERVERS=${DOCKER_HOST_IP}:9092

# GitHub properties for pulling the latest version of the JPO-ODE
MAVEN_GITHUB_TOKEN=
MAVEN_GITHUB_ORG=usdot-jpo-ode

# Docker compose restart policy: https://docs.docker.com/engine/containers/start-containers-automatically/
RESTART_POLICY="on-failure:3"

# Available profiles:
# - all
# - cm_api_full
# - conflictmonitor
# - geojsonconverter
# - cm_gui
# - cm_api
# - keycloak
# - mongo
# - ode
# - adm
# - cm_api_base
# - cm_gui
# - cm_api
# - keycloak
# - cm_api
# - cm_gui
# - keycloak
# - geojsonconverter
# - ode
# - adm
# - conflictmonitor
# - mongo
# EXAMPLE: COMPOSE_PROFILES=kafka_connect_standalone,kafka_ui,mongo_express
# Refer to jpo-utils/.env for more profiles
COMPOSE_PROFILES=cm_api_full



# Put anything you want for the NEXTAUTH_SECRET, and KEYCLOAK_CLIENT_SECRET
NEXTAUTH_SECRET=
NEXTAUTH_URL=http://${DOCKER_HOST_IP}:3000
KEYCLOAK_CLIENT_ID=conflictvisualizer-gui
KEYCLOAK_CLIENT_SECRET=
KEYCLOAK_REALM=conflictvisualizer
MAPBOX_TOKEN=

KEYCLOAK_ADMIN=
KEYCLOAK_ADMIN_PASSWORD=

# May be different from docker host ip for production deployments. Change as appropriate.
GUI_SERVER_URL=http://${DOCKER_HOST_IP}:3000
AUTH_SERVER_URL=http://${DOCKER_HOST_IP}:8084
API_SERVER_URL=http://${DOCKER_HOST_IP}:8081
CM_SERVER_URL=http://${DOCKER_HOST_IP}:8082
API_WS_URL=ws://${DOCKER_HOST_IP}:8081


#Specify MongoDB connection parameters
DB_HOST_IP=${DOCKER_HOST_IP}
DB_HOST_PORT=27017
CM_MONGO_READ_WRITE_USERNAME=api
CM_MONGO_READ_WRITE_USERNAME=api
CM_MONGO_AUTH_DB=CV

Alternate Mongo Connection Strategy - This will override the MONGO behavior specified above
#CM_MONGO_URI=

0 comments on commit d092f9b

Please sign in to comment.