The goal of these projects are simply to try using RESTful API over HTTP calls, using Docker Compose and Kubernetes.
Here's a screenshot of the main page:
The docker-compose.yml file starts 3 services: (1) main web form to collect data, (2) RESTful API to save data (in this case in a Postgres database), and (3) Postgres service itself.
All containers are named and then uses environment variables to set API Endpoint and DB connection string.
To build all images from the provided Dockerfile use build.ps1 script, from root folder like this:
Then just a simple
docker-compose up -d
docker pull ovicrisan/contactformsample docker pull ovicrisan/contactformsamplepg
docker pull postgres
Latest is version 12, but to have it working on Windows 10 I used the trick from here:
docker create -v /var/lib/postgresql/data --name pgdataalpine alpine docker run --rm --name postgres -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 --volumes-from pgdataalpine postgres
This create a volume in an Alpine image used by Postgres to store the data, persistently. Other methods to directly map a local volume to /var/lib/postgresql/data failed with some permission errors, so in the end I just used Eric's suggestion.