Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker-compose with Keycloak and test realm for integration tests #81

Merged
merged 5 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Config taken from https://stackoverflow.com/a/77257732
#
# This docker-compose is for development and test purposes. Tests are recorded with
# VCR against this instance.
#
# Log in to http://localhost:8080/admin/master/console/ with `admin`/`admin`
# credentials.
#
# DO NOT USE THIS IN PRODUCTION.
#

version: '3.8'

services:
keycloak:
image: quay.io/keycloak/keycloak:23.0.6
command: start-dev --import-realm
environment:
- KEYCLOAK_ADMIN=admin
- KEYCLOAK_ADMIN_PASSWORD=admin
volumes:
- ./docker/import:/opt/keycloak/data/import
ports:
- 8080:8080
33 changes: 33 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Keycloak Realm export and import

The `import/realm.json` is loaded when the Keycloak service is spun up through
docker-compose. In the top-level directory:

```bash
docker-compose up -d
```

You can now log in via `http://localhost:8080` with the `admin`/`admin` credentials.

## Exporting the Realm

In short - exporting through the admin UI (rightfully) obfuscates client secrets and
user credentials. However, for reproducible builds/environments, we want to include
this data in the Realm export.

Ensure the service is up and running through docker-compose.

Ensure that UID `1000` can write to `./docker/import/`:

```bash
chmod o+rwx ./docker/import/
```

Then open another terminal and run:

```bash
docker-compose exec keycloak ./bin/kc.sh \
export \
--file /opt/keycloak/data/import/test-realm.json \
--realm test
```
Loading
Loading