Skip to content

Instantly share code, notes, and snippets.

@psychemedia
Last active May 10, 2019 16:29
Show Gist options
  • Save psychemedia/8fa117e34c62b7f80b6c595b8ba4f488 to your computer and use it in GitHub Desktop.
Save psychemedia/8fa117e34c62b7f80b6c595b8ba4f488 to your computer and use it in GitHub Desktop.
Example of docker-compose / Digital Ocean workbench config for running Jupyter notebooks, PostgresDB and Agensgraph db
#Create a default token/password for Jupyter notebook
JUPYTER_TOKEN=letmein
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#Based on: https://github.com/khezen/compose-postgres
version: '3.5'
services:
agensgraph:
#https://github.com/bitnine-oss/agensgraph-docker
container_name: agensgraph_agens_container
image: bitnine/agensgraph
#Keep alive: https://stackoverflow.com/a/45450456/454773
command: tail -F /dev/null
#credentials: user: agens, pwd: agens
networks:
- agensgraph
volumes:
- agensgraph:/home/agens/AgensGraph/shareddata
#ports:
# - "5432:5432"
restart: unless-stopped
postgres:
container_name: agensgraph_postgres_container
image: postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
PGDATA: /data/postgres
volumes:
- postgres:/data/postgres
#ports:
# - "5432:5432"
networks:
- agensgraph
restart: unless-stopped
#pgadmin:
# container_name: agensgraph_pgadmin_container
# image: dpage/pgadmin4
# environment:
# PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
# PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
# volumes:
# - pgadmin:/root/.pgadmin
# ports:
# - "${PGADMIN_PORT:-5055}:80"
# networks:
# - agensgraph
# restart: unless-stopped
jupyter:
container_name: agensgraph_jupyter_notebook_container
#image: jupyter/minimal-notebook
build:
context: .
dockerfile: Dockerfile-jupyter
environment:
JUPYTER_TOKEN: "$JUPYTER_TOKEN"
ports:
- "80:8888"
volumes:
- agensgraph:/home/jovyan/agensgraph
#A file needs to be mounted against a file, not a directory
- ./DatabaseConnections.ipynb:/home/jovyan/work/DatabaseConnections.ipynb
networks:
- agensgraph
restart: unless-stopped
networks:
agensgraph:
driver: bridge
volumes:
agensgraph:
#pgadmin:
postgres:
FROM jupyter/minimal-notebook
#Install SQL magic support
RUN pip install --no-cache pandas
RUN pip install --no-cache psycopg2-binary
RUN pip install --no-cache git+https://github.com/catherinedevlin/ipython-sql
RUN pip install --no-cache git+https://github.com/pivotal-legacy/sql_magic
RUN pip install --no-cache git+https://github.com/andialbrecht/sqlparse
#ADD will automatically unzip the contents of gzipped file into the destination directory
#But not .zip file?
COPY import-northwind-dataset.zip ./
RUN unzip import-northwind-dataset.zip -d /home/jovyan/agensgraph
RUN rm ./import-northwind-dataset.zip
#Run the container
#docker run --rm -d -p 8899:8888 --name pgnotebook psychemedia/pgnotebook
##Or: docker run --rm -d --expose 8888 --name pgnotebook psychemedia/pgnotebook
#Or with a custom token:
#docker run --rm -d -p 8899:8888 --name pgnotebook -e JUPYTER_TOKEN='letmeout' psychemedia/pgnotebook
#Tidy up after running
#docker kill pgnotebook
#docker rm pgnotebook
#Push container to Docker hub (must be logged in)
#docker push psychemedia/pgnotebook
#!/bin/bash
#Optionally:
#export JUPYTER_TOKEN=myOwnPA5%w0rD
GIST=8fa117e34c62b7f80b6c595b8ba4f488
git clone https://gist.github.com/$GIST.git
cd $GIST
docker-compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment