Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
DWH_POSTGRES_PASSWORD=password4db
DWH_POSTGRES_ADMIN=postgres
DWH_POSTGRES_DATABASE=dwhdb
DWH_POSTGRES_DATABASE=emsdb

PGADMIN_DEFAULT_EMAIL=test@jaimal.com
PGADMIN_DEFAULT_PASSWORD=password
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
# postgres_docker
Local setup of Postgres on Docker Compose

## Prerequisites
- Docker (started) and docker-compose (just install Docker for Desktop if you are on laptop)

## Quickstart
1. Clone repo `git clone https://github.com/datafuel/postgres_docker.git`
2. Run `cd postgres_docker`
3. Rename **.env.example** to **.env** and replace dummy values with yours
4. Run `docker compose -f docker_build/docker-compose.yml`
5. Run `docker compose up` to run services
6. Run `docker exec -it dbt bash` to attach shell

## Connect to database
1. Give a *Name* to the Connection
2. Go to the *General* Tab then :
- **Host name /address** : postgres_dwh
- **Port** : 5432
- **Usernname** : postgres
- **Password** : password4db
*The credentials may vary. They are defined in the .env file*
18 changes: 15 additions & 3 deletions datafuel.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,28 @@ services:
postgres_dwh:
image: postgres:10-alpine
container_name: postgres_dwh
volumes:
# volumes:
# - "./data_repo:/host"
- ./scripts:/docker-entrypoint-initdb.d
- ./backup:/backup
# - ./scripts:/docker-entrypoint-initdb.d
# - ./backup:/backup
ports:
- "5433:5432"
environment:
POSTGRES_USER: $DWH_POSTGRES_ADMIN
POSTGRES_PASSWORD: $DWH_POSTGRES_PASSWORD
# POSTGRES_DB: $DWH_POSTGRES_DATABASE

pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- pgadmin:/root/.pgadmin
ports:
- 5050:80

networks:
default:
Expand Down
14 changes: 13 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
# postgreSQL service (share data between services)

postgres_dwh:
image: postgres:10-alpine
image: postgres
container_name: postgres_dwh
volumes:
- "./data_repo:/host"
Expand All @@ -15,3 +15,15 @@ services:
POSTGRES_USER: $DWH_POSTGRES_ADMIN
POSTGRES_PASSWORD: $DWH_POSTGRES_PASSWORD
POSTGRES_DB: testdb

pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- ./pgadmin_data:/root/.pgadmin
ports:
- 5050:80