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