Last active
May 31, 2018 01:44
-
-
Save davidoram/60dd55b2ef94aaad2484d916a71fc969 to your computer and use it in GitHub Desktop.
Run dockerised schemaspy against a postgres database
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
#!/bin/bash | |
# | |
# - Run dockerised schemaspy against a postgres db | |
# - write the output to a host directory | |
# - Opens the generated website in your broswer | |
# | |
# Assumes you have already got the schemaspy docker image eg: `docker pull schemaspy/schemaspy:snapshot` | |
# | |
set -e | |
if [ $# -ne 6 ]; then | |
echo "Usage:" | |
echo "" | |
echo " `basename $0` <username> <password> <db> <host> <port> <directory>" | |
echo "" | |
echo "For example:" | |
echo "" | |
echo " `basename $0` postgres password my_db docker.for.mac.localhost 5432 tmp/schemspy" | |
echo "" | |
echo "Will create the schemaspy docs for a database, then open those docs on your browser" | |
echo "" | |
exit | |
fi | |
TYPE=pgsql | |
USER=$1 | |
PASSWORD=$2 | |
DB=$3 | |
HOST=$4 | |
PORT=$5 | |
mkdir -p $6 | |
# Docker doesn't allow relative paths in Volumes | |
DIR=$(cd "$(dirname "$6")"; pwd)/$(basename "$6") | |
docker run -v "${DIR}:/output" schemaspy/schemaspy:snapshot -u ${USER} -p ${PASSWORD} -t ${TYPE} -db ${DB} -host ${HOST} -port ${PORT} -all -hq -ruby | |
open ${DIR}/index.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed a bug - Crashed if output directory didn't exist