{"id":21894117,"url":"https://github.com/hackgt/pg_initialaser","last_synced_at":"2026-04-11T13:32:11.875Z","repository":{"id":79765843,"uuid":"122300913","full_name":"HackGT/pg_initialaser","owner":"HackGT","description":"\"Postgres is 1% determination and 99% containerization\"-@mjkaufer Utility for creating user and database on a Postgres server in Kubernetes","archived":false,"fork":false,"pushed_at":"2018-02-23T19:26:49.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-22T04:09:52.865Z","etag":null,"topics":["database","docker","georgia-tech","hackathon","hackgt","kubernetes","pg-initialaser","postgres"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HackGT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2018-02-21T06:33:47.000Z","updated_at":"2018-04-25T21:46:33.000Z","dependencies_parsed_at":"2023-06-02T08:30:12.538Z","dependency_job_id":null,"html_url":"https://github.com/HackGT/pg_initialaser","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/HackGT/pg_initialaser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HackGT%2Fpg_initialaser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HackGT%2Fpg_initialaser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HackGT%2Fpg_initialaser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HackGT%2Fpg_initialaser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HackGT","download_url":"https://codeload.github.com/HackGT/pg_initialaser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HackGT%2Fpg_initialaser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31682953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T13:07:20.380Z","status":"ssl_error","status_checked_at":"2026-04-11T13:06:47.903Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["database","docker","georgia-tech","hackathon","hackgt","kubernetes","pg-initialaser","postgres"],"created_at":"2024-11-28T13:19:00.130Z","updated_at":"2026-04-11T13:32:11.847Z","avatar_url":"https://github.com/HackGT.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg_initialaser [![Build Status](https://travis-ci.org/HackGT/pg_initialaser.svg?branch=master)](https://travis-ci.org/HackGT/pg_initialaser)\n\nA simple script packaged into a Docker container that idempotent-ly creates\na Postgres user and database on a given host specified in environment variables.\nRealtalk:tm:: this project is a 2 line script that runs `CREATE USER` and\n`CREATE DATABASE`.\n\n**Note:** The user that is created has restricted permissions (only has access\nto the created database). It also does not have a password.\n\n## Environment variables\n\n| Name         | Description                                                                                  |\n| ----         | -----------                                                                                  |\n| POSTGRES_URL | (connection option) Connection string for the Postgres server. This should be an admin user. |\n| USERNAME     | Username for the user to be created                                                          |\n| DBNAME       | Name for the database to be created (owner is set to the created user)                       |\n\n## Exit Codes\n\n`pg_initializer` will only exit with an error code (exit code != 0) when `psql`\nhas issues connecting to the database. `psql` does not error when SQL errors are\nencountered, helping make the containerized utility idempotent.\n\n## Usage as an [Init Container](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/)\n\nMongoDB allows applications to upsert databases(!) by simply connecting and\nwriting. If no existing database exists at that path then a new database is\ncreated and the data is written there.\n\nPostgres does not work this way.\n\nInstead, a superuser (or other user with proper permissions) needs to explicitly\ncreate a database. `pg_initializer` does this after first creating a user with\nrestricted permissions and then creates a database with that user as the owner.\nBecause duplicate user/database errors do not produce error codes on exit, this\nutility is suitable for usage as an init container - exit 0'ing when both the\nuser and database exist.\n\nAdditionally, because connection failures will result in an error code, this\ninit container will prevent apps that depend on Postgres from starting when\nthe database server is down.\n\n## Background\n\nThis was created to be used as an [Init Container](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/)\nin [HackGT/biodomes](https://github.com/HackGT/biodomes) for applications that use Postgres as a datastore.\nThis image allows biodomes to create a new user and database for each deployment\nof each application that uses Postgres (each PR will have a separate db and all\nisolated from each other - and production).\n\nSee [HackGT/biodomes#16](https://github.com/HackGT/biodomes/pull/16) for more context.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackgt%2Fpg_initialaser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackgt%2Fpg_initialaser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackgt%2Fpg_initialaser/lists"}