We use Postgres and Docker, where I work, and we finished the following:
At the top of docker -entrypoint.sh, I add the following:
# Get the schema url=$(curl -s -u ${GIT_USER}:${GIT_PASSWORD} "${SQL_SCRIPT_URL}" | python -c 'import sys, json; print json.load(sys.stdin)["download_url"]') curl ${url} > db.sh chmod +x db.sh cp db.sh ./docker-entrypoint-initdb.d
Basically the shell script from Github is loaded, which initializes the schema for the database. We do this for version control of the circuit, so when you start your container, you can tell which circuit to use with the ENV variable.
Some notes about the code:
- We need to reorganize to pull stuff out of Github using a private key instead of user credentials.
- Catalog. / docker -entrypoint-initdb.d is the place where docker -entrypoint.sh will look for starting init scripts for the database. You can move files to this place as you want. Do this if downloading from Github is not applicable.
source share