{"id":26513598,"url":"https://github.com/khteh/postgresql","last_synced_at":"2026-04-19T19:03:21.137Z","repository":{"id":93198559,"uuid":"538799385","full_name":"khteh/PostgreSQL","owner":"khteh","description":"PostgresQL with customized docker entrypoing to bootstrap multiple databases","archived":false,"fork":false,"pushed_at":"2025-04-29T08:42:21.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-29T09:42:56.390Z","etag":null,"topics":["docker","dockerfile","kubernetes","postgresl"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/khteh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-09-20T03:50:47.000Z","updated_at":"2025-04-29T08:42:27.000Z","dependencies_parsed_at":"2025-04-23T04:45:34.091Z","dependency_job_id":null,"html_url":"https://github.com/khteh/PostgreSQL","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/khteh/PostgreSQL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khteh%2FPostgreSQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khteh%2FPostgreSQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khteh%2FPostgreSQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khteh%2FPostgreSQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/khteh","download_url":"https://codeload.github.com/khteh/PostgreSQL/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khteh%2FPostgreSQL/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32018765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","dockerfile","kubernetes","postgresl"],"created_at":"2025-03-21T04:29:03.206Z","updated_at":"2026-04-19T19:03:21.129Z","avatar_url":"https://github.com/khteh.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# postgresql\n\n- Overwrite docker-entrypoint.sh in https://github.com/docker-library/postgres/blob/master/docker-entrypoint.sh to enable multiple databases\n- Add `pgvector` extension\n\n## Customization Details:\n\n- https://hub.docker.com/_/postgres \"How to extend this image\"\n\n- `docker_process_init_files`:\n  - Add the following 3 lines to each of file extensions found in `/docker-entrypoint-initdb.d`:\n  ```\n  file=${f##*/}\n  database=${file%.*}\n  export DBNAME=$database\n  ```\n- `docker_process_sql`:\n  - Process the database files defined by `docker_process_init_files` with `DB_NAME` variable:\n  ```\n  if [ -n \"$DBNAME\" ]; then\n  \tquery_runner+=( --dbname \"$DBNAME\" )\n  ```\n- `docker_setup_db`:\n  - Check and setup all the `POSTGRES_DB_\u003cfoo\u003e`\n  - Set the stage in first `POSTGRES_DB_1` for the custom user required by all the subsequent DBs:\n  ```\n  CREATE USER :\"user\" WITH PASSWORD :'password' ;\n  ```\n  - In case a privilege escalation is needed,`CREATE EXTENSION \u003cfoo\u003e`, for instance,\n  ```\n  ALTER USER :\"user\" WITH SUPERUSER ;\n  ```\n\n## Check Existing Databases\n\n```\n$ psql -U guest -h \u003csvc-postgresql-nodeport\u003e -l\nPassword for user guest:\n                                                        List of databases\n       Name       |  Owner   | Encoding | Locale Provider |  Collate   |   Ctype    | Locale | ICU Rules |   Access privileges\n------------------+----------+----------+-----------------+------------+------------+--------+-----------+-----------------------\n AspNetCoreWebApi | guest    | UTF8     | libc            | en_US.utf8 | en_US.utf8 |        |           |\n Langchain        | guest    | UTF8     | libc            | en_US.utf8 | en_US.utf8 |        |           |\n library          | guest    | UTF8     | libc            | en_US.utf8 | en_US.utf8 |        |           |\n postgres         | postgres | UTF8     | libc            | en_US.utf8 | en_US.utf8 |        |           |\n school           | guest    | UTF8     | libc            | en_US.utf8 | en_US.utf8 |        |           |\n template0        | postgres | UTF8     | libc            | en_US.utf8 | en_US.utf8 |        |           | =c/postgres          +\n                  |          |          |                 |            |            |        |           | postgres=CTc/postgres\n template1        | postgres | UTF8     | libc            | en_US.utf8 | en_US.utf8 |        |           | =c/postgres          +\n                  |          |          |                 |            |            |        |           | postgres=CTc/postgres\n(7 rows)\n```\n\n## Dump the selected database\n\n```\n$ pg_dump -U guest -h \u003csvc-postgresql-nodeport\u003e -d \u003cdatabase\u003e -f \u003cdatabase\u003e.sql\n```\n\n## Map the databases in postgresql.yml\n\n```\n            - name: POSTGRES_DB_1\n              value: AspNetCoreWebApi\n            - name: POSTGRES_DB_2\n              value: library\n            - name: POSTGRES_DB_3\n              value: school\n            - name: POSTGRES_DB_4\n              value: LangchainCheckpoint\n```\n\n## PostGIS\n\n- Use https://hub.docker.com/r/postgis/postgis as base image\n\n## PostgreSQL HA cluster\n\n- https://github.com/bitnami/charts/tree/main/bitnami/postgresql-ha\n\n### Readings\n\n- https://www.cncf.io/blog/2023/09/29/recommended-architectures-for-postgresql-in-kubernetes/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhteh%2Fpostgresql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhteh%2Fpostgresql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhteh%2Fpostgresql/lists"}