Skip to content

Commit

Permalink
Feat/support postgres password file (#11)
Browse files Browse the repository at this point in the history
* feat: add support for postgres password file (docker secret)

* docs: update docs

* fix: read POSTGRES_PASSWORD from file first

* fix: fix env var name

* change: update support for POSTGRESQL_PASSWORD_FILE
  • Loading branch information
opichon authored Jun 11, 2022
1 parent 6d0aa25 commit 63d7b1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Available environment variables
- POSTGRESQL\_CONNECTION\_URI
- POSTGRESQL\_USER
- POSTGRESQL\_PASSWORD
- POSTGRESQL\_PASSWORD\_FILE
- POSTGRESQL\_CONNECTION\_POOL\_SIZE
- POSTGRESQL\_HOST
- POSTGRESQL\_PORT
Expand Down Expand Up @@ -101,4 +102,4 @@ docker run \
## Database setup
- Before you start this container, make sure to initialize your database.
- You do not need to ensure that the Postgresql database has started before this container is started. During bootup, SuperTokens will wait for ~1 hour for a Postgresql instance to be available.
- If `POSTGRESQL_USER`, `POSTGRESQL_PASSWORD` and `POSTGRESQL_CONNECTION_URI` are not provided, then SuperTokens will use an in memory database.
- If `POSTGRESQL_USER`, `POSTGRESQL_PASSWORD`, `POSTGRESQL_PASSWORD_FILE` and `POSTGRESQL_CONNECTION_URI` are not provided, then SuperTokens will use an in memory database.
8 changes: 7 additions & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ then
echo "postgresql_user: $POSTGRESQL_USER" >> $CONFIG_FILE
fi

if [ ! -z $POSTGRESQL_PASSWORD_FILE ]
then
POSTGRESQL_PASSWORD=$(cat "$POSTGRESQL_PASSWORD_FILE")
export POSTGRESQL_PASSWORD
fi

# verify postgresql password is passed
if [ ! -z $POSTGRESQL_PASSWORD ]
then
Expand Down Expand Up @@ -292,4 +298,4 @@ if [ "$(id -u)" = "0" ] && [ "$1" = 'supertokens' ]; then
exec gosu supertokens "$@"
else
exec "$@"
fi
fi

0 comments on commit 63d7b1f

Please sign in to comment.