This project is a simple SaaS Task Manager application built with a React.js frontend and a Node.js/Express backend, containerized using Docker. It allows users to create, read, update, and delete tasks via a web interface, with data stored persistently in a JSON file. This README guides you through setting it up locally in WSL and running it on your system.
~/JenkinsTask/
├── backend/ # Backend Node.js/Express API
│ ├── Dockerfile # Dockerfile for building the backend image
│ ├── app.js # Main backend application file (API logic)
│ ├── package.json # Node.js dependencies and scripts
│ ├── package-lock.json # Lock file for dependency versions
│ └── tasks.json # Persistent storage for tasks (generated at runtime)
├── frontend/ # Frontend React.js application
│ ├── Dockerfile # Dockerfile for building the frontend image
│ ├── package.json # React dependencies and scripts
│ ├── package-lock.json # Lock file for dependency versions
│ ├── public/ # Public assets (e.g., index.html, favicon)
│ └── src/ # React source files (App.js, App.css, etc.)
└── docker-compose.yml # Docker Compose configuration for multi-container setup
backend/Dockerfile: Defines the multi-stage build process for the Node.js backend, installing dependencies and setting up the runtime environment.backend/app.js: Implements the Express API with CRUD endpoints (GET /api/tasks,POST /api/tasks,PUT /api/tasks/:id,DELETE /api/tasks/:id) and file-based storage.backend/package.json: Lists dependencies (express,cors) and thestartscript.backend/tasks.json: Stores tasks persistently; initialized as an empty array ([]) if not present.frontend/Dockerfile: Uses a multi-stage build to compile the React app and serve it with Nginx.frontend/package.json: Specifies React dependencies (e.g.,axios) and build scripts.frontend/src/App.js: Core React component for displaying and managing tasks via API calls.docker-compose.yml: Configures the backend and frontend services, mapping ports and volumes.
- WSL (Ubuntu): Ensure you're running WSL 2 with Ubuntu installed.
- Docker: Installed and running in WSL.
- Docker Compose: Installed for multi-container management.
- Node.js: Optional (for manual setup outside Docker, not required with Docker).
- If cloning from a repository:
git clone <repository-url> ~/saas-task-manager cd ~/saas-task-manager
- If starting fresh, create the directory:
mkdir ~/saas-task-manager cd ~/saas-task-manager
- Note: Copy the project files (
backend/,frontend/,docker-compose.yml) into this directory.
- Note: Copy the project files (
- Install Docker:
sudo apt update sudo apt install docker.io -y sudo service docker start sudo usermod -aG docker $USER newgrp docker - Install Docker Compose:
sudo apt install docker-compose -y
- Verify:
docker --version docker-compose --version
The backend uses tasks.json for data persistence:
- Initialize the file:
echo "[]" > ~/saas-task-manager/backend/tasks.json chmod 666 ~/saas-task-manager/backend/tasks.json # Ensure write access
- Navigate to Project Root:
cd ~/saas-task-manager
- Build and Start Containers:
docker-compose up -d --build
--build: Builds fresh images from Dockerfiles.-d: Runs in detached mode (background).
- Verify Running Containers:
docker ps -a
- Expected Output:
CONTAINER ID IMAGE PORTS NAMES <id> saas-task-manager_frontend 0.0.0.0:8080->80/tcp saas-task-manager_frontend_1 <id> saas-task-manager_backend 0.0.0.0:5000->5000/tcp saas-task-manager_backend_1
- Expected Output:
- Backend API:
- List tasks:
curl localhost:5000/api/tasks
- Expected:
[](empty array initially).
- Expected:
- Add a task:
curl -X POST -H "Content-Type: application/json" -d '{"title":"Test Task"}' localhost:5000/api/tasks
- List tasks:
- Frontend UI:
- Open your browser at
http://localhost:8080. - Add a task via the input field—verify it appears in the list.
- Edit or delete tasks using the buttons (if implemented in
App.js).
- Open your browser at
- Access: The app runs on
http://localhost:8080(frontend) andhttp://localhost:5000(backend API). - Stopping: To stop the containers:
docker-compose down
- Add
-vto remove volumes:docker-compose down -v.
- Add
- Port Conflict:
- Error:
Bind for 0.0.0.0:5000 failed. - Fix: Check running containers (
docker ps), stop conflicting ones (e.g.,docker stop <id>), or change ports indocker-compose.yml(e.g.,"5001:5000").
- Error:
- 500 Error:
- Check logs:
docker logs saas-task-manager_backend_1. - Ensure
tasks.jsonexists and is writable (chmod 666 backend/tasks.json).
- Check logs:
- Frontend Not Loading:
- Verify
docker psshows both services; rebuild withdocker-compose up -d --build.
- Verify
- Docker Hub account (e.g., username
yourusername).
-
Tag Images:
- Backend:
docker tag saas-task-manager_backend yourusername/saas-task-backend:latest
- Frontend:
docker tag saas-task-manager_frontend yourusername/saas-task-frontend:latest
- Replace
yourusernamewith your Docker Hub username.
- Backend:
-
Log In to Docker Hub:
docker login
- Enter your username and password.
-
Push Images:
- Backend:
docker push yourusername/saas-task-backend:latest
- Frontend:
docker push yourusername/saas-task-frontend:latest
- Backend:
-
Verify:
- Visit
hub.docker.com/u/yourusernameto seesaas-task-backendandsaas-task-frontend.
- Visit
- Development: Use
docker-compose.ymlfor local dev; extend with a database (e.g., MongoDB) for production. - Best Practices: Multi-stage Dockerfiles optimize image size; volumes ensure data persistence.
Enjoy setting up and exploring your SaaS Task Manager!
Get the images here: https://hub.docker.com/repositories/pxkundu