Skip to content

Commit

Permalink
Update Spring Boot to v3, Java to v17, and do more cleanup (#122)
Browse files Browse the repository at this point in the history
* Update Java from 11 to 17
* Update Spring Boot from 2.5.6 to 3.1.4
* Update Gradle from 7.4.2 to 8.4
* Update Docker image build to use Jib instead of a Dockerfile
* Rename service/docker folder to service/local-docker for clarity of usage
* Update minor and patch versions for a few other dependencies to accommodate the major version changes
* Remove CHANGELOG.md as it has never been used and is currently superseded by release-drafter
* Remove CONTRIBUTING.md as it was copied from another Provenance repository and is too inaccurate to warrant keeping
* Address some minor build warnings
rpatel-figure authored Oct 12, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 0f4466f commit fd0217b
Showing 49 changed files with 235 additions and 334 deletions.
13 changes: 8 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -18,8 +18,11 @@ Before we can merge this PR, please make sure that all the following items have
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

- [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/provenance-io/p8e-cee-api/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [ ] Wrote unit and integration
- [ ] Re-reviewed `Files changed` in the Github PR explorer
- [ ] Review `Unit Test Results` in the comment section below once CI passes
- [ ] Targeted PR against correct branch
- [ ] Tagged PR with **exactly one of** `patch`, `minor`, or `major`, adhering to [semantic versioning](https://semver.org/)
- [ ] Tagged PR with one or more of `feature`, `enhancement`, `fix`/`bugfix`, `chore`, `dependencies`, & `docs`, as applicable to the scope of the PR
- [ ] Acknowledge that by merging my changes to `main`, they are ready to be included in the next release, and otherwise would ask for a prerelease to be created against my branch
- [ ] Linked to GitHub issue with discussion and accepted design OR link to spec that describes this work
- [ ] Wrote unit and integration tests as applicable to the scope of the PR
- [ ] Re-reviewed `Files changed` in the GitHub PR explorer
- [ ] Reviewed `Test Results` in the comment section below once CI passes
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -25,15 +25,13 @@ jobs:
if: inputs.linting || github.event.pull_request.draft == false
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
uses: actions/checkout@v4

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
distribution: 'zulu'
java-version: '17'

- name: Linting
run: ./gradlew clean ktlint detekt --parallel --refresh-dependencies
@@ -43,13 +41,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
java-version: '17'
distribution: 'zulu'

# TODO: Figure out how to simplify integration test run below

- name: Add Homebrew to PATH
run: echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
36 changes: 9 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -28,11 +28,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
java-version: 17
distribution: 'zulu'

- name: Add Homebrew to PATH
run: echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
@@ -50,37 +50,19 @@ jobs:
- name: Set Image Details
id: ci-release-create-outputs
run: |
DOCKER_IMAGE=provenanceio/p8e-cee-api
VERSION=$( echo ${{ github.event.release.tag_name }} | sed -e 's/^v//' )
if [ "$VERSION" == "" ] ; then
VERSION=$( echo ${{ github.event.inputs.versionTag }} | sed -e 's/^v//' )
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [ ${{ github.event.inputs.tagAsLatest }} == 'true' ] ; then
TAGS="${TAGS},${DOCKER_IMAGE}:latest"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v3
with:
file: service/docker/Dockerfile
context: .
push: true
tags: ${{ steps.ci-release-create-outputs.outputs.tags }}
env:
JIB_AUTH_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
JIB_AUTH_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKER_IMAGE_NAME: provenanceio/p8e-cee-api:${{ steps.ci-release-create-outputs.outputs.version }}
TAG_DOCKER_IMAGE_AS_LATEST: ${{ github.event.inputs.tagAsLatest }}
run: ./gradlew :service:jib -Djib.console=plain -Pversion=${VERSION}

- name: Install gpg secret key
if: inputs.publishToMaven || github.event_name == 'release'
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -48,12 +48,12 @@ out/
/.datastore

# Vault
service/docker/volumes/
service/docker/vault/init.output
service/docker/vault/keys.output
service/local-docker/volumes/
service/local-docker/vault/init.output
service/local-docker/vault/keys.output
service/src/test/resources/volumes/

# Object store files
service/docker/object-store-1/
service/docker/object-store-2/
service/local-docker/object-store-1/
service/local-docker/object-store-2/

2 changes: 1 addition & 1 deletion .sdkmanrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java=11.0.20-tem
java=17.0.8-zulu
Empty file removed CHANGELOG.md
Empty file.
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at community@interchain.io. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at inbound@provenance.io. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

157 changes: 0 additions & 157 deletions CONTRIBUTING.md

This file was deleted.

18 changes: 8 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
kotlin("jvm") version "1.8.10"
kotlin("jvm") version "1.8.22"
id("java")
id("maven-publish")
id("java-library")
@@ -24,20 +23,19 @@ subprojects {

allprojects {
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf(
"-Xjsr305=strict",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xskip-prerelease-check", // To support loan package contracts dependency using context receivers
)
jvmTarget = "11"
apiVersion = "1.6"
languageVersion = "1.6"
jvmTarget = "17"
apiVersion = "1.8"
languageVersion = "1.8"
allWarningsAsErrors = true
}
}
@@ -56,8 +54,8 @@ nexusPublishing {
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

allprojects {
5 changes: 5 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -11,6 +11,11 @@ plugins {
`kotlin-dsl`
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

// For everything else
repositories {
mavenCentral()
25 changes: 13 additions & 12 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[versions]
kotlin = "1.8.10"
kotlin = "1.8.22"
kotlin_coroutines = "1.6.4"
assetClassification = "3.7.0"
bouncyCastle = "1.70"
detekt = "1.18.1"
grpc = "1.51.3"
hamkrest = "1.8.0.1"
jackson_databind = "2.12.6.1"
jackson_jsr310 = "2.12.+"
jackson_kotlinModule = "2.12.5"
jackson_protobuf = "0.9.9-jackson2.9-proto3"
jackson = "2.15.2"
jackson_protobuf = "0.9.14"
jakarta_servlet = "5.0.0"
jib = "3.4.0"
kong_unirest = "3.13.6"
kotest = "5.5.5"
kotest_extensions_arrow = "1.2.+"
@@ -29,11 +29,11 @@ provenance_client = "1.3.0"
provenance_hdWallet = "0.1.15"
provenance_kmsConnector = "0.3.6"
provenance_proto = "1.13.1"
reactor = "3.4.9"
reactor = "3.5.10"
redisson = "3.16.0"
reflections = "0.9.10"
spring_boot = "2.5.6"
spring_dependencyManagement = "1.0.11.RELEASE"
spring_boot = "3.1.4"
spring_dependencyManagement = "1.1.3"
spring_mockk = "3.0.1"
springdoc = "1.5.13"
springfox = "3.0.0"
@@ -44,6 +44,7 @@ testContainers = "1.3.3"
kotlin = { id = "kotlin", version.ref = "kotlin" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
idea = { id = "idea" }
jib = { id = "com.google.cloud.tools.jib", version.ref = "jib" }
nexus_publishing = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexus_publishing" }
protobuf = { id = "com.google.protobuf", version.ref = "protobuf_plugin" }
spring_boot = { id = "org.springframework.boot", version.ref = "spring_boot" }
@@ -87,10 +88,9 @@ assetClassification_client = { module = "tech.figure.classification.asset:ac-cli
assetClassification_verifier = { module = "tech.figure.classification.asset:ac-verifier", version.ref = "assetClassification" }
objectStore_gateway = { module = "tech.figure.objectstore.gateway:client", version.ref = "objectStore_gateway" }
# Jackson
## TODO: Clean up Jackson versions
jackson_databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson_databind" }
jackson_datatype = { module = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310", version.ref = "jackson_jsr310" }
jackson_kotlinModule = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson_kotlinModule" }
jackson_databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" }
jackson_datatype = { module = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310", version.ref = "jackson" }
jackson_kotlinModule = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" }
jackson_protobuf = { module = "com.hubspot.jackson:jackson-datatype-protobuf", version.ref = "jackson_protobuf" }
# Google
grpc_protobuf = { module = "io.grpc:grpc-protobuf", version.ref = "grpc" }
@@ -100,6 +100,7 @@ protobuf_java_util = { module = "com.google.protobuf:protobuf-java-util", versio
# Other
bouncyCastle = { module = "org.bouncycastle:bcpkix-jdk15on", version.ref = "bouncyCastle" }
bouncyCastle_provider = { module = "org.bouncycastle:bcprov-jdk15on", version.ref = "bouncyCastle" }
jakarta_servlet = { module = "jakarta.servlet:jakarta.servlet-api", version.ref = "jakarta_servlet" }
kong_unirest = { module = "com.konghq:unirest-java", version.ref = "kong_unirest" }
kotlin_logging = { module = "io.github.microutils:kotlin-logging-jvm", version.ref = "kotlin_logging" }
ktlint = { module = "com.pinterest:ktlint", version.ref = "ktlint" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
41 changes: 28 additions & 13 deletions gradlew
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,11 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -193,18 +198,28 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
15 changes: 9 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
3 changes: 1 addition & 2 deletions models/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
val ktlint: Configuration by configurations.creating

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.detekt)
`java-library`
`maven-publish`
}

java.sourceCompatibility = JavaVersion.VERSION_11
java.sourceCompatibility = JavaVersion.VERSION_17

dependencies {
ktlint(libs.ktlint)
118 changes: 89 additions & 29 deletions service/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
val ktlint: Configuration by configurations.creating

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.detekt)
alias(libs.plugins.jib)
alias(libs.plugins.spring.boot)
alias(libs.plugins.spring.dependencyManagement)
kotlin("plugin.spring") version "1.8.10"
kotlin("plugin.spring") version "1.8.22"
}

java.sourceCompatibility = JavaVersion.VERSION_11
java.sourceCompatibility = JavaVersion.VERSION_17

dependencyManagement {
applyMavenExclusions(false)
@@ -30,40 +30,41 @@ dependencies {
libs.kotlin.coroutines.reactor,
libs.springBoot.starter,
libs.springBoot.starter.actuator,
libs.springBoot.starter.jetty,
libs.springBoot.starter.devTools,
libs.springBoot.starter.jetty,
libs.springBoot.starter.security,
libs.springBoot.starter.validation,
libs.reactor.core, // Needed to play nice with WebFlux Coroutines stuff
libs.assetClassification.client,
libs.assetClassification.verifier,
libs.bouncyCastle,
libs.bouncyCastle.provider,
libs.grpc.protobuf,
libs.grpc.stub,
libs.jackson.databind,
libs.jackson.datatype,
libs.jackson.kotlinModule,
libs.jackson.protobuf,
libs.jakarta.servlet,
libs.kong.unirest,
libs.kotlin.logging,
libs.springfox.swagger,
libs.springfox.swagger.ui,
libs.swagger.annotations,
libs.objectStore.gateway,
libs.p8eScope.encryption,
libs.p8eScope.objectStore.client,
libs.p8eScope.sdk,
libs.provenance.keyAccessLib,
libs.protobuf.java.util,
libs.provenance.client,
libs.provenance.hdWallet,
libs.provenance.hdWallet.bip39,
libs.provenance.client,
libs.provenance.protoKotlin,
libs.provenance.keyAccessLib,
libs.provenance.loanPackage,
libs.jackson.databind,
libs.jackson.datatype,
libs.jackson.protobuf,
libs.jackson.kotlinModule,
libs.protobuf.java.util,
libs.kong.unirest,
libs.grpc.protobuf,
libs.grpc.stub,
libs.provenance.protoKotlin,
libs.reactor.core, // Needed to play nice with WebFlux Coroutines stuff
libs.reflections,
libs.bouncyCastle,
libs.bouncyCastle.provider,
libs.springdoc.openApi.webFluxSupport,
libs.springdoc.openApi.kotlinSupport,
libs.assetClassification.client,
libs.assetClassification.verifier,
libs.objectStore.gateway,
libs.springdoc.openApi.webFluxSupport,
libs.springfox.swagger,
libs.springfox.swagger.ui,
libs.swagger.annotations,
).forEach { dependency ->
implementation(dependency)
}
@@ -82,15 +83,15 @@ dependencies {

listOf(
libs.hamkrest,
libs.mockk,
libs.kotlin.faker,
libs.kotlin.coroutines.test,
libs.spring.mockk,
libs.kotest,
libs.kotest.assertions,
libs.kotest.assertions.arrow,
libs.kotest.property,
libs.kotest.spring,
libs.kotlin.coroutines.test,
libs.kotlin.faker,
libs.mockk,
libs.spring.mockk,
libs.testContainers.core,
).forEach { testDependency ->
testImplementation(testDependency)
@@ -143,3 +144,62 @@ detekt {
config = files("${rootDir.path}/detekt.yml")
source = files("src/main/kotlin", "src/test/kotlin")
}

val latestTag: String? = "latest".takeIf {
System.getenv("TAG_DOCKER_IMAGE_AS_LATEST") == "true" ||
System.getenv("GITHUB_REF_NAME")
?.takeIf { it.isNotBlank() }
?.let { githubRefName -> setOf("main").any { githubRefName.endsWith(it) } }
?: false
}

tasks.named("jib") {
dependsOn(tasks.named("bootJar"))
}

tasks.named("jibDockerBuild") {
dependsOn(tasks.named("bootJar"))
}

val jarFileName = "service.jar"
val mainClassName = "io.provenance.api.ApplicationKt"

jib {
from {
auth {
username = System.getenv("JIB_AUTH_USERNAME") ?: "_json_key"
password = System.getenv("JIB_AUTH_PASSWORD") ?: "nopass"
}
image = "azul/zulu-openjdk:17.0.8.1"
}
to {
auth {
username = System.getenv("JIB_AUTH_USERNAME") ?: "_json_key"
password = System.getenv("JIB_AUTH_PASSWORD") ?: "nopass"
}
// The base tag should be specified with `image`, and additional tags with `tags, to control setting of `latest`
image = System.getenv("DOCKER_IMAGE_NAME") ?: "provenanceio/${rootProject.name}:${rootProject.version}"
tags = setOfNotNull(latestTag)
}
extraDirectories {
paths {
path {
setFrom(file("src/main/jib/"))
into = "/"
includes.set(listOf("service-configure"))
}
path {
setFrom(file("build/libs"))
into = "/"
includes.set(listOf(jarFileName))
}
}
permissions = mapOf("/service-configure" to "755", jarFileName to "755")
}
container {
mainClass = mainClassName
ports = listOf("8080")
entrypoint = listOf("/bin/bash", "-c", "--", "/service-configure /$jarFileName")
creationTime = "USE_CURRENT_TIMESTAMP"
}
}
31 changes: 0 additions & 31 deletions service/docker/Dockerfile

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e

if [ -d "/vault/secrets" ]; then
@@ -9,12 +9,13 @@ fi

# Create the trust store and key store for java
if [ "$KAFKA_SECURITY_PROTOCOL" != "" ]; then
echo -n ${KAFKA_TRUSTSTORE} | base64 -d > ${KAFKA_TRUSTSTORE_PATH}
echo -n ${KAFKA_KEYSTORE} | base64 -d > ${KAFKA_KEYSTORE_PATH}
echo -n "${KAFKA_TRUSTSTORE}" | base64 -d > "${KAFKA_TRUSTSTORE_PATH}"
echo -n "${KAFKA_KEYSTORE}" | base64 -d > "${KAFKA_KEYSTORE_PATH}"
fi

if [ "$JMX_ENABLED" = true ]; then
JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/dumps/dump.bin -Dcom.sun.management.jmxremote.port=7199 -Dcom.sun.management.jmxremote.rmi.port=7199 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=$POD_IP -Dcom.sun.management.jmxremote.local.only=false"
fi

java $JAVA_OPTS -jar $1
# shellcheck disable=SC2086
exec java $JAVA_OPTS -jar $1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.provenance.api.frameworks.config

import io.provenance.api.domain.usecase.common.originator.DefaultAudience
import javax.validation.constraints.NotNull
import jakarta.validation.constraints.NotNull
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.validation.annotation.Validated

Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package io.provenance.api.frameworks.config

import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.ConstructorBinding
import org.springframework.validation.annotation.Validated

@ConstructorBinding
@ConfigurationProperties(prefix = "service")
@Validated
data class ServiceProps(
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.provenance.api.frameworks.config

import jakarta.validation.constraints.NotNull
import org.springframework.boot.context.properties.ConfigurationProperties
import javax.validation.constraints.NotNull

@ConfigurationProperties(prefix = "vault")
class VaultProperties : LoggableProperties() {
Original file line number Diff line number Diff line change
@@ -16,20 +16,37 @@ import org.springframework.security.web.server.SecurityWebFilterChain
@EnableConfigurationProperties(value = [ServiceProps::class])
class SecurityConfig {
@Bean
fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
http.authorizeExchange {
it.pathMatchers("${Routes.MANAGE_BASE}/**", "${Routes.EXTERNAL_BASE}/**", "${Routes.INTERNAL_BASE}/**", "${Routes.DOCS_BASE}/**").permitAll()
fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain = http.apply {
authorizeExchange { spec ->
spec.pathMatchers(
"${Routes.MANAGE_BASE}/**",
"${Routes.EXTERNAL_BASE}/**",
"${Routes.INTERNAL_BASE}/**",
"${Routes.DOCS_BASE}/**"
).permitAll()
}

return http.httpBasic().disable()
.formLogin().disable()
.logout().disable()
.csrf().disable()
.headers().frameOptions().disable()
.cache().disable()
.and()
.authorizeExchange()
.pathMatchers("/").permitAll()
.and().build()
}
httpBasic { spec ->
spec.disable()
}
formLogin { spec ->
spec.disable()
}
logout { spec ->
spec.disable()
}
csrf { spec ->
spec.disable()
}
headers { spec ->
spec.frameOptions { frameOptionsSpec ->
frameOptionsSpec.disable()
}
spec.cache { cacheSpec ->
cacheSpec.disable()
}
}
http.authorizeExchange { authorize ->
authorize.pathMatchers("/").permitAll()
}
}.build()
}
Original file line number Diff line number Diff line change
@@ -3,6 +3,11 @@ package io.provenance.api.util
import org.springframework.core.io.buffer.DataBufferUtils
import org.springframework.http.codec.multipart.FilePart
import reactor.core.publisher.Mono
import java.nio.ByteBuffer

fun FilePart.awaitAllBytes(): Mono<ByteArray> =
DataBufferUtils.join(this.content()).map { it.asByteBuffer().array() }
DataBufferUtils.join(this.content()).map { dataBuffer ->
ByteBuffer.allocate(dataBuffer.capacity()).also { byteBuffer ->
dataBuffer.toByteBuffer(byteBuffer)
}.array()
}

0 comments on commit fd0217b

Please sign in to comment.