File tree Expand file tree Collapse file tree 5 files changed +43
-0
lines changed Expand file tree Collapse file tree 5 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ dokku postgres:info lolipop
7575# you can also retrieve a specific piece of service info via flags
7676dokku postgres:info lolipop --data-dir
7777dokku postgres:info lolipop --dsn
78+ dokku postgres:info lolipop --exposed-dsn
7879dokku postgres:info lolipop --exposed-ports
7980dokku postgres:info lolipop --id
8081dokku postgres:info lolipop --internal-ip
@@ -265,6 +266,27 @@ The `import` command should be used with any non-plain-text files exported by `p
265266dokku postgres:connect db < ./dump.sql
266267```
267268
269+ ## Exposed DSN
270+
271+ ``` shell
272+ # expose the database (you must open the exposed port on your firewall if you have one)
273+ dokku postgres:expose lolipop
274+
275+ # exposed dsn available on service info
276+ dokku postgres:info lolipop
277+ =====> Container Information
278+ ...
279+ Exposed dsn: postgres://postgres:SOME_PASSWORD@dokku.me:28804/lolipop
280+ Exposed ports: 5432-> 28804
281+ ...
282+ ```
283+
284+ So now you connect to your database with [ ` pgcli ` ] ( https://www.pgcli.com/ ) or with your favorite app.
285+
286+ ``` shell
287+ pgcli $( ssh dokku@dokku.me postgres:info lolipop --exposed-dsn)
288+ ```
289+
268290## Security
269291
270292The connection to the database is done over SSL. A self-signed certificate is
Original file line number Diff line number Diff line change @@ -340,6 +340,7 @@ service_info() {
340340 " --config-dir: ${SERVICE_ROOT} /config"
341341 " --data-dir: ${SERVICE_ROOT} /data"
342342 " --dsn: ${SERVICE_URL} "
343+ " --exposed-dsn: ${service_exposed_url " $SERVICE " } "
343344 " --exposed-ports: $( service_exposed_ports " $SERVICE " ) "
344345 " --id: ${SERVICE_CONTAINER_ID} "
345346 " --internal-ip: $( get_container_ip " ${SERVICE_CONTAINER_ID} " ) "
Original file line number Diff line number Diff line change @@ -152,3 +152,18 @@ service_url() {
152152 local SERVICE_DNS_HOSTNAME=" $( service_dns_hostname " $SERVICE " ) "
153153 echo " $PLUGIN_SCHEME ://postgres:$PASSWORD @$SERVICE_DNS_HOSTNAME :${PLUGIN_DATASTORE_PORTS[0]} /$DATABASE_NAME "
154154}
155+
156+ service_exposed_url () {
157+ local SERVICE=" $1 "
158+ local SERVICE_ROOT=" $PLUGIN_DATA_ROOT /$SERVICE "
159+ local PORT_FILE=" $SERVICE_ROOT /PORT"
160+ [[ ! -f $PORT_FILE ]] && echo ' -' && return 0
161+ local GLOBAL_VHOST_FILE=" $DOKKU_ROOT /VHOST"
162+ [[ ! -f $GLOBAL_VHOST_FILE ]] && echo ' -' && return 0
163+
164+ local PORTS=($( cat " $PORT_FILE " ) )
165+ local PASSWORD=" $( cat " $SERVICE_ROOT /PASSWORD" ) "
166+ local DATABASE_NAME=" $( get_database_name " $SERVICE " ) "
167+ local GLOBAL_VHOSTS=($( cat " $GLOBAL_VHOST_FILE " ) )
168+ echo " $PLUGIN_SCHEME ://postgres:$PASSWORD @${GLOBAL_VHOSTS[0]} :${PORTS[0]} /$DATABASE_NAME "
169+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ service-info-cmd() {
1111 # E dokku $PLUGIN_COMMAND_PREFIX:info lolipop --config-dir
1212 # E dokku $PLUGIN_COMMAND_PREFIX:info lolipop --data-dir
1313 # E dokku $PLUGIN_COMMAND_PREFIX:info lolipop --dsn
14+ # E dokku $PLUGIN_COMMAND_PREFIX:info lolipop --exposed-dsn
1415 # E dokku $PLUGIN_COMMAND_PREFIX:info lolipop --exposed-ports
1516 # E dokku $PLUGIN_COMMAND_PREFIX:info lolipop --id
1617 # E dokku $PLUGIN_COMMAND_PREFIX:info lolipop --internal-ip
@@ -22,6 +23,7 @@ service-info-cmd() {
2223 # F --config-dir, show the service configuration directory
2324 # F --data-dir, show the service data directory
2425 # F --dsn, show the service DSN
26+ # F --exposed-dsn, show the exposed service DSN (you must expose the service first)
2527 # F --exposed-ports, show service exposed ports
2628 # F --id, show the service container id
2729 # F --internal-ip, show the service internal ip
Original file line number Diff line number Diff line change @@ -47,6 +47,9 @@ teardown() {
4747 run dokku " $PLUGIN_COMMAND_PREFIX :info" l --dsn
4848 assert_success
4949
50+ run dokku " $PLUGIN_COMMAND_PREFIX :info" l --exposed-dsn
51+ assert_success
52+
5053 run dokku " $PLUGIN_COMMAND_PREFIX :info" l --exposed-ports
5154 assert_success
5255
You can’t perform that action at this time.
0 commit comments