From 4c80b523e1ccbc9a2bc84d1de8e3c91ff8d21fb6 Mon Sep 17 00:00:00 2001 From: sanderPostma Date: Wed, 3 Jul 2024 14:03:00 +0200 Subject: [PATCH 1/3] chore: extract ktor version --- modules/openid-federation-common/build.gradle.kts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/openid-federation-common/build.gradle.kts b/modules/openid-federation-common/build.gradle.kts index 2bc918dd..62762b20 100644 --- a/modules/openid-federation-common/build.gradle.kts +++ b/modules/openid-federation-common/build.gradle.kts @@ -9,6 +9,8 @@ plugins { kotlin("plugin.serialization") version "2.0.0" } +val ktorVersion = "2.3.11" + kotlin { @OptIn(ExperimentalWasmDsl::class) @@ -47,7 +49,7 @@ kotlin { sourceSets { val commonMain by getting { dependencies { - implementation("io.ktor:ktor-client-core:2.3.11") + implementation("io.ktor:ktor-client-core:$ktorVersion") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0") implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.0") } @@ -60,7 +62,7 @@ kotlin { } val jvmMain by getting { dependencies { - implementation("io.ktor:ktor-client-cio:2.3.11") + implementation("io.ktor:ktor-client-core-jvm:$ktorVersion") } } val jvmTest by getting { @@ -71,7 +73,7 @@ kotlin { val androidMain by getting { dependencies { - implementation("io.ktor:ktor-client-okhttp:2.3.11") + implementation("io.ktor:ktor-client-core-jvm:$ktorVersion") } } val androidUnitTest by getting { @@ -83,7 +85,7 @@ kotlin { val iosMain by creating { dependsOn(commonMain) dependencies { - implementation("io.ktor:ktor-client-ios:2.3.11") + implementation("io.ktor:ktor-client-ios:$ktorVersion") } } val iosX64Main by getting { @@ -105,7 +107,7 @@ kotlin { val jsMain by getting { dependencies { - implementation("io.ktor:ktor-client-js:2.3.11") + implementation("io.ktor:ktor-client-js:$ktorVersion") } } From 8d322d70f9102ce29bf5cc9b79c86b47fa9e1943 Mon Sep 17 00:00:00 2001 From: sanderPostma Date: Mon, 8 Jul 2024 13:57:13 +0200 Subject: [PATCH 2/3] chore: fix project name --- settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 1e991276..5bece6b0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,4 +1,4 @@ -rootProject.name = "kotlin-mp-genesis" +rootProject.name = "openid-federation" enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") pluginManagement { From 1639346fb5ba13e3e42fc57f4bf7a214d3ae85ad Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Tue, 9 Jul 2024 23:49:43 +0530 Subject: [PATCH 3/3] Feature/oidf 32 postgres docker (#7) * Added Spring boot with status API * chores: PR feedback * Updated the server name in gradle module * Added test for status endpoint and added README * Enabled test run on gradle build * Added Postgres and docker * Added environment file * Updated env variable * Fixed merge conflicts * Updated CI for GitHub secrets * Added docker in GitHub action * Added env variable for docker in GitHub action * Removed Windows in GitHub action * Added comment for removing Windows in CI * Removed hardcoded path from run script * fix: make admin server load env variables from root .env file (#10) * chore: fix project name * chore: extract ktor version * fix: temporarily hardcode db credentials * fix: import .env variables from file * fix: adjust ci file to new docker compose dir --------- Co-authored-by: sanderPostma --------- Co-authored-by: John Melati Co-authored-by: sanderPostma --- .env | 4 ++++ .fleet/run.json | 2 +- .github/workflows/ci.yml | 15 +++++++++++- .gitignore | 2 ++ docker-compose.yaml | 23 +++++++++++++++++++ gradle/libs.versions.toml | 2 ++ modules/admin-server/README.md | 7 ++++++ modules/admin-server/build.gradle.kts | 2 ++ .../src/main/resources/application.properties | 9 +++++++- 9 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 .env create mode 100644 docker-compose.yaml diff --git a/.env b/.env new file mode 100644 index 00000000..34ab61a8 --- /dev/null +++ b/.env @@ -0,0 +1,4 @@ +DATASOURCE_URL=jdbc:postgresql://localhost:5432/openid-federation-db +DATASOURCE_USER=openid-federation-db-user +DATASOURCE_PASSWORD=openid-federation-db-password +DATASOURCE_DB=openid-federation-db \ No newline at end of file diff --git a/.fleet/run.json b/.fleet/run.json index f360fcd9..a523f1a3 100644 --- a/.fleet/run.json +++ b/.fleet/run.json @@ -1,7 +1,7 @@ { "configurations": [ { - "name": "OpenID-Federation [:server:build]", + "name": "OpenID-Federation [:admin-server:build]", "type": "gradle", "workingDir": "$PROJECT_DIR$", "tasks": [ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9acc12e1..73b95060 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,9 @@ jobs: gradle: strategy: matrix: - os: [ ubuntu-latest, windows-latest ] + # Removed windows, because build failing with docker network. "bridge" network driver is not supported for Windows containers + # os: [ ubuntu-latest, windows-latest ] + os: [ ubuntu-latest ] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -16,6 +18,13 @@ jobs: distribution: adopt-hotspot java-version: 17 + - name: Build the stack + run: docker-compose -f docker-compose.yaml up -d + env: + DATASOURCE_USER: ${{ secrets.DATASOURCE_USER }} + DATASOURCE_PASSWORD: ${{ secrets.DATASOURCE_PASSWORD }} + DATASOURCE_URL: ${{ secrets.DATASOURCE_URL }} + - name: Setup Gradle uses: gradle/gradle-build-action@v3 @@ -25,3 +34,7 @@ jobs: - name: Execute Gradle build run: ./gradlew build + env: + DATASOURCE_USER: ${{ secrets.DATASOURCE_USER }} + DATASOURCE_PASSWORD: ${{ secrets.DATASOURCE_PASSWORD }} + DATASOURCE_URL: ${{ secrets.DATASOURCE_URL }} diff --git a/.gitignore b/.gitignore index f0e9e76a..161fec79 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ captures /platforms/ /platform-tools/ /.temp/ +/docker/.env +/.run/* diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..af8db708 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,23 @@ +version: '3.9' + +services: + db: + image: postgres:latest + container_name: openid-federation-datastore + environment: + POSTGRES_USER: ${DATASOURCE_USER} + POSTGRES_PASSWORD: ${DATASOURCE_PASSWORD} + POSTGRES_DB: openid-federation-db + ports: + - "5432:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + networks: + - openid_network + +networks: + openid_network: + driver: bridge + +volumes: + postgres_data: \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8f2751ea..7a25a76a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -33,8 +33,10 @@ kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serializa kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect" } springboot-actuator = { group = "org.springframework.boot", name = "spring-boot-starter-actuator" } springboot-web = { group = "org.springframework.boot", name = "spring-boot-starter-web" } +springboot-data-jdbc = { group = "org.springframework.boot", name = "spring-boot-starter-data-jdbc" } springboot-devtools = { group = "org.springframework.boot", name = "spring-boot-devtools" } springboot-test = { group = "org.springframework.boot", name = "spring-boot-starter-test" } +postgres = { module = "org.postgresql:postgresql" } [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" } diff --git a/modules/admin-server/README.md b/modules/admin-server/README.md index 5081c690..aecd1dbb 100644 --- a/modules/admin-server/README.md +++ b/modules/admin-server/README.md @@ -6,6 +6,13 @@ API
+Add environment file (.env) with following properties +``` +DATASOURCE_USER= +DATASOURCE_PASSWORD= +DATASOURCE_URL= +``` + To build
```./gradlew :modules:admin-server:build``` diff --git a/modules/admin-server/build.gradle.kts b/modules/admin-server/build.gradle.kts index d7e90794..b1def3cc 100644 --- a/modules/admin-server/build.gradle.kts +++ b/modules/admin-server/build.gradle.kts @@ -18,8 +18,10 @@ java { dependencies { implementation(libs.springboot.actuator) implementation(libs.springboot.web) + implementation(libs.springboot.data.jdbc) implementation(libs.kotlin.reflect) testImplementation(libs.springboot.test) + runtimeOnly(libs.postgres) runtimeOnly(libs.springboot.devtools) } diff --git a/modules/admin-server/src/main/resources/application.properties b/modules/admin-server/src/main/resources/application.properties index 79c568ef..683495f2 100644 --- a/modules/admin-server/src/main/resources/application.properties +++ b/modules/admin-server/src/main/resources/application.properties @@ -1,5 +1,12 @@ +spring.config.import=optional:file:../../.env[.properties] + spring.application.name=OpenID Federation +spring.datasource.url=${DATASOURCE_URL} +spring.datasource.username=${DATASOURCE_USER} +spring.datasource.password=${DATASOURCE_PASSWORD} +spring.datasource.driver-class-name=org.postgresql.Driver + # Mapping /actuator/health to /status management.endpoints.web.base-path=/ -management.endpoints.web.path-mapping.health=status +management.endpoints.web.path-mapping.health=status \ No newline at end of file