-
-
Save sijad/829b3c0eef527015ae635d8ae3b62f87 to your computer and use it in GitHub Desktop.
my docker-sqitch.sh
This file contains hidden or 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
# APP settings | |
DATABASE_URL=//user:secret@localhost/db-name | |
# SQITCH settings | |
SQITCH_FULLNAME= | |
SQITCH_EMAIL= |
This file contains hidden or 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
#!/usr/bin/env bash | |
export $(grep -v '^#' .env | xargs) | |
# Determine which Docker image to run. | |
SQITCH_IMAGE=${SQITCH_IMAGE:=sqitch/sqitch:latest} | |
# Set up required pass-through variables. | |
passopt=( | |
-e "SQITCH_TARGET=db:pg:$DATABASE_URL" | |
-e "TZ=$(date +%Z)" \ | |
-e "LESS=${LESS:--R}" \ | |
) | |
# Iterate over optional Sqitch and engine variables. | |
for var in \ | |
SQITCH_CONFIG SQITCH_USERNAME SQITCH_PASSWORD SQITCH_FULLNAME SQITCH_EMAIL SQITCH_TARGET \ | |
DBI_TRACE \ | |
PGUSER PGPASSWORD PGHOST PGHOSTADDR PGPORT PGDATABASE PGSERVICE PGOPTIONS PGSSLMODE PGREQUIRESSL PGSSLCOMPRESSION PGREQUIREPEER PGKRBSRVNAME PGKRBSRVNAME PGGSSLIB PGCONNECT_TIMEOUT PGCLIENTENCODING PGTARGETSESSIONATTRS \ | |
MYSQL_PWD MYSQL_HOST MYSQL_TCP_PORT \ | |
TNS_ADMIN TWO_TASK ORACLE_SID \ | |
ISC_USER ISC_PASSWORD \ | |
VSQL_HOST VSQL_PORT VSQL_USER VSQL_PASSWORD VSQL_SSLMODE \ | |
SNOWSQL_ACCOUNT SNOWSQL_USER SNOWSQL_PWD SNOWSQL_HOST SNOWSQL_PORT SNOWSQL_DATABASE SNOWSQL_REGION SNOWSQL_WAREHOUSE | |
do | |
if [ -n "${!var}" ]; then | |
passopt+=(-e $var) | |
fi | |
done | |
# Run the container with the current and home directories mounted. | |
docker run -it --rm --network host \ | |
--mount "type=bind,src=$(pwd),dst=/repo" \ | |
"${passopt[@]}" "$SQITCH_IMAGE" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment