Skip to content

Commit d84bfe3

Browse files
committed
fix: make keycloak startup
1 parent b4bb1fb commit d84bfe3

File tree

3 files changed

+160
-140
lines changed

3 files changed

+160
-140
lines changed

devenv.nix

Lines changed: 55 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
{ inputs, pkgs, lib, config, ... }: {
1+
{ inputs
2+
, pkgs
3+
, lib
4+
, config
5+
, ...
6+
}:
7+
{
28
env.DEVENV_NIX = inputs.nix.packages.${pkgs.stdenv.system}.nix;
39
# ignore annoying browserlists warning that breaks pre-commit hooks
410
env.BROWSERSLIST_IGNORE_OLD_DATA = "1";
@@ -17,6 +23,7 @@
1723
pkgs.watchexec
1824
pkgs.openssl
1925
pkgs.sqlx-cli
26+
pkgs.process-compose
2027
];
2128

2229
languages.nix.enable = true;
@@ -128,7 +135,9 @@
128135
{ pkgs, ... }: {
129136
130137
# Enable all languages tooling!
131-
${lib.concatStringsSep "\n " (map (lang: "languages.${lang}.enable = true;") (builtins.attrNames config.languages))}
138+
${lib.concatStringsSep "\n " (
139+
map (lang: "languages.${lang}.enable = true;") (builtins.attrNames config.languages)
140+
)}
132141
133142
# If you're missing a language, please contribute it by following examples of other languages <3
134143
}
@@ -140,12 +149,16 @@
140149
exec = ''
141150
cat > docs/services-all.md <<EOF
142151
\`\`\`nix
143-
${lib.concatStringsSep "\n " (map (lang: "services.${lang}.enable = true;") (builtins.attrNames config.services))}
152+
${lib.concatStringsSep "\n " (
153+
map (lang: "services.${lang}.enable = true;") (builtins.attrNames config.services)
154+
)}
144155
\`\`\`
145156
EOF
146157
cat > docs/languages-all.md <<EOF
147158
\`\`\`nix
148-
${lib.concatStringsSep "\n " (map (lang: "languages.${lang}.enable = true;") (builtins.attrNames config.languages))}
159+
${lib.concatStringsSep "\n " (
160+
map (lang: "languages.${lang}.enable = true;") (builtins.attrNames config.languages)
161+
)}
149162
\`\`\`
150163
EOF
151164
'';
@@ -164,55 +177,55 @@
164177
description = "Generate missing template markdown files";
165178
exec = ''
166179
167-
process_directory() {
168-
local nix_dir=$1
169-
local md_dir=$2
170-
local category=$3
180+
process_directory() {
181+
local nix_dir=$1
182+
local md_dir=$2
183+
local category=$3
171184
172-
nixFiles=($(ls $nix_dir/*.nix))
173-
mdFiles=($(ls $md_dir/*.md))
185+
nixFiles=($(ls $nix_dir/*.nix))
186+
mdFiles=($(ls $md_dir/*.md))
174187
175-
declare -a nixList
176-
declare -a mdList
188+
declare -a nixList
189+
declare -a mdList
177190
178-
# Remove extensions and populate lists
179-
for file in "''${nixFiles[@]}"; do
180-
baseName=$(basename "$file" .nix)
181-
nixList+=("$baseName")
182-
done
191+
# Remove extensions and populate lists
192+
for file in "''${nixFiles[@]}"; do
193+
baseName=$(basename "$file" .nix)
194+
nixList+=("$baseName")
195+
done
183196
184-
for file in "''${mdFiles[@]}"; do
185-
baseName=$(basename "$file" .md)
186-
mdList+=("$baseName")
187-
done
197+
for file in "''${mdFiles[@]}"; do
198+
baseName=$(basename "$file" .md)
199+
mdList+=("$baseName")
200+
done
188201
189-
IFS=$'\n' sorted_nix=($(sort <<<"''${nixList[*]}"))
190-
IFS=$'\n' sorted_md=($(sort <<<"''${mdList[*]}"))
202+
IFS=$'\n' sorted_nix=($(sort <<<"''${nixList[*]}"))
203+
IFS=$'\n' sorted_md=($(sort <<<"''${mdList[*]}"))
191204
192-
# Compare and create missing files
193-
missing_files=()
194-
for item in "''${sorted_nix[@]}"; do
195-
if [[ ! " ''${sorted_md[@]} " =~ " $item " ]]; then
196-
missing_files+=("$item")
197-
cat << EOF > "$md_dir/$item.md"
205+
# Compare and create missing files
206+
missing_files=()
207+
for item in "''${sorted_nix[@]}"; do
208+
if [[ ! " ''${sorted_md[@]} " =~ " $item " ]]; then
209+
missing_files+=("$item")
210+
cat << EOF > "$md_dir/$item.md"
198211
199212
200-
[comment]: # (Please add your documentation on top of this line)
213+
[comment]: # (Please add your documentation on top of this line)
201214
202-
@AUTOGEN_OPTIONS@
203-
EOF
204-
echo "Created missing file: $md_dir/$item.md"
205-
fi
206-
done
215+
@AUTOGEN_OPTIONS@
216+
EOF
217+
echo "Created missing file: $md_dir/$item.md"
218+
fi
219+
done
207220
208-
if [ ''${#missing_files[@]} -eq 0 ]; then
209-
echo "All $category docs markdown files are present."
210-
fi
211-
}
221+
if [ ''${#missing_files[@]} -eq 0 ]; then
222+
echo "All $category docs markdown files are present."
223+
fi
224+
}
212225
213-
process_directory "src/modules/languages" "docs/individual-docs/languages" "language"
214-
process_directory "src/modules/services" "docs/individual-docs/services" "service"
215-
process_directory "src/modules/process-managers" "docs/individual-docs/process-managers" "process manager"
226+
process_directory "src/modules/languages" "docs/individual-docs/languages" "language"
227+
process_directory "src/modules/services" "docs/individual-docs/services" "service"
228+
process_directory "src/modules/process-managers" "docs/individual-docs/process-managers" "process manager"
216229
'';
217230
};
218231

examples/keycloak/.test.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
#!/bin/sh
2-
set -ex
2+
set -e
33

44
echo "Startup complete..."
55
echo "Checking for keycloak readiness..."
6+
echo "Process compose socket: $PC_SOCKET_PATH"
7+
bash
68

79
for i in $(seq 1 10); do
8-
if curl -v "http://localhost:8089/auth/realms/master/.well-known/openid-configuration"; then
10+
status=$(
11+
curl --silent --output /dev/null --write-out "%{http_code}" \
12+
"http://localhost:8089/realms/master/.well-known/openid-configuration" || true
13+
)
14+
15+
if curl -k --head -fsS "https://localhost:9000/health/ready" ||
16+
[ "$status" -eq 200 ]; then
917
echo "Keycloak master realm up and running."
1018
exit 0
1119
fi
1220

13-
echo "Could not get openid-configuration for master realm. Try: '$i/10'."
21+
echo "Could not get openid-configuration for master realm. Status: $status, Try: '$i/10'."
1422
sleep 3
1523
done
1624

0 commit comments

Comments
 (0)