Technical monitoring - Manage your technical ressources from the Web
This Web app is based on the following technologies and patterns:
- Postgres
- React & Redux
- Node.js & Express
- REST API
- Docker (for storage)
- Javascript modern tooling (Webpack, Babel, etc.)
- JWT (JSON Web Token)
⚠️ This app is not perfect in many respects. I use it as an experimentation field for my training in technologies and concepts quite new for me (Single Page App, Server Side Rendering, ES6, React/Redux, Node/Express, Docker, Webpack, etc.)
This project embeds a Dockerfile
that creates a new Docker image based on the Postgres:9.6
official image and runs some bootstrapping SQL scripts (from the docker/Postgres/src folder). These scripts execute the following commands during container build :
- create an
app
DB user (passwordapp
) - create an
app
database - create an
app_test
database - create a
model
schema in each database - grant all permissions to
app
user for each database
Ref.: https://docs.docker.com/engine/examples/postgresql_service/
⚠️ The container maps the localvar/pgdata
folder to container's data folder. You may have to run the following command before running the container:
## cd to project's root directory:
cd <PROJECT_ROOT_DIR>
mkdir -p var/pgdata
- Build the Postgres DB image:
## Change directory where the Postgres Dockerfile is:
cd docker/Postgres
## Build the image:
docker build -t my-tech-monitoring-db .
- Start the DB container :
npm run start-db
Here are some useful commands for Docker & Postgres (as a reminder) :
#############
## Reminder #
#############
## List Docker images:
docker images
## Remove an image:
docker rmi <imageId>
## List all Docker containers:
docker ps -a
## List all started containers:
docker ps
## Remove a container :
docker rm <containerId>
## Show logs for a given container :
docker logs <containerId>
## End of reminder
## Start the database container as daemon:
npm run start-db
## [Optional, for demo purposes only] Start the container once again in TTY mode in order to connect to the database through PSQL :
## Nota: Password for `postgres` role is `postgres`
docker run -it --rm --name my-tech-monitoring-db-cli --link my-tech-monitoring-db-server:db-server my-tech-monitoring-db psql -h db-server -d app -U postgres
## List tables (relations) in `model` schema :
$ postgres=# \dt model.*
## Show `model.techresources` table's structure :
$ postgres=# \d+ model.techresources
## Show `model.techresources` table's content :
$ postgres=# select * from model.techresources;
## Running migrations
./node_modules/.bin/knex migrate:latest --env <development|test>
## Running seeders (fixtures)
./node_modules/.bin/knex seed:run --env <development|test>