Overview
The Product Distribution Dashboard can be quickly deployed using Docker Compose, which orchestrates all required services including the backend, frontend, PostgreSQL database, and pgAdmin.Prerequisites
Before starting, ensure you have the following installed:Docker
Install Docker Desktop or Docker Engine (version 20.10 or higher)
Docker Compose
Docker Compose is included with Docker Desktop. For standalone installations, install Docker Compose v2.0 or higher.
Docker Compose Configuration
The application uses a multi-service Docker Compose setup with the following architecture:Services Overview
PostgreSQL Database
PostgreSQL Database
Image:
postgres:16-alpineContainer Name: product-distribution-postgresPort: 5432:5432The PostgreSQL database stores all product distribution data including products, stores, warehouses, and distribution records.Environment Variables:POSTGRES_DB: product_distribution_dbPOSTGRES_USER: product_distributionPOSTGRES_PASSWORD: product_distribution
Backend Service
Backend Service
Build Context: Root directory with
backend/DockerfileContainer Name: product-distribution-backendPort: 8080:8080Spring Boot backend built with Java 17 and Maven. Includes health checks via Spring Boot Actuator.Environment Variables:SPRING_PROFILES_ACTIVE: devSPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/product_distribution_dbSPRING_DATASOURCE_USERNAME: product_distributionSPRING_DATASOURCE_PASSWORD: product_distributionAPP_FRONTEND_URL: http://localhost:4200
Frontend Service
Frontend Service
Build Context:
frontend/ directoryContainer Name: product-distribution-frontendPort: 4200:4200Angular 18 application with Node.js 20. Runs in development mode with hot reload enabled.Dependencies: Starts after backend service.pgAdmin
pgAdmin
Image:
dpage/pgadmin4Container Name: pgadminPort: 5050:80Web-based PostgreSQL administration tool for database management.Environment Variables:PGADMIN_DEFAULT_EMAIL: [email protected]PGADMIN_DEFAULT_PASSWORD: admin
Installation Steps
Start All Services
Run Docker Compose to build and start all services:
The
--build flag ensures images are rebuilt if there are any code changes. For subsequent runs without code changes, you can omit this flag.Wait for Services to Start
Monitor the logs to ensure all services start successfully:
- PostgreSQL health check passes
- Backend connects to database and starts on port 8080
- Frontend compiles and serves on port 4200
Verify Installation
Access the services to confirm they’re running:
- Frontend: http://localhost:4200
- Backend API: http://localhost:8080/actuator/health
- pgAdmin: http://localhost:5050
Access Points
Once all services are running, you can access:| Service | URL | Description |
|---|---|---|
| Frontend Dashboard | http://localhost:4200 | Main application interface |
| Backend API | http://localhost:8080 | REST API endpoints |
| Health Check | http://localhost:8080/actuator/health | Backend health status |
| pgAdmin | http://localhost:5050 | Database management interface |
| PostgreSQL | localhost:5432 | Direct database connection |
pgAdmin Configuration
To connect to the PostgreSQL database from pgAdmin:Login to pgAdmin
- URL: http://localhost:5050
- Email: [email protected]
- Password: admin
Managing Services
Start Services in Background
Stop Services
Stop Services and Remove Volumes
View Logs
Restart a Service
Rebuild a Service
Troubleshooting
Port Already in Use
Error:Bind for 0.0.0.0:8080 failed: port is already allocated
Solution: Check which process is using the port and stop it:
docker-compose.yml:
Backend Cannot Connect to Database
Symptoms: Backend logs show connection errors to PostgreSQL Solution:-
Check if PostgreSQL container is healthy:
-
Verify database logs:
-
Ensure the backend waits for database health check:
Container Keeps Restarting
Solution:-
Check container logs:
-
Inspect container status:
-
Common causes:
- Missing environment variables
- Port conflicts
- Build errors
- Insufficient resources
Database Connection Pool Exhausted
Symptoms: Backend logs show “Connection pool exhausted” errors Solution: Increase the connection pool size by setting environment variables:Out of Memory Errors
Solution: Increase Docker memory allocation:- Docker Desktop: Settings → Resources → Memory → Increase to 4+ GB
- Linux: Adjust Docker daemon settings
Clean Build Issues
Solution: Remove all containers, images, and volumes for a fresh start:Volume Management
The PostgreSQL data is persisted in a named volume:Backup Database Volume
Restore Database Volume
Next Steps
Local Development
Set up the project for local development without Docker
Deployment
Deploy the application to production environments