Architecture
TODO
Microservice architecture with three main services intended to be deployed as Docker containers, either individually or with Kubernetes.
- Backend (api) Node.js server using express
- Frontend (spa - Single Page Application) React web GUI
- Repository (db) PostgreSQL database to persist data
Services
Section titled “Services”TODO: img
Backend / API
Section titled “Backend / API”…
…
Database
Section titled “Database”The service db in is given a name “katalogue_db” and the instruction to use an image of postgres called postgres-alpine. After that were adding a check to see if the server is up, this is needed for the following services. We’re creating some environment variables creating a admin user and password. We’re adding two volumes/folders in the docker container copying everything from the db catalog in our Katalogue sourcecode to an init folder into the image. We’re also coping a postgres sample database onto the image. The last thing is to expose port 5432 from the image to our local computer. What happens next is that Docker will set up the server and since we’ve added the sourcecode for the database into that init folder it will look for a shell file to initialize the database.
This file then logs on the newly created database with the user and password we created in docker-compose.yml and runs a file called installation_order.sql. This file just tells the order that the users, schemas, tables and views has to be created. We then create a demo database called dvdrental and restore a database from the file we copied to the image in the step before. When all this is done you now have a local postgres database that you can logon to using: