Last active
April 6, 2021 10:43
-
-
Save koga1020/bdce52d8448f8877adba9915e8e8f2f4 to your computer and use it in GitHub Desktop.
docker-compose for Elixir project.
This file contains 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: '3' | |
services: | |
db: | |
image: postgres:11.8-alpine | |
volumes: | |
- ./docker/db/init:/docker-entrypoint-initdb.d | |
- ./docker/db/data:/var/lib/postgresql/data | |
ports: | |
- "5432:5432" | |
environment: | |
- POSTGRES_DEV_DB=${COMPOSE_PROJECT_NAME}_dev | |
- POSTGRES_TEST_DB=${COMPOSE_PROJECT_NAME}_test | |
- POSTGRES_USER=postgres | |
- POSTGRES_PASSWORD=postgres |
This file contains 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
POSTGRES_DEV_DB=${PROJECT_NAME}_dev | |
POSTGRES_TEST_DB=${PROJECT_NAME}_test | |
databases=(${POSTGRES_DEV_DB} ${POSTGRES_TEST_DB}) | |
for database in ${databases[@]}; do | |
psql --username postgres -c "CREATE DATABASE ${database};" | |
psql --username postgres -c "GRANT ALL PRIVILEGES ON DATABASE ${database} TO postgres" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment