Skip to content

Commit

Permalink
Binding IP of PG container is now configurable
Browse files Browse the repository at this point in the history
Replace `PSQL_SC_BIND_EXTERNAL` with `PSQL_SC_BIND_IP`. See README for
instructions.

Closes #10
  • Loading branch information
Flink committed Aug 3, 2015
1 parent a4658b8 commit f6d46eb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ If you are using custom `PSQL_SC_ROOT` directory, make sure it is writable by
dokku config:set --global PSQL_SC_ROOT=/my/custom/path
```

### Binding Postgresql port to all interfaces
### Binding Postgresql port to another IP

By default, the container is not reachable from outside. The container can be
reachable publicly by setting `PSQL_SC_BIND_EXTERNAL` to true in the global
dokku config.
bound to an IP of your choice by setting `PSQL_SC_BIND_IP` to an IP in the
global dokku config.

```bash
dokku config:set --global PSQL_SC_BIND_EXTERNAL=true
dokku config:set --global PSQL_SC_BIND_IP=0.0.0.0
```

## Commands
Expand Down
2 changes: 1 addition & 1 deletion commands
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ case "$1" in
exit 0
fi
dokku_log_info1 "Starting Postgresql server"
docker run $(bind_external_options) -d -v "$PSQL_ROOT/data:/var/lib/postgresql/data" --name "$PSQL_CONTAINER_NAME" "$PSQL_IMAGE" > /dev/null
docker run $(bind_ip_options) -d -v "$PSQL_ROOT/data:/var/lib/postgresql/data" --name "$PSQL_CONTAINER_NAME" "$PSQL_IMAGE" > /dev/null
;;

psql:restart)
Expand Down
8 changes: 4 additions & 4 deletions functions
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ export_psql_root() {
export PSQL_ROOT
}

bind_external_options() {
local BIND_EXTERNAL=$(dokku config:get --global PSQL_SC_BIND_EXTERNAL)
if [[ $BIND_EXTERNAL = 'true' ]]; then
echo "-p 0.0.0.0:$PSQL_PORT:$PSQL_PORT"
bind_ip_options() {
local BIND_IP=$(dokku config:get --global PSQL_SC_BIND_IP)
if [[ -n $BIND_IP ]]; then
echo "-p $BIND_IP:$PSQL_PORT:$PSQL_PORT"
else
echo ''
fi
Expand Down
2 changes: 1 addition & 1 deletion install
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ mkdir -p "$PSQL_ROOT/data"
chown dokku:dokku -R "$PSQL_ROOT" &> /dev/null || true
PASSWORD=$(openssl rand -hex 32)
export_psql_image
docker run $(bind_external_options) -v "$PSQL_ROOT/data":/var/lib/postgresql/data -d -e POSTGRES_PASSWORD=$PASSWORD --name "$PSQL_CONTAINER_NAME" "$PSQL_IMAGE"
docker run $(bind_ip_options) -v "$PSQL_ROOT/data":/var/lib/postgresql/data -d -e POSTGRES_PASSWORD=$PASSWORD --name "$PSQL_CONTAINER_NAME" "$PSQL_IMAGE"

0 comments on commit f6d46eb

Please sign in to comment.