Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM eclipse-temurin:21-jdk AS build
WORKDIR /home/gradle/project

# 1. Copy Gradle wrapper and configuration files first.
# This includes the 'gradle' directory with the wrapper and libs.versions.toml
COPY gradlew .
COPY gradle gradle
COPY build.gradle settings.gradle ./

COPY regi-headless/build.gradle regi-headless/
COPY buildSrc buildSrc

RUN sed -i 's/\r$//' gradlew && chmod +x gradlew

# 2. Pre-download dependencies.
# This layer is cached until you change your version catalog or build scripts.
RUN ./gradlew :regi-headless:dependencies --no-daemon

# 3. Copy the actual source code and build the distribution
COPY . .
RUN sed -i 's/\r$//' gradlew && chmod +x gradlew
RUN ./gradlew :regi-headless:installDist --no-daemon

# Download the OpenTelemetry Java Agent
ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar /home/gradle/project/opentelemetry-javaagent.jar

FROM eclipse-temurin:21-jre-alpine
WORKDIR /app

# Copy the application and the OTel agent
COPY --from=build /home/gradle/project/regi-headless/build/install/regi-headless ./
COPY --from=build /home/gradle/project/opentelemetry-javaagent.jar ./

# AWS Batch/Lambda often prefer non-root, and it's better for OTel file permissions
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
RUN chown -R appuser:appgroup /app
USER appuser

RUN chmod +x /app/bin/regi-headless

ENTRYPOINT ["/app/bin/regi-headless"]
30 changes: 30 additions & 0 deletions Dockerfile-cwbi-copy.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM ghcr.io/usace/usace-wm-python:3.11

USER root

RUN apk update && apk add --no-cache git openjdk-23-jre \
&& mkdir -p /jobs \
&& chown appuser:appuser /jobs

# Set JAVA_HOME to the directory of Java 23
ENV JAVA_HOME=/usr/lib/jvm/java-23-openjdk

# Add Java to the PATH so it's available globally
# Add python bin for python command line tools like cwms-cli
ENV PATH="$JAVA_HOME/bin:/appuser/.local/bin:$PATH"

RUN mkdir -p /jobs && chown appuser:appuser /jobs

COPY --chown=appuser:appuser cwbi-docker/entrypoint.sh /entrypoint.sh
COPY --chown=appuser:appuser cwbi-docker/requirements.txt /requirements.txt

# Set the user to the non-root user
USER appuser

RUN chmod +x /entrypoint.sh && \
pip install --no-cache-dir -r /requirements.txt

ENTRYPOINT [ "/entrypoint.sh" ]

# CMD ["sleep", "infinity"]
CMD ["/jobs/bin/daily.sh"]
10 changes: 1 addition & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
plugins {
id "com.palantir.git-version" version "3.0.0"
id "org.sonarqube" version "4.0.0.2929"
}

def versionLabel(gitInfo) {
def branch = gitInfo.branchName // all branches are snapshots, only tags get released
def tag = gitInfo.lastTag
// tag is returned as is. Branch may need cleanup
return branch == null ? tag : "99." + branch.replace("/","-") + "-SNAPSHOT"
}

allprojects {
group = 'mil.army.wmist.regi-headless'
version = versionLabel(versionDetails())
version = project.findProperty('projectVersion') ?: "99.99.99+unversioned"
}

