Skip to content

Commit 743c355

Browse files
committed
adding postgres container config
0 parents  commit 743c355

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
environments/db.env

compose.podman.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: '1'
2+
3+
services:
4+
keycloak-db:
5+
image: postgres:15
6+
container_name: keycloak-db
7+
hostname: keycloak-db
8+
restart: unless-stopped
9+
env_file:
10+
- ./environments/db.env
11+
volumes:
12+
- './environments/db-init.sh:/docker-entrypoint-initdb.d/db-init.sh'
13+
- 'postgres-data:/var/lib/postgresql/data'
14+
15+
volumes:
16+
postgres-data:
17+
name: keycloak-postgres-data

environments/db-init.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -u
5+
6+
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" "$POSTGRES_DB" <<-EOSQL
7+
CREATE USER "$KEYCLOAK_DB_USER" WITH password '$KEYCLOAK_DB_PASS';
8+
CREATE DATABASE "$KEYCLOAK_DB_NAME";
9+
ALTER DATABASE "$KEYCLOAK_DB_NAME" OWNER TO "$KEYCLOAK_DB_USER"
10+
EOSQL

environments/db.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
POSTGRES_DB=postgres
2+
POSTGRES_USER=postgres
3+
POSTGRES_PASSWORD=postgres
4+
5+
KEYCLOAK_DB_NAME=keycloak
6+
KEYCLOAK_DB_USER=keycloak
7+
KEYCLOAK_DB_PASS=keycloak

0 commit comments

Comments
 (0)