Frictionless Local Postgres with Docker Compose

PostgreSQL is a very powerful open source database that is available everywhere from a developer laptop to cloud providers. I have been using PostgreSQL for decades starting in 1998. I am always looking for ways to optimize my dev workstation configuration.

PgAdmin 4 is the graphical interface for working with Postgres. It is is a single page web application written in JavaScript that talks to a backend written in python. Using docker-compose it is possible to run both pgAdmin and postgres inside docker, as shown in the diagram below.

final configuration: apps, containers, virtual machines on a developer workstation

Because pgAdmin runs as a server it asks for a username/password to access the UI. After logging in to pgAdmin you have to setup a connection to the database that you want administer. The login and connection setup are annoying when developing locally.

Setting up pgAdmin with pre-configured connectivity and passwords is tricky. It requires in depth understanding of docker, docker-compose, shell scripting, and how pgAdmin works. I put together an example implementation at https://github.com/asaikali/docker-compose-postgres with all the gory technical details explained in the repository’s readme.md file.

Storing JKS files in Spring Cloud Config Sever

A customer asked me how they can store a JKS file with certificates in a spring cloud config server, retrieve it on application startup and use it to setup a a Java SSLContext for doing mutual TLS with a backend system, that was using self signed certificates.

The config server can’t store binary files, so you have to first encode the JKS file as a base64 string, put in the config server then pull it at startup with regular Spring @Value annotation which is then used to setup the context. I created a sample application which you can find at https://github.com/asaikali/mtls-demo