A full-featured Node.js CRUD API built with Express and PostgreSQL (Neon), which provides seamless Docker-based deployment. The CI/CD pipeline handles automated builds, tests, Docker image creation, and pushes to Docker Hub, making it easily deployable on any platform that supports Docker. Ideal for developers looking for a ready-to-use backend API with robust development, testing, and deployment workflows.
- Features
- Tech Stack
- Getting Started
- Environment Variables
- Running Tests
- API Endpoints
- Docker
- CI/CD Pipeline
- License
- π Full CRUD API for user management
- π PostgreSQL database integration (Neon)
- π¦ Dockerized for easy deployment
- βοΈ Jenkins for CI/CD pipeline
- π Environment variable support with
.envor Jenkins Secret Files - π§ͺ Automated testing with Jest and Supertest
Pipeline Overview |
The following technologies are used in this project:
- Backend: Node.js, Express, Joi, CORS, dotenv
- Database: PostgreSQL (Neon), @neondatabase/serverless
- Testing: Jest, Supertest
- Development Tools: Nodemon
- Containerization: Docker
- CI/CD: Jenkins
- Version Control: Git, GitHub
Follow the steps below to set up and run the project successfully:
https://github.com/PAIshanMadusha/node-docker-jenkins-cicd-pipeline.gitcd node-docker-jenkins-cicd-pipelinenpm installGo to Neon and sign in or create an account. Create a new project and copy your ** π database connection details** from the dashboard.
PORT=3000
PGUSER=your_db_user
PGPASSWORD=your_db_password
PGHOST=your_db_host
PGDATABASE=your_db_nameInformation About Environment Variables
| Variable | Description |
|---|---|
PORT |
Port number for API server |
PGUSER |
PostgreSQL username |
PGPASSWORD |
PostgreSQL password |
PGHOST |
PostgreSQL host URL |
PGDATABASE |
PostgreSQL database name |
npm run devServer is running on port: 3000
User Table Created If Not Exists!
npm testReplace
:idwith the actual user ID. Test endpoints using Postman, Insomnia, or any API client athttp://localhost:3000.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users |
Retrieve all users |
| GET | /api/users/:id |
Retrieve a user by ID |
| POST | /api/users |
Create a new user |
| PUT | /api/users/:id |
Update an existing user |
| DELETE | /api/users/:id |
Delete a user |
This project is fully containerized. You can run it directly from Docker Hub without building locally, and Make sure you have Docker Desktop (or Docker Engine) running on your system.
docker pull ishanmadusha/node-docker-jenkins-cicd-pipeline:latestdocker run -d --name node-crud-app --env-file .env -p 3000:3000 ishanmadusha/node-docker-jenkins-cicd-pipeline:latestπ Test the App: Visit: http://localhost:3000
This project includes a fully automated CI/CD pipeline defined in the Jenkinsfile for a Node.js application using Docker on Windows. The pipeline handles building, testing, Docker image creation, pushing to Docker Hub, and deploying the container.
Install or open Jenkins and try building your own pipeline on your machine.
3. Run Tests: Runs automated tests to ensure the project is working correctly without breaking existing functionality.
4. Build Docker Image: Builds a Docker image for the application. Replace the Docker Hub username in the Jenkinsfile with your own credentials.
6. Push Docker Image: Pushes the built Docker image to your Docker Hub repository, including a latest tag for convenience.
7. Deploy the Container: Deploys the Docker container using the pushed image. The container runs with environment variables stored securely
Ishan Madhusha
GitHub: PAIshanMadusha
Feel free to explore my work and get in touch if you'd like to collaborate! π
This project is licensed under the MIT License : See the LICENSE file for details.
