зеркало из
				https://github.com/iharh/notes.git
				synced 2025-10-31 21:56:08 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			28 строки
		
	
	
		
			917 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			28 строки
		
	
	
		
			917 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| https://github.com/mrts/docker-postgresql-multiple-databases
 | |
| https://github.com/mrts/docker-postgresql-multiple-databases/blob/master/create-multiple-postgresql-databases.sh
 | |
| 
 | |
| https://dev.to/nietzscheson/multiples-postgres-databases-in-one-service-with-docker-compose-4fdf
 | |
| ### entrypoint.sh
 | |
| #!/bin/bash
 | |
| 
 | |
| set -e
 | |
| set -u
 | |
| 
 | |
| function create_user_and_database() {
 | |
|     local database=$1
 | |
|     echo "  Creating user and database '$database'"
 | |
|     psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
 | |
|         CREATE USER $database;
 | |
|         CREATE DATABASE $database;
 | |
|         GRANT ALL PRIVILEGES ON DATABASE $database TO $database;
 | |
|   EOSQL
 | |
| }
 | |
| 
 | |
| if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then
 | |
|     echo "Multiple database creation requested: $POSTGRES_MULTIPLE_DATABASES"
 | |
|     for db in $(echo $POSTGRES_MULTIPLE_DATABASES | tr ',' ' '); do
 | |
|         create_user_and_database $db
 | |
|     done
 | |
|     echo "Multiple databases created"
 | |
| fi
 | 
