Skip to content

Commit 318d812

Browse files
author
Matthew Fisher
committed
feat(docker-entrypoint): read username and password from file
These files are injected in from kubernetes secrets
1 parent c1cb835 commit 318d812

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
contrib/ci/tmp

contrib/ci/test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ set -x
55

66
JOB=$(docker run -d $1)
77
# wait for postgres to boot
8+
CURRENT_DIR=$(cd $(dirname $0); pwd)
9+
mkdir -p $CURRENT_DIR/tmp
10+
echo "testuser" > $CURRENT_DIR/tmp/user
11+
echo "icanttellyou" > $CURRENT_DIR/tmp/password
12+
JOB=$(docker run -dv $CURRENT_DIR/tmp:/var/run/secrets/deis/database/creds $1)
813
sleep 10
914
docker exec $JOB is_master
1015
docker rm -f $JOB

rootfs/docker-entrypoint.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
#
3-
# Copied from https://github.com/docker-library/postgres/blob/ec5ce80ca914e02c2d5eb9fde424039d4cee032e/9.4/docker-entrypoint.sh
3+
# Originally copied and modified from
4+
# https://github.com/docker-library/postgres/blob/ec5ce80ca914e02c2d5eb9fde424039d4cee032e/9.4/docker-entrypoint.sh
45
#
56
set -e
67

@@ -9,6 +10,9 @@ set_listen_addresses() {
910
sed -ri "s/^#?(listen_addresses\s*=\s*)\S+/\1'$sedEscapedValue'/" "$PGDATA/postgresql.conf"
1011
}
1112

13+
POSTGRES_USER="$(cat /var/run/secrets/deis/database/creds/user)"
14+
POSTGRES_PASSWORD="$(cat /var/run/secrets/deis/database/creds/password)"
15+
1216
if [ "$1" = 'postgres' ]; then
1317
mkdir -p "$PGDATA"
1418
chmod 700 "$PGDATA"

0 commit comments

Comments
 (0)