Skip to content
Open

Dev #10

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.vscode/
.idea/
docker/
data/
.empty/

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ touch .env

Open the `.env` file and place the following text, filling the `{text under curly brackets}` as suggested:

_content of the `.env` file -->_
_to create a new `.env` file -->_

```ini
```bash
$ tee .env <<EOF
DSDB_USER=datascientist
DSDB_PASSWORD={your password}
DSDB_DB=dsdb
Expand All @@ -65,6 +66,7 @@ POSTGRES_DB=mydb

PGADMIN_DEFAULT_EMAIL={your email}
PGADMIN_DEFAULT_PASSWORD={another different password}
EOF
```

And then start the game
Expand Down
57 changes: 25 additions & 32 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.7'
services:
jupyter:
image: jupyter/scipy-notebook:latest
ds:
image: jupyter/base-notebook:latest
container_name: jupyter-dsdb
environment:
# Jupyter container variables
Expand All @@ -10,43 +10,36 @@ services:
DSDB_USER: ${DSDB_USER}
DSDB_PASSWORD: ${DSDB_PASSWORD}
DSDB_DB: ${DSDB_DB}
DSDB_HOST: db:5432
DSDB_DRIVER: postgres+psycopg2
command: [
"/bin/bash", "-c", "conda install --yes --quiet psycopg2 sqlalchemy && pip install -q dsdb && start-notebook.sh --notebook-dir ~/local_directory --ip 0.0.0.0 --no-browser"]
DSDB_HOST: ${DSDB_HOST}
DSDB_PORT: ${DSDB_PORT}
DSDB_TYPE: ${DSDB_TYPE}
command: >
bash -c "conda install --yes --quiet -c conda-forge redis-py
&& python -m pip install -e /home/jovyan/local_directory
&& start-notebook.sh --notebook-dir ~/local_directory --ip 0.0.0.0 --no-browser"
ports:
- 8888:8888
volumes:
- ./:/home/jovyan/local_directory
- jupyter_conda:/opt/conda
depends_on:
- db
# depends_on:
# - db

db:
build:
context: https://bitbucket.org/buildnn/docker-dsdb-postgres.git
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
DSDB_USER: ${DSDB_USER}
DSDB_DB: ${DSDB_DB}
DSDB_PASSWORD: ${DSDB_PASSWORD}
POSTGRES_MULTIDB: "${DSDB_DB}:${DSDB_USER}:${DSDB_PASSWORD}"
redis:
image: redis:6
command: [ "redis-server", "/etc/redis/conf/redis.conf" ]
ports:
- 6379:6379
volumes:
- postgres_data:/var/lib/postgresql/data/

pgadmin:
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD}
PGADMIN_LISTEN_PORT: 5050
- ./docker/redis/:/etc/redis/conf

redis-insights:
image: redislabs/redisinsight
ports:
- 5050:5050
depends_on:
- db
- 8001:8001
volumes:
- redisinsight:/db

volumes:
postgres_data:
jupyter_conda:
jupyter_conda:
redisinsight:
3 changes: 3 additions & 0 deletions docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
redis/users.acl
*.env
mongodb/init-mongo.js
31 changes: 31 additions & 0 deletions docker/docker-compose-mongodb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3.7'
services:
ds:
image: jupyter/base-notebook:latest
container_name: jupyter-dsdb
env_file: mongodb.env
environment:
# Jupyter container variables
JUPYTER_ENABLE_LAB: 1
command: >
bash -c "conda install --yes --quiet -c conda-forge redis-py
&& python -m pip install -e /home/jovyan/local_directory
&& start-notebook.sh --notebook-dir ~/local_directory --ip 0.0.0.0 --no-browser"
ports:
- 8888:8888
volumes:
- ../:/home/jovyan/local_directory
- jupyter_conda:/opt/conda

mongodb:
image: mongo:4
env_file: mongodb.env
ports:
- 27017:27017
- 27018:27018
- 27019:27019
volumes:
- ./mongodb/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro

volumes:
jupyter_conda:
37 changes: 37 additions & 0 deletions docker/docker-compose-postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: '3.7'
services:
ds:
image: jupyter/base-notebook:latest
container_name: jupyter-dsdb
env_file: postgres.env
environment:
# Jupyter container variables
JUPYTER_ENABLE_LAB: 1
command: >
bash -c "conda install --yes --quiet psycopg2 sqlalchemy pandas
&& python -m pip install -e /home/jovyan/local_directory
&& start-notebook.sh --notebook-dir ~/local_directory --ip 0.0.0.0 --no-browser"
ports:
- 8888:8888
volumes:
- ../:/home/jovyan/local_directory
- jupyter_conda:/opt/conda

postgres:
image: postgres:12
env_file: postgres.env
ports:
- 5432:5432
volumes:
- ./postgres:/docker-entrypoint-initdb.d/

pgadmin:
image: dpage/pgadmin4
env_file: pgadmin.env
ports:
- 5050:5050
depends_on:
- postgres

volumes:
jupyter_conda:
29 changes: 29 additions & 0 deletions docker/docker-compose-redis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3.7'
services:
ds:
image: jupyter/base-notebook:latest
container_name: jupyter-dsdb
env_file: redis.env
environment:
# Jupyter container variables
JUPYTER_ENABLE_LAB: 1
command: >
bash -c "conda install --yes --quiet -c conda-forge redis-py
&& python -m pip install -e /home/jovyan/local_directory
&& start-notebook.sh --notebook-dir ~/local_directory --ip 0.0.0.0 --no-browser"
ports:
- 8888:8888
volumes:
- ../:/home/jovyan/local_directory
- jupyter_conda:/opt/conda

redis:
image: redis:6
command: [ "redis-server", "/etc/redis/conf/redis.conf" ]
ports:
- 6379:6379
volumes:
- ./redis/:/etc/redis/conf

volumes:
jupyter_conda:
26 changes: 26 additions & 0 deletions docker/postgres/create-multiple-postgresql-databases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e

function create_user_n_db() {
local database=$(echo $1 | tr ':' ' ' | awk '{print $1}')
local owner=$(echo $1 | tr ':' ' ' | awk '{print $2}')
local passwd=$(echo $1 | tr ':' ' ' | awk '{print $3}')
echo " Creating user and its db '$database'"
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER $owner WITH PASSWORD '$passwd';
CREATE DATABASE $database;
GRANT ALL PRIVILEGES ON DATABASE $database TO $owner;
EOSQL
echo "ok"
}


if [ -n "$POSTGRES_MULTIDB" ]; then
echo "Multi-db initialization started..."
for db in $(echo $POSTGRES_MULTIDB | tr ',' ' '); do
create_user_n_db $db
done
echo "Multi-db initialization completed."
fi

Loading