{"id":28816713,"url":"https://github.com/luismr/postgres-17-multidb-pgvector","last_synced_at":"2026-04-11T14:32:22.709Z","repository":{"id":299695183,"uuid":"1003857486","full_name":"luismr/postgres-17-multidb-pgvector","owner":"luismr","description":"Postgres 17 image with multi-db, user, and pgvector (0.7.1) auto-setup via env variables.","archived":false,"fork":false,"pushed_at":"2025-06-17T21:14:46.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-17T21:27:54.763Z","etag":null,"topics":["docker","docker-compose","docker-image","multi-database","multidb","pgvector","postgres","postgres-17","postgresql"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luismr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2025-06-17T19:19:09.000Z","updated_at":"2025-06-17T21:13:59.000Z","dependencies_parsed_at":"2025-06-17T21:39:37.320Z","dependency_job_id":null,"html_url":"https://github.com/luismr/postgres-17-multidb-pgvector","commit_stats":null,"previous_names":["luismr/postgres-17-multidb-pgvector"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/luismr/postgres-17-multidb-pgvector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luismr%2Fpostgres-17-multidb-pgvector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luismr%2Fpostgres-17-multidb-pgvector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luismr%2Fpostgres-17-multidb-pgvector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luismr%2Fpostgres-17-multidb-pgvector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luismr","download_url":"https://codeload.github.com/luismr/postgres-17-multidb-pgvector/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luismr%2Fpostgres-17-multidb-pgvector/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31684523,"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":["docker","docker-compose","docker-image","multi-database","multidb","pgvector","postgres","postgres-17","postgresql"],"created_at":"2025-06-18T17:06:36.944Z","updated_at":"2026-04-11T14:32:22.663Z","avatar_url":"https://github.com/luismr.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Custom Postgres with Dynamic Multi-Database and pgvector Support\n\n![Docker 21.1.x](https://img.shields.io/badge/Docker-21.1.x-2496ED?logo=docker\u0026logoColor=white\u0026style=for-the-badge)\n![Docker Compose 2.37.x](https://img.shields.io/badge/Docker--Compose-2.37.x-2496ED?logo=docker\u0026logoColor=white\u0026style=for-the-badge)\n![Postgres 17](https://img.shields.io/badge/Postgres-17-green?logo=postgresql\u0026logoColor=white\u0026style=for-the-badge)\n![pgvector 0.7.1](https://img.shields.io/badge/pgvector-0.7.1-green?logo=postgresql\u0026logoColor=white\u0026style=for-the-badge)\n![AMD64](https://img.shields.io/badge/Arch-amd64-blue?logo=linux\u0026logoColor=white\u0026style=for-the-badge)\n![ARM64](https://img.shields.io/badge/Arch-arm64-blue?logo=linux\u0026logoColor=white\u0026style=for-the-badge)\n\nThis image extends the official Postgres image to support:\n- Dynamic creation of multiple databases and users at initialization\n- Automatic enabling of the `pgvector` extension for databases prefixed with `VECTOR_`\n- Admin and user role setup via environment variables\n- Use of `gettext`/`envsubst` for dynamic templating\n\n## Table of Contents\n- [Features](#features)\n- [Project Structure](#project-structure)\n- [Requirements](#requirements)\n- [Build and Run with Docker](#build-and-run-with-docker)\n- [Prebuilt Docker Image](#prebuilt-docker-image)\n- [Example Usage](#example-usage)\n- [Environment Variables](#environment-variables)\n- [Sidecar Database Logic](#sidecar-database-logic)\n- [How It Works](#how-it-works)\n- [Overriding Defaults](#overriding-defaults)\n- [Notes](#notes)\n- [Contributing](#contributing)\n- [License](#license)\n- [References](#references)\n\n## Features\n\n- **Multi-database initialization**: Create any number of databases and users at container startup.\n- **pgvector support**: If a database name starts with `VECTOR_`, the `pgvector` extension is enabled in that database.\n- **Admin user**: Optionally create a superuser admin role.\n- **Sidecar users**: Each sidecar database gets a user with the pattern `\u003cdb\u003e_user` (all lowercase) and a default password.\n\n## Project Structure\n\n```\npostgres-pgvector-multidatabase/\n├── Dockerfile           # Docker build instructions for the custom Postgres image\n├── init-multidb.sh      # Initialization script for dynamic multi-database and user setup\n├── init.sql.template    # SQL template used for database/user creation and extension enabling\n├── LICENSE.md           # Project license (MIT)\n├── README.md            # Project documentation and usage instructions\n```\n\n## Requirements\n- Docker\n- Docker Compose (optional, for multi-container setups)\n\n## Build and Run with Docker\n\n### Build the Docker Image\n\n```sh\ndocker build -t custom-postgres-multidb-pgvector .\n```\n\n### Run the Container\n\n```sh\ndocker run -d \\\n  --name my-postgres \\\n  -e POSTGRES_USER=pguser \\\n  -e POSTGRES_PASSWORD=pguserstrongpassword \\\n  -e POSTGRES_DB=postgres \\\n  -e POSTGRES_DB_SIDECARS=db1,db2,VECTOR_db3 \\\n  -p 5432:5432 \\\n  custom-postgres-multidb-pgvector\n```\n\nYou can adjust the environment variables as needed.\n\n## Prebuilt Docker Image\n\nA prebuilt image is available on Docker Hub:\n\n[luismachadoreis/postgres-multidb-pgvector:pg17](https://hub.docker.com/repository/docker/luismachadoreis/postgres-multidb-pgvector/tags/pg17)\n\n- Use the `pg17` tag for AMD64 (x86_64) systems:\n  ```sh\n  docker pull luismachadoreis/postgres-multidb-pgvector:pg17\n  ```\n- Use the `pg17-arm64` tag for ARM64 (Apple Silicon, Raspberry Pi, etc):\n  ```sh\n  docker pull luismachadoreis/postgres-multidb-pgvector:pg17-arm64\n  ```\n\nYou can use the appropriate image in your `docker run` or `docker-compose.yml` as the base image for your platform.\n\n## Example Usage\n\n### docker-compose.yml\n```yaml\nversion: '3.8'\nservices:\n  postgres:\n    build: .\n    environment:\n      POSTGRES_USER: pguser\n      POSTGRES_PASSWORD: pguserstrongpassword\n      POSTGRES_DB: postgres\n      POSTGRES_DB_SIDECARS: db1,db2,VECTOR_db3\n    ports:\n      - \"5432:5432\"\n    volumes:\n      - pgdata:/var/lib/postgresql/data\nvolumes:\n  pgdata:\n```\n\n## Environment Variables\n| Variable                  | Default                | Description                                                                 |\n|---------------------------|------------------------|-----------------------------------------------------------------------------|\n| `POSTGRES_USER`           | `pguser`               | Default user role (as in official image)                                    |\n| `POSTGRES_PASSWORD`       | `pguserstrongpassword` | Password for the default user                                               |\n| `POSTGRES_DB`             | `postgres`             | Default database (as in official image)                                     |\n| `POSTGRES_DB_SIDECARS`    | `db1,db2,VECTOR_db3`   | Comma-separated list of extra databases to create                           |\n\n## Sidecar Database Logic\n- For each database in `POSTGRES_DB_SIDECARS`:\n  - A database is created (if it doesn't exist)\n  - A user is created: `\u003cdb\u003e_user` (all lowercase), password: `mydefaultpassword`\n  - The user is granted all privileges on their database\n  - If the database name starts with `VECTOR_`, the `pgvector` extension is enabled in that database\n\n## How It Works\n- On first container startup, the script `init-multidb.sh` runs.\n- It reads the environment variables and creates the specified databases and users.\n- For any database with a name starting with `VECTOR_`, it enables the `pgvector` extension.\n- All sidecar users get the password `mydefaultpassword` (change in script if needed).\n\n## Overriding Defaults\nYou can override any environment variable at build or runtime. For example, to add more vector-enabled databases:\n\n```yaml\n      POSTGRES_DB_SIDECARS: db1,VECTOR_embeddings,VECTOR_analytics\n```\n\n## Notes\n- The default user and database logic is compatible with the official Postgres image.\n- The admin user is optional but recommended for superuser access.\n- The `pgvector` extension is built from source at image build time.\n\n## Contributing\n\n### Clone the Repository\n\n```sh\ngit clone git@github.com:luismr/postgres-17-multidb-pgvector.git\ncd postgres-17-multidb-pgvector\n```\n\n### Submitting Pull Requests\n\n1. Fork this repository on GitHub.\n2. Create a new branch for your feature or fix:\n   ```sh\n   git checkout -b my-feature-branch\n   ```\n3. Make your changes and commit them with clear messages.\n4. Push your branch to your fork:\n   ```sh\n   git push origin my-feature-branch\n   ```\n5. Open a Pull Request on GitHub from your branch to the `main` branch of this repository.\n6. Provide a clear description of your changes in the PR.\n\n## License\n[MIT License](LICENSE.md)\n\n## References\n\n- [Docker Documentation](https://docs.docker.com/)\n- [Docker Compose Documentation](https://docs.docker.com/compose/)\n- [PostgreSQL 17 Documentation](https://www.postgresql.org/docs/17/)\n- [pgvector Extension](https://github.com/pgvector/pgvector)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluismr%2Fpostgres-17-multidb-pgvector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluismr%2Fpostgres-17-multidb-pgvector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluismr%2Fpostgres-17-multidb-pgvector/lists"}