UPDATE
I believe I resolved this issue with this connection...
db, err := gorm.Open("postgres", "host='postgres'&user:docker&port=5432&dbname='docker'&password='password'&sslmode=disable")
I am getting a connection refused between a Docker PG container and a GoLang Scratch container. The error is:
============ exiting ==========
todo_1 | pq: SSL is not enabled on the server
todo_1 | panic: failed to connect database e
The main.go file which is panicking
Complete code base with Docker files
OTHER NOTE:
- I am using GORM library to connect with PG.
REQUEST: Please look over code and give some hints on where and how to resolve this SSL issue.
You can follow the code to find the documentation on how to use the Postgres calls.
And lib/pq documents it's usage including:
And:
So your connect string for a database without SSL is simply:
Or you could configure Postgres with an SSL key. That's less trivial, but to implement you'd need to modify the postgresql.conf file to enable the ssl settings and mount the TLS key pair as a volume, or preferably a secret with swarm mode. One of the many examples of how to do this can be found at: https://gist.github.com/likwid/86193ef581c530ea55d3