This is a ERP backend repository using NestJS, PostgreSQL, Prisma and Docker.
Prerequisites: You have to have installed Postgres in your machine.
- Create a
.env
file at the root and add essential environment variables from.env.example
file - Run
npm install
oryarn
- Now to run the app in the Dev Environment run
npm run start:dev
oryarn start:dev
- For production, first build using
npm run build
oryarn build
and then runnpm start
oryarn start
- Now the server should listen on
http://localhost:8000
based on the port number you set in.env
Prerequisites: You have to have installed Docker and Docker-compose in your computer
- Create a
.env
file at the project root and add essential environment variables from.env.example
file - Open any command line tool in your computer like for Windows
Git Bash
, for LinuxTerminal
orTerminator
, and for MaciTerm2
, and so on. - Change directory to this project in which location you have for example
cd ~/www/ERP-API-nestjs-postgreSQL-prisma
- Now run
docker compose up
ordocker-compose up
if you installed docker compose separately - Now the server should listen on
http://localhost:8000
based on the port number you set in.env
- To delete all the Containers, Images and Volumes:
docker system prune --volumes -af
- To delete all the Networks:
docker network prune -f
- To delete all containers including its volumes:
docker rm -vf $(docker ps -aq)
- To delete all the images:
docker rmi -f $(docker images -aq)
- To delete specific Container:
docker rm container_id1, container_id2...
- To delete specific Images:
docker rmi image_id1, image_id2...
- To delete specific Networks:
docker network rm network_id1, network_id2...
- To delete specific Volumes:
docker volume rm volume_id1, volume_id2...
- HR
- Inventory
- Online Exam
- Admission Management System
- E-commerce
- Create employee
- Update employee
- Get all employee
-
If you see the following error message while running
npm run migrate:dev
script command ornpx prisma migrate dev
command then create the shadow database manually by using command Line or a database query client like DBeaver, HeidiSQL, pgAdmin, and so on.Error: Database "apierp_shadow_db" does not exist on the database server at "localhost:5432".
- Alternatively you can just run this command
sudo chmod +x init-multiple-dbs.sh
before runningdocker compose up
to give the permission to the container for running the custom script so that it can create the shadow database for prisma.
- Alternatively you can just run this command
-
If you see this
Error: P1001: Can't reach database server at "postgres:5432"
error message while runningnpm run migrate:dev
script command ornpx prisma generate
ornpx prisma migrate dev
command to perform Prisma migrations locally then you can replace the value ofPOSTGRES_HOST
withlocalhost
likePOSTGRES_HOST=localhost
in.env
file.N.B: Please keep in mind, before running
docker compose up
first the value of thePOSTGRES_HOST
env variable should bepostgres
because, inside docker, services communicate with each other with their container name as the hostname like when we'll rundocker compose up
, ournest-app
service will be connected withpostgres
service throughhttp://postgres:5432
.- Alternatively you can run the command from the container by using this command
docker exec -it nest-app bash
- Alternatively you can run the command from the container by using this command