Production-ready backend infrastructure with automated initialization using Init Container Pattern.
- π§ Init Container: Automatically sets up users, databases, and configurations
- π Elasticsearch: Search engine with custom users and roles
- π PostgreSQL: Primary database with application schemas
- π₯ Redis: Caching and session storage with ACL users
- π° RabbitMQ: Message broker with vhosts and users
- π Kibana: Elasticsearch dashboard
- π§ PgAdmin: PostgreSQL management interface
chmod +x manage.sh start.sh
./manage.sh start./manage.sh status./manage.sh logs # All services
./manage.sh logs-init # Init container onlyAll services are configured with restart: unless-stopped policy, which means:
- β Services automatically restart if they crash
- β Services automatically start when Docker daemon starts
- β Services automatically start after system reboot
- β Services will NOT restart if manually stopped with
docker stop
To enable automatic startup after system reboot:
# Make sure Docker starts on boot (usually already configured)
sudo systemctl enable docker
# Services will automatically start when Docker startsgit clone cd ecom-be-stack cp .env.example .env
2. **Edit credentials in `.env` file:**
- Replace all `your_*_here` placeholders with secure passwords
- Keep usernames or customize as needed
3. **Create network (optional, one-time):**
```bash
docker network create ecom-network
- Start all services:
./manage.sh start # Or using legacy docker.sh: ./docker.sh up
Primary management script:
./manage.sh start # Start all services with automatic setup
./manage.sh stop # Stop all services
./manage.sh restart # Restart all services
./manage.sh status # Show service status
./manage.sh logs # Follow logs from all services
./manage.sh clean # Clean containers/volumes (interactive)Linux/macOS:
./docker.sh up # Start all services (redirects to manage.sh)
./docker.sh down # Stop all services
./docker.sh logs # Follow logs
./docker.sh clean # Clean containers/volumes (interactive)Windows (PowerShell):
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
.\docker.ps1 up
.\docker.ps1 down
.\docker.ps1 logs
.\docker.ps1 clean# Start specific services
docker-compose up -d postgres redis
# View service logs
docker-compose logs -f elasticsearch
# Restart a service
docker-compose restart kibana
# Check service status
docker-compose ps| Service | Host Access | Management UI | Default Credentials |
|---|---|---|---|
| PostgreSQL | localhost:5443 |
PgAdmin: http://localhost:8081 |
See .env file |
| Redis | localhost:6390 |
- | See .env file |
| RabbitMQ | localhost:5683 |
http://localhost:15683 |
See .env file |
| Elasticsearch | localhost:9201 |
- | See .env file |
| Kibana | http://localhost:5602 |
Web UI | Use admin_ecom or dev_ecom |
| PgAdmin | http://localhost:8081 |
Web UI | See .env file |
elastic: Built-in superuser (full access)admin_ecom: Custom admin user (superuser privileges)dev_ecom: Developer user (limited access to ecom indices)kibana_system: Service account (for Kibana β Elasticsearch communication)
- Admin User: Full database access (migrations, maintenance)
- Developer User: Limited access (application runtime)
All sensitive data is configured via .env file:
- Database passwords
- Redis authentication
- RabbitMQ credentials
- Elasticsearch user passwords
- Kibana service credentials
- PgAdmin login
- Services communicate via internal Docker network
ecom-network - Only necessary ports are exposed to host
- Service-to-service authentication enabled
The backend application (ecom-backend) connects to these services using:
Development URLs (from host):
DATABASE_URL=postgresql://dev_user:password@localhost:5443/ecommerce_db
REDIS_URL=redis://dev_user:password@localhost:6390
RABBITMQ_URL=amqp://dev_user:password@localhost:5683/
ELASTICSEARCH_URL=http://dev_user:password@localhost:9201
Container-to-Container URLs:
DATABASE_INTERNAL_URL=postgresql://dev_user:password@postgres:5432/ecommerce_db
REDIS_INTERNAL_URL=redis://dev_user:password@redis:6379
RABBITMQ_INTERNAL_URL=amqp://dev_user:password@rabbitmq:5672/
ELASTICSEARCH_INTERNAL_URL=http://dev_user:password@elasticsearch:9200
Container startup failures:
# Check container status
docker-compose ps
# View logs for specific service
docker-compose logs service-name
# Restart problematic service
docker-compose restart service-nameNetwork connectivity issues:
# Verify network exists
docker network inspect ecom-network
# Connect container to network manually
docker network connect ecom-network container-namePort conflicts:
# Check what's using a port (macOS/Linux)
lsof -i :5443
# Windows
netstat -ano | findstr :5443Permission issues:
# Fix Docker permission issues (Linux)
sudo chown -R $USER:$USER .Elasticsearch:
curl -u "admin_ecom:password" http://localhost:9201/_cluster/healthPostgreSQL:
docker exec ecom-postgres pg_isready -U admin_ecom -d ecommerce_dbRedis:
docker exec ecom-redis redis-cli -a password pingAll services use Docker volumes for data persistence:
ecom_postgres_data: Database filesecom_redis_data: Redis snapshotsecom_rabbitmq_data: Queue dataecom_elasticsearch_data: Search indicesecom_pgadmin_data: PgAdmin configurations
# Database backup
docker exec ecom-postgres pg_dump -U admin_ecom ecommerce_db > backup.sql
# Elasticsearch backup
docker exec ecom-elasticsearch curl -X POST "localhost:9200/_snapshot/backup/snapshot_1"# Pull latest images
docker-compose pull
# Restart with new images
docker-compose up -d# Remove all containers and volumes (WARNING: DATA LOSS)
./docker.sh clean
# Manual cleanup
docker-compose down -v
docker system prune- PostgreSQL Documentation
- Redis Documentation
- RabbitMQ Documentation
- Elasticsearch Documentation
- Kibana Documentation
Need help? Check the troubleshooting section or create an issue in the repository.