File tree Expand file tree Collapse file tree 5 files changed +161
-0
lines changed
Expand file tree Collapse file tree 5 files changed +161
-0
lines changed Original file line number Diff line number Diff line change 1+ # PostgreSQL
2+ POSTGRES_DB = keycloak
3+ POSTGRES_USER = keycloak
4+ POSTGRES_PASSWORD = keycloak_password
5+
6+ # Keycloak Admin
7+ KEYCLOAK_ADMIN = admin
8+ KEYCLOAK_ADMIN_PASSWORD = admin123
9+
10+ # Database
11+ KC_DB = postgres
12+ KC_DB_URL = jdbc:postgresql://postgres:5432/keycloak
13+ KC_DB_USERNAME = keycloak
14+ KC_DB_PASSWORD = keycloak_password
Original file line number Diff line number Diff line change 1+ name : Keycloak Docker CI
2+
3+ on :
4+ push :
5+ branches : ["main"]
6+ pull_request :
7+
8+ jobs :
9+ keycloak-test :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - uses : actions/checkout@v4
14+
15+ - name : Prepare env
16+ run : cp .env.example .env
17+
18+ - name : Start containers
19+ run : docker compose up -d
20+
21+ - name : Wait for Keycloak
22+ run : |
23+ for i in {1..15}; do
24+ curl -f http://localhost:8080 && exit 0
25+ sleep 5
26+ done
27+ exit 1
28+
29+ - name : Stop containers
30+ run : docker compose down
Original file line number Diff line number Diff line change 1+ # ## macOS ###
2+ # General
3+ .DS_Store
4+
5+ # Environment Variables
6+ .env
7+
8+ # Visual Studio Code
9+ .vscode /
Original file line number Diff line number Diff line change 1+ # Keycloak SSO Docker Environment
2+
3+ A complete Docker-based ** Keycloak SSO** environment using PostgreSQL as the database.
4+
5+ This repository is suitable for:
6+ - Single Sign-On (SSO)
7+ - OAuth2 / OpenID Connect authentication
8+ - Local development & testing
9+ - CI pipelines
10+
11+ ---
12+
13+ ## 🚀 Services
14+
15+ - ** Keycloak** (latest)
16+ - ** PostgreSQL** (persistent storage)
17+
18+ ---
19+
20+ ## 📦 Requirements
21+
22+ - Docker
23+ - Docker Compose v2
24+
25+ ---
26+
27+ ## ⚙️ Environment Setup
28+
29+ Copy environment example:
30+
31+ ``` bash
32+ cp .env.example .env
33+ ```
34+
35+ Edit values as needed.
36+
37+ ---
38+
39+ ## ▶️ Run Keycloak
40+
41+ ``` bash
42+ docker compose up -d
43+ ```
44+
45+ ---
46+
47+ ## 🌐 Access Keycloak
48+
49+ - Admin Console: http://localhost:8080
50+ - Username: ` admin `
51+ - Password: value from ` .env `
52+
53+ ---
54+
55+ ## 🔐 Realm Import
56+
57+ Place realm JSON files inside:
58+
59+ ```
60+ ./realm
61+ ```
62+
63+ They will be automatically imported on startup.
64+
65+ ---
66+
67+ ## 🧪 Stop Containers
68+
69+ ``` bash
70+ docker compose down
71+ ```
72+
73+ Remove volumes:
74+
75+ ``` bash
76+ docker compose down -v
77+ ```
Original file line number Diff line number Diff line change 1+ services :
2+ postgres :
3+ image : postgres:16
4+ container_name : keycloak_postgres
5+ restart : unless-stopped
6+ env_file :
7+ - .env
8+ volumes :
9+ - kc_postgres_data:/var/lib/postgresql/data
10+ healthcheck :
11+ test : ["CMD-SHELL", "pg_isready -U $POSTGRES_USER"]
12+ interval : 10s
13+ timeout : 5s
14+ retries : 5
15+
16+ keycloak :
17+ image : quay.io/keycloak/keycloak:latest
18+ container_name : keycloak
19+ command : start-dev --import-realm
20+ env_file :
21+ - .env
22+ ports :
23+ - " 8080:8080"
24+ depends_on :
25+ postgres :
26+ condition : service_healthy
27+ volumes :
28+ - ./realm:/opt/keycloak/data/import
29+
30+ volumes :
31+ kc_postgres_data :
You can’t perform that action at this time.
0 commit comments