Last active
April 29, 2020 20:20
-
-
Save retrospectacus/521b0a572212ed0aa5835ffa38bbf354 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
db: | |
image: postgres:9.6 | |
command: postgres -c 'max_connections=300' -c 'shared_buffers=4GB' -c 'work_mem=16MB' -c 'maintenance_work_mem=1GB' -c 'bgwriter_lru_maxpages=200' -c 'commit_delay=10' -c 'checkpoint_timeout=30min' -c 'checkpoint_warning=30min' -c 'log_timezone=Canada/Mountain' -c 'timezone=Canada/Mountain' | |
volumes: | |
- ${PWD}/docker/db/initdb.sh:/docker-entrypoint-initdb.d/initdb.sh | |
ports: | |
- "5432:5432" | |
env_file: | |
- docker/dsdev.env | |
fg-db: | |
build: docker/ds-fg-db | |
command: postgres -c 'data_directory=/datadir' | |
ports: | |
- "15432:5432" | |
environment: | |
PGDATA: /datadir | |
DB_USER_NAME: dsfg | |
DB_PASSWORD: yukon | |
DB_SCHEMA: dsfg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if psql --username "$POSTGRES_USER" postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='$DB_USER_NAME'" | grep -q 1 ; then | |
echo "User already exists; skipping import" | |
else | |
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL | |
create user $DB_USER_NAME with createrole superuser password '$DB_PASSWORD'; | |
create database $DB_SCHEMA with owner $DB_USER_NAME; | |
EOSQL | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM postgres:11.2-alpine | |
COPY create_db.sh /docker-entrypoint-initdb.d/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment