|
| 1 | +# Urlaubsantraege Platform |
| 2 | + |
| 3 | +Lead-engineered packaging for the [urlaubsverwaltung](https://github.com/urlaubsverwaltung/urlaubsverwaltung) HR leave management application. This repository vendors the upstream source as a git submodule and adds everything required to build, ship, and operate the service with Docker, Docker Compose, and GitHub Actions. |
| 4 | + |
| 5 | +## Repository layout |
| 6 | + |
| 7 | +``` |
| 8 | +app/urlaubsverwaltung # upstream source (git submodule) |
| 9 | +compose/ # docker compose stacks |
| 10 | +config/ # baseline Spring Boot configuration overlays |
| 11 | +.github/workflows/ # CI/CD pipelines |
| 12 | +scripts/ # helper scripts for local validation |
| 13 | +Dockerfile # production-grade image build |
| 14 | +.dockerignore # docker build context filter |
| 15 | +.env.example # base environment configuration |
| 16 | +README.md # this file |
| 17 | +``` |
| 18 | + |
| 19 | +Run `git submodule update --init --recursive` after cloning to hydrate `app/urlaubsverwaltung`. |
| 20 | + |
| 21 | +## Upstream requirements snapshot |
| 22 | + |
| 23 | +| Concern | Value | |
| 24 | +| --- | --- | |
| 25 | +| JDK | 21 (Temurin) | |
| 26 | +| Build tool | Maven Wrapper (`./mvnw`) | |
| 27 | +| Database | PostgreSQL 15.x | |
| 28 | +| Mail | SMTP (sample: Mailpit) | |
| 29 | +| Profiles | `default` (production), `demodata` (demo/dev) | |
| 30 | +| Optional auth | OpenID Connect (Keycloak example included) | |
| 31 | + |
| 32 | +The upstream application exposes Spring Boot actuators at `/actuator/health`, `/actuator/health/readiness`, and `/actuator/health/liveness`. Our Docker image enables these endpoints for container health checks. |
| 33 | + |
| 34 | +## Configuration defaults |
| 35 | + |
| 36 | +Configuration lives under `config/` and is loaded by Spring when placed on the classpath (`--spring.config.additional-location=classpath:/config/`). Environment variables override every secret or deployment specific value. |
| 37 | + |
| 38 | +| Environment variable | Purpose | Default | |
| 39 | +| --- | --- | --- | |
| 40 | +| `SERVER_PORT` | HTTP listener | `8080` | |
| 41 | +| `SPRING_PROFILES_ACTIVE` | Active Spring profiles | `default` (production) | |
| 42 | +| `SPRING_DATASOURCE_URL` | JDBC URL | `jdbc:postgresql://postgres:5432/urlaubsverwaltung` | |
| 43 | +| `SPRING_DATASOURCE_USERNAME` | DB user | `urlaubsverwaltung` | |
| 44 | +| `SPRING_DATASOURCE_PASSWORD` | DB password | `urlaubsverwaltung` | |
| 45 | +| `SPRING_MAIL_HOST` | SMTP host | `mailpit` | |
| 46 | +| `SPRING_MAIL_PORT` | SMTP port | `1025` | |
| 47 | +| `SPRING_MAIL_USERNAME` | SMTP user | _empty_ | |
| 48 | +| `SPRING_MAIL_PASSWORD` | SMTP password | _empty_ | |
| 49 | +| `UV_MAIL_FROM` | Sender email | `[email protected]` | |
| 50 | +| `UV_MAIL_FROMDISPLAYNAME` | Sender display name | `Urlaubsverwaltung` | |
| 51 | +| `UV_MAIL_REPLYTO` | Reply-to email | `[email protected]` | |
| 52 | +| `UV_MAIL_REPLYTODISPLAYNAME` | Reply-to display name | `Urlaubsverwaltung` | |
| 53 | +| `UV_MAIL_APPLICATIONURL` | Public base URL | `http://localhost:8080` | |
| 54 | +| `UV_CALENDAR_ORGANIZER` | Calendar organiser | `[email protected]` | |
| 55 | +| `MANAGEMENT_HEALTH_MAIL_ENABLED` | Disable expensive mail health probe | `false` | |
| 56 | + |
| 57 | +Optional OpenID Connect variables (used in the OIDC compose stack): |
| 58 | + |
| 59 | +| Environment variable | Purpose | Default (OIDC stack) | |
| 60 | +| --- | --- | --- | |
| 61 | +| `SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_DEFAULT_CLIENT_ID` | OIDC client id | `urlaubsverwaltung` | |
| 62 | +| `SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_DEFAULT_CLIENT_SECRET` | OIDC client secret | `urlaubsverwaltung-secret` | |
| 63 | +| `SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_DEFAULT_CLIENT_NAME` | Display name | `urlaubsverwaltung` | |
| 64 | +| `SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_DEFAULT_SCOPE` | Requested scopes | `openid,profile,email,roles` | |
| 65 | +| `SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_DEFAULT_AUTHORIZATION_GRANT_TYPE` | Flow | `authorization_code` | |
| 66 | +| `SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_DEFAULT_REDIRECT_URI` | Redirect template | `http://localhost:8080/login/oauth2/code/{registrationId}` | |
| 67 | +| `SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_DEFAULT_ISSUER_URI` | Issuer URL | `http://keycloak:8080/realms/urlaubsverwaltung` | |
| 68 | +| `SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI` | Resource server issuer | `http://keycloak:8080/realms/urlaubsverwaltung` | |
| 69 | +| `UV_SECURITY_OIDC_CLAIM_MAPPERS_GROUP_CLAIM_ENABLED` | Enable group claim mapping | `true` | |
| 70 | +| `UV_SECURITY_OIDC_CLAIM_MAPPERS_GROUP_CLAIM_CLAIM_NAME` | Group claim name | `groups` | |
| 71 | + |
| 72 | +All secrets (DB password, OIDC secret, SMTP credentials) must be provided via env vars or external secret managers. They never live in git. |
| 73 | + |
| 74 | +## Building the Docker image |
| 75 | + |
| 76 | +Requirements: Docker 24+, git submodules initialised. |
| 77 | + |
| 78 | +``` |
| 79 | +docker build \ |
| 80 | + -t flex420/urlaubsverwaltung:local \ |
| 81 | + . |
| 82 | +``` |
| 83 | + |
| 84 | +Key characteristics: |
| 85 | + |
| 86 | +- Multi-stage build: Temurin 21 JDK for Maven build -> Temurin 21 JRE runtime. |
| 87 | +- Uses Maven wrapper with dependency download caching via buildkit. |
| 88 | +- Produces a non-root image (`uv` user, UID 1000) exposing port 8080. |
| 89 | +- Boots with sensible `JAVA_TOOL_OPTIONS` (container aware heap and GC tuning). |
| 90 | +- Declares an `HEALTHCHECK` hitting `/actuator/health/readiness`. |
| 91 | + |
| 92 | +## Docker Compose stacks |
| 93 | + |
| 94 | +We ship two Compose bundles under `compose/`. |
| 95 | + |
| 96 | +### `docker-compose.dev.yml` |
| 97 | + |
| 98 | +- Services: `app` (built locally), `postgres`, `mailpit`. |
| 99 | +- Activates `demodata` profile by default for seeded demo accounts. |
| 100 | +- Persists the database via the `urlaubsverwaltung-data` named volume. |
| 101 | +- Mailpit listens on `localhost:8025` (UI) and `localhost:1025` (SMTP). |
| 102 | + |
| 103 | +Usage: |
| 104 | + |
| 105 | +``` |
| 106 | +cp .env.example .env |
| 107 | +# edit credentials if needed |
| 108 | +docker compose -f compose/docker-compose.dev.yml up --build |
| 109 | +``` |
| 110 | + |
| 111 | +Visit http://localhost:8080 and sign in with the pre-seeded demo users described in the upstream README ( `[email protected]` / `secret`). |
| 112 | + |
| 113 | +### `docker-compose.oidc.yml` |
| 114 | + |
| 115 | +Extends the dev stack with Keycloak for OpenID Connect testing: |
| 116 | + |
| 117 | +- Adds `keycloak` with an imported realm and demo users. |
| 118 | +- Binds Keycloak to `localhost:8090` and wires the issuer into the app. |
| 119 | +- Documents how to obtain tokens via `scripts/keycloak-demo.sh`. |
| 120 | + |
| 121 | +Start it with: |
| 122 | + |
| 123 | +``` |
| 124 | +docker compose \ |
| 125 | + -f compose/docker-compose.dev.yml \ |
| 126 | + -f compose/docker-compose.oidc.yml \ |
| 127 | + up --build |
| 128 | +``` |
| 129 | + |
| 130 | +## Helper scripts |
| 131 | + |
| 132 | +`scripts/verify.sh` runs `docker build` and `docker compose config` validation locally. `scripts/keycloak-demo.sh` (requires curl and jq) demonstrates obtaining an OIDC token from the sample realm. |
| 133 | + |
| 134 | +## CI/CD pipeline |
| 135 | + |
| 136 | +`.github/workflows/ci.yml` performs: |
| 137 | + |
| 138 | +1. Checks out this repo and pulls the upstream submodule. |
| 139 | +2. Executes the upstream unit test suite via `./app/urlaubsverwaltung/mvnw -B -DskipITs test`. |
| 140 | +3. Runs `scripts/verify.sh` to lint the Docker context and Compose files. |
| 141 | +4. Builds the production image with caching and pushes tagged images to Docker Hub (`flex420/urlaubsverwaltung`) on `main` and version tags. |
| 142 | +5. Publishes a lightweight SBOM and attaches it as workflow artifact. |
| 143 | +GitHub secrets required (already provisioned): |
| 144 | + |
| 145 | +- `DOCKERHUB_USERNAME` |
| 146 | +- `DOCKERHUB_TOKEN` |
| 147 | + |
| 148 | +## Updating upstream |
| 149 | + |
| 150 | +To update the upstream application: |
| 151 | + |
| 152 | +``` |
| 153 | +git submodule update --remote app/urlaubsverwaltung |
| 154 | +# optionally pin to a release tag, then commit |
| 155 | +``` |
| 156 | + |
| 157 | +Re-run the CI pipeline to publish a refreshed image. |
0 commit comments