Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
207 lines (193 loc) · 6.79 KB
/
Copy pathdocker-compose.yml
File metadata and controls
207 lines (193 loc) · 6.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
services:
postgres:
# see: https://hub.docker.com/_/postgres/tags
image: postgres:16
container_name: postgres_container
# ports:
# - ${POSTGRES_PORT}:5432
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- ./postgres/data:/var/lib/postgresql/data
- ./postgres/config/docker-entrypoint-initdb.d/010_init_postgrest.sql:/docker-entrypoint-initdb.d/010_init_postgrest.sql
restart: unless-stopped
configs:
- source: 005_init_users.sql
target: /docker-entrypoint-initdb.d/005_init_users.sql
pgadmin:
# see: https://hub.docker.com/r/dpage/pgadmin4/tags
# https://www.pgadmin.org/docs/pgadmin4/latest/container_deployment.html
container_name: pgadmin_container
image: dpage/pgadmin4:8.6
# ports:
# - ${PGADMIN_PORT}:80
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
PGADMIN_DISABLE_POSTFIX: true
PGADMIN_CONFIG_CONSOLE_LOG_LEVEL: 10
logging:
driver: "none"
volumes:
- ./pgadmin/data:/var/lib/pgadmin
restart: unless-stopped
depends_on:
- postgres
# https://stackoverflow.com/questions/64620446/adding-postgress-connections-to-pgadmin-in-docker-file
user: root
entrypoint: /bin/sh -c "chmod 600 /pgpass; /entrypoint.sh;"
configs:
- source: servers.json
target: /pgadmin4/servers.json
- source: pgpass
target: /pgpass
postgrest:
#see: https://hub.docker.com/r/postgrest/postgrest/tags
image: postgrest/postgrest:v12.0.2
container_name: postgrest_container
# ports:
# - ${PGRST_PORT}:3000
environment:
PGRST_DB_URI: postgres://authenticator:${PGRST_PASSWORD}@postgres:${POSTGRES_PORT}/${POSTGRES_DB}
PGRST_OPENAPI_SERVER_PROXY_URI: ${PGRST_OPENAPI_SERVER_PROXY_URI}
PGRST_DB_SCHEMAS: api
PGRST_DB_ANON_ROLE: api_anon
PGRST_OPENAPI_SECURITY_ACTIVE: true
PGRST_JWT_SECRET: ${PGRST_JWT_SECRET}
PGRST_ROLE_CLAIM_KEY: ${PGRST_ROLE_CLAIM_KEY}
# PGRST_DB_PRE_REQUEST: ${PGRST_DB_PRE_REQUEST}
restart: unless-stopped
depends_on:
- postgres
swaggerui:
# see: https://hub.docker.com/r/swaggerapi/swagger-ui/tags
image: swaggerapi/swagger-ui:v5.17.3
container_name: swaggercontainer
# ports:
# - ${SWAGGERUI_PORT}:8080
environment:
API_URL: ${PGRST_OPENAPI_SERVER_PROXY_URI}
# VALIDATOR_URL: "localhost" # optional
PERSIST_AUTHORIZATION: ${SWAGGERUI_PERSIST_AUTHORIZATION} # default: false
configs:
- source: swagger-initializer.js
target: /usr/share/nginx/html/swagger-initializer.js
restart: unless-stopped
depends_on:
- postgrest
keycloak-db:
image: postgres
profiles:
- keycloak
volumes:
- ./keycloak/data/db:/var/lib/postgresql/data
environment:
- POSTGRES_DB=keycloak
- POSTGRES_USER=keycloak
- POSTGRES_PASSWORD=${KEYCLOAK_DB_PASSWORD}
keycloak:
image: quay.io/keycloak/keycloak
profiles:
- keycloak
command:
- start
environment:
#see https://www.keycloak.org/server/all-config
#DB params are optional. If not set, internal h2 DB is used
- KC_DB=postgres
- KC_DB_URL_HOST=keycloak-db
- KC_DB_URL_PORT=5432
- KC_DB_URL_DATABASE=keycloak
- KC_DB_USERNAME=keycloak
- KC_DB_SCHEMA=public
- KC_DB_PASSWORD=${KEYCLOAK_DB_PASSWORD}
- KEYCLOAK_ADMIN=${KEYCLOAK_ADMIN:-admin}
- KEYCLOAK_ADMIN_PASSWORD=${KEYCLOAK_ADMIN_PASSWORD}
- KC_HOSTNAME_URL=${KEYCLOAK_SERVER}
- KC_HTTP_ENABLED=true
# see https://github.com/keycloak/keycloak/issues/14586
- KC_HOSTNAME_STRICT=false
- KC_PROXY=edge
- PROXY_ADDRESS_FORWARDING=true
#- KC_HTTP_RELATIVE_PATH: /auth
#ports:
# - 8080:8080
depends_on:
- keycloak-db
# see: https://docs.docker.com/compose/compose-file/08-configs/
configs:
005_init_users.sql:
content: |
CREATE ROLE authenticator WITH NOINHERIT LOGIN PASSWORD '${PGRST_PASSWORD}';
pgpass:
content: postgres:5432:*:${POSTGRES_USER}:${POSTGRES_PASSWORD}
servers.json:
content: |
{"Servers": {"1": {
"Group": "Servers",
"Name": "Postgres",
"Host": "postgres",
"Port": 5432,
"MaintenanceDB": "postgres",
"Username": "postgres",
"PassFile": "/pgpass",
"SSLMode": "prefer"
}}}
swagger-initializer.js:
content: |
window.onload = function () {
var current_token = null;
function get_token() {
// warning! this thing is the path to the authorization value, it will change depending on your auth method
return window.ui.auth().getIn(['authorized', 'JWT', 'value']);
}
function reload_if_token_changed() {
setTimeout(function () {
var new_token = get_token()
if (new_token != current_token) {
current_token = new_token;
window.ui.getSystem().specActions.download();
}
});
}
document.addEventListener('click', function (evt) {
// the match is your buttons
if (evt.target && evt.target.matches('.auth.authorize.button')) {
reload_if_token_changed();
}
});
console.log("SWAGGERUI_PERSIST_AUTHORIZATION" + "${SWAGGERUI_PERSIST_AUTHORIZATION}");
//<editor-fold desc="Changeable Configuration Block">
// swagger will insert a window.ui = SwaggerUIBundle() here but we need to override it
//</editor-fold>
window.ui = SwaggerUIBundle({
"dom_id": "#swagger-ui",
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout",
queryConfigEnabled: false,
persistAuthorization: "${SWAGGERUI_PERSIST_AUTHORIZATION}" === "true",
url: "${PGRST_OPENAPI_SERVER_PROXY_URI}",
onComplete: function () {
// will be set if persistAuthorization is true
const config_str = localStorage.getItem("authorized");
const token = config_str ? JSON.parse(config_str).JWT?.value : null;
if (token) reload_if_token_changed();
},
requestInterceptor: function (e) {
if (current_token && !e.headers.Authorization) {
e.headers.Authorization = current_token;
}
return e;
},
});
//</editor-fold>
};