A scalable infrastructure that dynamically provisions isolated PrestaShop e-commerce instances with automated deployment, containerization, and database management.
- Multi-tenant Architecture: Each store runs in isolated Docker containers with dedicated databases
- Automated Deployment: Deploy fully functional PrestaShop instances in under 2 minutes
- Dynamic Port Allocation: Automatic port discovery starting from 8081
- Containerized Isolation: Dedicated MySQL database for each tenant
- Scalable Design: Support for hundreds of isolated stores
- Simple Management: Clean web interface for store creation
Frontend (Next.js) β Backend (Flask) β Docker Engine β PrestaShop + MySQL Containers
Each tenant gets:
- Dedicated PrestaShop container
- Isolated MySQL database
- Unique port assignment
- Separate Docker network
- Backend: Flask, Python
- Frontend: Next.js, React, TypeScript, Tailwind CSS
- Containerization: Docker, Docker Compose
- Database: MySQL 5.7
- E-commerce: PrestaShop 8.1.6
- Docker & Docker Compose
- Python 3.8+
- Node.js 18+
- Clone the repository
git clone https://github.com/aryanrangapur/Multi-Tenant-PrestaShop-SaaS-Server.git
cd Multi-Tenant-PrestaShop-SaaS-Server- Start the Backend
cd backend
python -m venv venv
# On Windows:
venv\Scripts\activate
# On Mac/Linux:
source venv/bin/activate
pip install -r requirements.txt
python app.py- Start the Frontend (in a new terminal)
cd frontend
npm install
npm run dev- Access the Application
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
- Health Check: http://localhost:5000/health
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down-
Launch EC2 Instance
- AMI: Amazon Linux 2023
- Instance Type: t3.medium (minimum)
- Storage: 30GB+
- Security Group: Open ports 22, 3000, 5000, 8081-8100
-
Deploy with One Command
# Connect to your EC2 instance
ssh -i your-key.pem ec2-user@YOUR_EC2_IP
# Install Docker and deploy
sudo yum update -y
sudo yum install docker -y
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -a -G docker ec2-user
# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# Clone and deploy
git clone https://github.com/aryanrangapur/Multi-Tenant-PrestaShop-SaaS-Server.git
cd Multi-Tenant-PrestaShop-SaaS-Server
docker-compose up -d- Access Your Application
- Frontend: http://YOUR_EC2_IP:3000
- Backend API: http://YOUR_EC2_IP:5000
- Stores: http://YOUR_EC2_IP:8081, http://YOUR_EC2_IP:8082, etc.
-
Access the frontend at http://localhost:3000
-
Enter admin credentials (email and password) for your new store
-
Click "Deploy Store" - the system will:
- Create isolated Docker containers
- Setup MySQL database
- Configure PrestaShop
- Return store URLs
-
Access your store using the provided URLs:
- Store Frontend:
http://localhost:8081(or assigned port) - Admin Panel:
http://localhost:8081/admin-xxxx
- Store Frontend:
POST /create-store
Content-Type: application/json
{
"email": "[email protected]",
"password": "securepassword"
}Response:
{
"url": "http://localhost:8081",
"admin_url": "http://localhost:8081/admin123",
"admin_email": "[email protected]",
"admin_password": "securepassword"
}GET /healthResponse:
{
"status": "healthy"
}Multi-Tenant-PrestaShop-SaaS-Server/
βββ backend/
β βββ app.py # Flask backend server
β βββ requirements.txt # Python dependencies
β βββ Dockerfile # Backend container definition
β βββ .env.example # Environment variables template
βββ frontend/
β βββ app/
β β βββ layout.tsx # Root layout
β β βββ page.tsx # Main page component
β β βββ globals.css # Global styles
β βββ package.json # Node.js dependencies
β βββ Dockerfile # Frontend container definition
β βββ tailwind.config.js # Tailwind CSS configuration
β βββ .env.example # Environment variables template
βββ docker-compose.yml # Multi-container setup
βββ README.md # This file
βββ .gitignore # Git ignore rules
- Port: 5000
- Environment: BASE_PORT, TENANTS_DIR
- Volumes: Docker socket, tenants directory
- Port: 3000
- Environment: BACKEND_URL
- Depends on: Backend service
- Port Range: 8081-8100+
- Services: PrestaShop + MySQL per store
- Networks: Isolated per tenant
BASE_PORT=8081
TENANTS_DIR=./tenantsNEXT_PUBLIC_BACKEND_URL=http://localhost:5000# Stop all services (preserves data)
docker-compose down
# Stop and remove all data (β οΈ Destructive)
docker-compose down -v
# Clean up individual tenant
cd backend/tenants/tenantX
docker-compose down -v# Application logs
docker-compose logs -f
# Individual store logs
docker logs tenant1_shop
docker logs tenant1_db- Docker must be running before creating stores
- Ports 8081-8100 should be available for store instances
- Admin credentials are stored in the database - use strong passwords
- Data persistence uses Docker volumes - backup regularly
- For production: Add SSL, authentication, and monitoring
- Wait 1-2 minutes for full initialization
- Check Docker container status:
docker ps - View container logs:
docker logs container_name
- The system automatically finds the next available port
- Ensure ports 8081-8100 are not occupied by other services
- Ensure Docker and Docker Compose are properly installed
- Check permissions for Docker socket
MIT License - see repository for details.