-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experiment generating multiple login users for pgbouncer
- Loading branch information
Showing
3 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM edoburu/pgbouncer:latest | ||
|
||
# Custom step to generate all users from environment variables | ||
COPY generate-config.sh / | ||
# Run our script and then the default entrypoint | ||
ENTRYPOINT ["/bin/sh", "-c", "/generate-config.sh && exec /entrypoint.sh"] | ||
|
||
CMD ["/usr/bin/pgbouncer", "/etc/pgbouncer/pgbouncer.ini"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
output_file="/etc/pgbouncer/userlist.txt" | ||
|
||
> "$output_file" | ||
|
||
# See https://github.com/edoburu/docker-pgbouncer/blob/master/examples/generate-userlist; | ||
# The MD5 should be formed from password+username | ||
compute_md5() { | ||
password="$1" | ||
username="$2" | ||
printf "md5%s" "$(printf "%s%s" "$password" "$username" | md5sum | awk '{print $1}')" | ||
} | ||
|
||
echo "\"$DB_USER\" \"$(compute_md5 "$DB_ROOT_PASSWORD" "$DB_USER")\"" >> "$output_file" | ||
echo "\"$FERRY_DB_USER\" \"$(compute_md5 "$FERRY_DB_PASSWORD" "$FERRY_DB_USER")\"" >> "$output_file" | ||
echo "\"$HASURA_DB_USER\" \"$(compute_md5 "$HASURA_DB_PASSWORD" "$HASURA_DB_USER")\"" >> "$output_file" | ||
|
||
echo "Userlist generated in $output_file" | ||
cat "$output_file" |