Skip to content

Instantly share code, notes, and snippets.

@vknabel
Created May 3, 2021 17:03
Show Gist options
  • Save vknabel/c7349bfac9be10b81b4fb8b9e931c497 to your computer and use it in GitHub Desktop.
Save vknabel/c7349bfac9be10b81b4fb8b9e931c497 to your computer and use it in GitHub Desktop.
function psqlhere() {
local CURRENT_BASENAME=$(basename "$PWD")
echo -e "\e[1;32mDATABASE_URL postgres://$CURRENT_BASENAME:$CURRENT_BASENAME@localhost/$CURRENT_BASENAME\e[0m";
docker run --rm \
--env POSTGRES_USER=$CURRENT_BASENAME \
--env POSTGRES_DB=$CURRENT_BASENAME \
--env POSTGRES_PASSWORD=$CURRENT_BASENAME \
--publish 5432:5432 \
--name "psql-$CURRENT_BASENAME" \
--tty --interactive \
--volume "/Users/vknabel/dev/psqlhere/$PWD":/var/lib/postgresql/data \
postgres:11-alpine
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment