This template provides a PostgreSQL database with PostGIS and Uber's H3 extension pre-installed, ready to deploy on Railway.
- PostgreSQL 17
- PostGIS 3.4
- Uber's H3 postgres extension bindings for hexagonal hierarchical geospatial indexing https://github.com/postgis/h3-pg
- Pre-configured extensions and dependencies
- A Railway account
- Railway CLI (optional, for local development)
Docker Compose reads POSTGRES_PORT, POSTGRES_DB, POSTGRES_USER, and POSTGRES_PASSWORD from a .env file. These are the same variables used for deployment; you can change the values in .env before first run.
Clone this repository:
git clone <your-repo-url>
cd postgres-h3Create a .env file so Docker Compose and the database init scripts have valid values (without it, variables are empty and initialization will fail):
cp .env.example .envEdit .env if you want different database name, user, or password. Then start the database:
docker-compose up -dConnect to the database (use the same POSTGRES_DB and POSTGRES_PASSWORD as in your .env):
psql -h localhost -p 54040 -U postgres -d postgresh3db -W
Enter the password when prompted (e.g. postgres if that’s your POSTGRES_PASSWORD).
-
Use the right port and password: With docker-compose the app is on port 54040 (mapped from 5432). Connect with the same password as in
.env(POSTGRES_PASSWORD). -
Stale volume: The password is set only when the data directory is first created. If you previously ran the container without
POSTGRES_PASSWORDor with a different one, the existing volume still has the old password. Reset and re-init:docker-compose down -v docker-compose up -d
(
-vremoves thepostgres_datavolume so the next startup re-initializes with your current.env.)
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Developed and maintained by Chike Ozulumba. For issues or suggestions, please open an issue on the GitHub repository.