Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (40 sloc) 3.05 KB

ContactForm.Sample

These 2 projects are sample ASP.NET Core microservices build on top of ContactForm project. First one, ContactForm.Sample (see readme.md file) is only displaying 2 contact forms, one that uses C# and the other using JavaScript (AJAX) to call second project, Contactform.Sample.Postgres (see readme.md file), to save data.

The goal of these projects are simply to try using RESTful API over HTTP calls, using Docker Compose and Kubernetes.

ContactForm.Sample diagram

Here's a screenshot of the main page:

ContactForm.Sample main page

Docker compose

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:

.\build.ps1

Then just a simple

docker-compose up -d

The images are also available on Docker Hub here and here:

docker pull ovicrisan/contactformsample
docker pull ovicrisan/contactformsamplepg

Postgres image

To test with Postgres database you have the option to install it locally from postgresql.org/download or just use Docker image from hub.docker.com/_/postgres:

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.

Read more:

You can’t perform that action at this time.