Skip to content

Commit

Permalink
Feature/oidf 32 postgres docker (#7)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: John Melati <[email protected]>
Co-authored-by: sanderPostma <[email protected]>
  • Loading branch information
3 people authored Jul 9, 2024
1 parent 3c587cc commit 1639346
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .fleet/run.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"configurations": [
{
"name": "OpenID-Federation [:server:build]",
"name": "OpenID-Federation [:admin-server:build]",
"type": "gradle",
"workingDir": "$PROJECT_DIR$",
"tasks": [
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ captures
/platforms/
/platform-tools/
/.temp/
/docker/.env
/.run/*
23 changes: 23 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
7 changes: 7 additions & 0 deletions modules/admin-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ API

<br>

Add environment file (.env) with following properties
```
DATASOURCE_USER=<USER>
DATASOURCE_PASSWORD=<PASSWORD>
DATASOURCE_URL=<URL>
```

To build
<br>
```./gradlew :modules:admin-server:build```
Expand Down
2 changes: 2 additions & 0 deletions modules/admin-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1639346

Please sign in to comment.