postgis
PostGIS
docker-compose.yml
postgis:
image: postgis/postgis:latest
ports:
- '5432:5432'
volumes:
- $PWD/bootstrap/init-mydb-db.sh:/docker-entrypoint-initdb.d/init-mydb-db.sh
environment:
- POSTGRES_USER=admin
- POSTGRES_PASSWORD=admin
- POSTGRES_DATABASE=admin
PostGIS 15+ DB & User Creation
bootstrap/init-mydb-db.sh
#!/bin/bash
set -e
DB_NAME=mydb
DB_USER=mydb
DB_PASSWORD=mydb
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER $DB_USER with password '$DB_PASSWORD';
CREATE DATABASE $DB_NAME;
GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;
\c $DB_NAME
CREATE EXTENSION postgis;
GRANT ALL ON SCHEMA public TO $DB_USER;
EOSQL