File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ username=db_username
21
21
password=db_password
22
22
database=db_name
23
23
hostname=localhost
24
+ port=5432
25
+
26
+ ;; These options are used for docker port redirection.
27
+ ;; env_hostname=POSTGRES_PORT_5432_TCP_PORT
28
+ ;; env_port=POSTGRES_PORT_5432_TCP_ADDR
24
29
25
30
;; If you have a Google Analytics account, put your information
26
31
;; in this section (optional)
Original file line number Diff line number Diff line change 6
6
"github.com/coopernurse/gorp"
7
7
_ "github.com/lib/pq"
8
8
"github.com/stevenleeg/gobb/config"
9
+ "os"
9
10
)
10
11
11
12
var db_map * gorp.DbMap
@@ -21,6 +22,17 @@ func GetDbSession() *gorp.DbMap {
21
22
db_hostname , _ := config .Config .GetString ("database" , "hostname" )
22
23
db_port , _ := config .Config .GetString ("database" , "port" )
23
24
25
+ db_env_hostname , _ := config .Config .GetString ("database" , "env_hostname" )
26
+ db_env_port , _ := config .Config .GetString ("database" , "env_port" )
27
+
28
+ // Allow database information to come from environment variables
29
+ if db_env_hostname != "" {
30
+ db_hostname = os .Getenv (db_env_hostname )
31
+ }
32
+ if db_env_port != "" {
33
+ db_port = os .Getenv (db_env_port )
34
+ }
35
+
24
36
if db_port == "" {
25
37
db_port = "5432"
26
38
}
You can’t perform that action at this time.
0 commit comments