I'll keep this short.
In official docker image, there's already built-in SSL keys ready. We just need to tell Postgres to use it by adding the following section into the docker-compose file:
image: postgres:xxx
...
command: >
    -c ssl=on 
    -c ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
    -c ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.keyIf you are using CapRover, adding the above lines won't work. You will have to use a custom Dockerfile instead. For example:
FROM postgres:14
CMD ["postgres", "-c", "ssl=on", "-c", "ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem", "-c", "ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key" ]The easiest way would be: pasting the above dockerfile into Deployment > Method 4 section of your Postgres app and deploy it.
