This repository contains a CRUD (Create, Read, Update, Delete) backend built using Node.js Express and PostgreSQL. It provides a RESTful API for managing data in a PostgreSQL database.
- Create, Read, Update, and Delete operations for managing resources.
- Uses Node.js and Express for the backend server.
- PostgreSQL database for data storage.
- Dockerized for easy deployment.
- Node.js and npm installed locally.
- Docker installed
- Clone the repository:
git clone https://github.com/yourusername/your-repo.git
- Install dependencies
cd your-repo
npm install
Follow these steps to set up and run the backend:
Run the following command to build the Docker image:
sudo docker build -t <image_name> .
Replace <image_name>
with the desired name for your Docker image.
After building the image, you can verify it by running:
docker images
This command lists all Docker images on your system. Ensure that your newly built image is listed.
Use Docker Compose to start the containers defined in the docker-compose.yml
file:
docker-compose up
This command starts the Node.js Express backend and PostgreSQL database.
To clean up Docker resources and restart the server fresh, you can run:
docker system prune
Be cautious when using this command as it deletes all unused data (containers, networks, volumes, and images).
-
If you want to see all containers, including those that are not currently running, you can use the following command:
docker ps -a
This command lists all containers on your system, including stopped ones.
-
Make sure to configure your Node.js application to connect to the PostgreSQL database using the provided environment variables.
-
Replace placeholders such as
<image_name>
in the commands with appropriate values.