tasks.register('logTeamCityBuildStatus') {
Expand Down
16 changes: 0 additions & 16 deletions buildSrc/src/main/groovy/regi-headless.deps-conventions.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@

def checkForNexusCredentials() {
if(!project.hasProperty('nexusUser')) {
println ('Please set the nexusUser property in the GRADLE_USER_HOME ($userHome/.gradle/gradle.properties) file or via -PnexusUser= .')
}
if(!project.hasProperty('nexusPassword')) {
println ('Please set the nexusPassword property in the GRADLE_USER_HOME ($userHome/.gradle/gradle.properties) file or via -PnexusPassword= .')
}
}

repositories {
maven {
url 'https://www.hec.usace.army.mil/nexus/repository/maven-public'
}
maven {
url 'https://www.hec.usace.army.mil/nexus/repository/hec-internal'
credentials {
checkForNexusCredentials()
username "$nexusUser"
password "$nexusPassword"
}
}
mavenCentral()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ plugins {
}

compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
options.release = 21
}

dependencies {
Expand Down
57 changes: 57 additions & 0 deletions cwbi-docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

## Check if OFFICE is set
#if [ -z "$OFFICE" ]; then
# echo "OFFICE is not set"
# exit 1
#fi
#
## Lowercase the OFFICE variable
#OFFICE_LOWER="${OFFICE,,}"
#
## Check if GITHUB_TOKEN is set
#if [ -z "$GITHUB_TOKEN" ]; then
# echo "GITHUB_TOKEN is not set"
# exit 1
#fi
#
#if [ -z "$ENVIRONMENT" ]; then
# echo "ENVIRONMENT not set"
# exit 1
#fi
#
#GITHUB_BRANCH="cwbi-$ENVIRONMENT"
#
#echo "Using GITHUB_BRANCH: $GITHUB_BRANCH"
#
## Clone the office repo
#git clone --branch $GITHUB_BRANCH \
# https://$GITHUB_TOKEN@github.com/USACE-WaterManagement/$OFFICE_LOWER-wm-cwbi-jobs.git /jobs
#if [ $? -ne 0 ]; then
# echo "Failed to clone the repository for $OFFICE"
# exit 1
#fi
#
#unset GITHUB_TOKEN

# Set all shell scripts to executable
chmod +x /jobs/bin/*.sh


# Check if the requirements.txt file exists and install Python dependencies
REQUIREMENTS_FILE="/jobs/python/requirements.txt"

if [ -f "$REQUIREMENTS_FILE" ]; then
echo "Installing Python dependencies from $REQUIREMENTS_FILE..."
pip install -r "$REQUIREMENTS_FILE"
else
echo "No requirements.txt found at $REQUIREMENTS_FILE"
fi

if [ -d "/app/local_dist" ]; then
echo "Installing local wheels from /app/local_dist..."
pip install --force-reinstall /app/local_dist/*.whl
fi

# Run whatever CMD was passed in
exec "$@"
52 changes: 52 additions & 0 deletions cwbi-docker/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
cwms-python==1.0.1
hec-python-library==1.0
hecdss==0.1.29
cwms-cli==0.1.5
shef-parser==1.6.2
beautifulsoup4==4.13.5
bokeh==3.8.2
boto3==1.40.39
botocore==1.40.39
certifi==2025.8.3
charset-normalizer==3.4.3
click==8.3.0
colorama==0.4.6
contourpy==1.3.3
cycler==0.12.1
dataretrieval==1.0.12
flexcache==0.3
flexparser==0.4
fonttools==4.60.2
idna==3.10
Jinja2==3.1.6
jmespath==1.0.1
kiwisolver==1.4.9
MarkupSafe==3.0.2
matplotlib==3.10.6
narwhals==2.5.0
numpy==2.3.3
packaging==25.0
pandas==2.3.2
pillow==11.3.0
Pint==0.25
Pint-Pandas==0.7.1
platformdirs==4.4.0
plotly==6.3.0
pyparsing==3.2.5
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.2
requests==2.32.5
requests-toolbelt==1.0.0
s3transfer==0.14.0
scipy==1.16.2
seaborn==0.13.2
six==1.17.0
soupsieve==2.8
tornado==6.5.2
typing_extensions==4.15.0
tzdata==2025.2
tzlocal==5.3.1
urllib3==2.6.3
xarray==2025.9.0
xyzservices==2025.4.0
16 changes: 16 additions & 0 deletions datasources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: 1

datasources:
- name: Prometheus
type: prometheus
url: http://prometheus:9090
access: proxy
isDefault: true
- name: Jaeger
type: jaeger
url: http://jaeger:16686
access: proxy
- name: Loki
type: loki
url: http://loki:3100
access: proxy
66 changes: 66 additions & 0 deletions docker-compose-cwbi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: regi-headless-cwbi

services:
app:
build:
context: .
dockerfile: Dockerfile-cwbi-copy.dockerfile
command: ["python", "/jobs/GateFlowCalc2_Jpype.py"]
environment:
- OTEL_SERVICE_NAME=regi-headless
- OTEL_TRACES_EXPORTER=otlp
- OTEL_METRICS_EXPORTER=otlp
- OTEL_LOGS_EXPORTER=otlp
- OTEL_BSP_SCHEDULE_DELAY=1000
- OTEL_EXPORTER_OTLP_PROTOCOL=grpc
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
- OTEL_INSTRUMENTATION_OKHTTP_ENABLED=true
- OTEL_INSTRUMENTATION_METHODS_ENABLED=true
- CDA_URL=http://host.docker.internal:7001/swt-data
- API_KEY=apikey M5HECTEST
- OFFICE_ID=SWT
depends_on:
- otel-collector
volumes:
- ./regi-headless/build/install/regi-headless/dist:/app/local_dist
- ./regi-headless/src/test/resources/usace/rowcps/headless/examples/GateFlowCalc2_Jpype.py:/jobs/GateFlowCalc2_Jpype.py
- ./empty_dir:/jobs/bin
- ./empty_dir:/jobs/python

otel-collector:
image: otel/opentelemetry-collector-contrib:latest
command: ["--config=/etc/otel-collector-config.yaml"]
volumes:
- ./otel-config.yaml:/etc/otel-collector-config.yaml

jaeger:
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686"
- "4317:4317"

prometheus:
image: prom/prometheus
volumes:
- ./prometheus.yaml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"

loki:
image: grafana/loki:latest
ports:
- "3100:3100"

grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
volumes:
- ./datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
environment:
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
depends_on:
- prometheus
- jaeger
- loki
64 changes: 64 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: regi-headless-java

services:
app:
build: .
environment:
- OTEL_SERVICE_NAME=regi-headless
- OTEL_TRACES_EXPORTER=otlp
- OTEL_METRICS_EXPORTER=otlp
- OTEL_LOGS_EXPORTER=otlp
- OTEL_BSP_SCHEDULE_DELAY=1000
- OTEL_EXPORTER_OTLP_PROTOCOL=grpc
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
- OTEL_INSTRUMENTATION_OKHTTP_ENABLED=true
- OTEL_INSTRUMENTATION_METHODS_ENABLED=true
# - REGI_HEADLESS_OPTS=-javaagent:/app/opentelemetry-javaagent.jar
- JAVA_TOOL_OPTIONS=-javaagent:/app/opentelemetry-javaagent.jar
- CDA_URL=http://host.docker.internal:7001/swt-data
- API_KEY=apikey M5HECTEST
- OFFICE_ID=SWT
- SCRIPT=/scripts/GateFlowCalc2.py
depends_on:
- otel-collector
volumes:
- ./otel-config.yaml:/etc/otel-collector-config.yaml
- ./regi-headless/src/test/resources/usace/rowcps/headless/examples/GateFlowCalc2.py:/scripts/GateFlowCalc2.py

otel-collector:
image: otel/opentelemetry-collector-contrib:latest
command: ["--config=/etc/otel-collector-config.yaml"]
volumes:
- ./otel-config.yaml:/etc/otel-collector-config.yaml

jaeger:
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686"
- "4317:4317"

prometheus:
image: prom/prometheus
volumes:
- ./prometheus.yaml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"

loki:
image: grafana/loki:latest
ports:
- "3100:3100"

grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
volumes:
- ./grafana/datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
environment:
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
depends_on:
- prometheus
- jaeger
- loki
Loading