Docker Slices
Purpose
Each user gets a dedicated Docker container (“slice”) running the WhatsApp CRM backend and headless Chromium. Slices are fully isolated — own container, own database, own WhatsApp session, own media storage. The gateway proxies authenticated requests to the correct slice port.
Architecture
Naming Conventions
| Item | Pattern | Example |
|---|---|---|
| Container name | wank-slice-{N} |
wank-slice-1 |
| Database | wa_slice_{N} |
wa_slice_1 |
| Data directory | /data/slices/{N}/ |
/data/slices/1/ |
| Host port | 5001 + (N-1) * 2 |
5001, 5003, 5005… |
| Internal port | 3101 (fixed) | 3101 |
Port Allocation
Ports use odd numbers starting at 5001, incrementing by 2:
| Slice | Port |
|---|---|
| 1 | 5001 |
| 2 | 5003 |
| 3 | 5005 |
| N | 5001 + (N-1) * 2 |
Formula: port = 5001 + (sliceNum - 1) * 2
Reverse: sliceNum = floor((port - 5001) / 2) + 1
All ports bind to 127.0.0.1 only — not exposed to the internet.
Resource Limits
| Resource | Limit |
|---|---|
| Memory | 512 MB |
| CPU | 0.5 cores |
| Shared memory (shm) | 256 MB |
| Restart policy | unless-stopped |
Volume Mounts
| Host Path | Container Path | Purpose |
|---|---|---|
/data/slices/{N}/session |
/app/.wwebjs_auth |
WhatsApp Web session data |
/data/slices/{N}/media |
/app/media |
Downloaded media files |
Docker Image
| Item | Value |
|---|---|
| Image | wank-slice:latest |
| Base | Node.js + Chromium |
| Internal port | 3101 |
Container Environment
Each container receives:
DATABASE_URL— connection string to itswa_slice_Ndatabase via Docker bridge (172.17.0.1:5432)PORT=3101NODE_ENV=production
Slice Lifecycle
[Provisioned/Available] → signup → [Assigned] → cancel → [Destroying] → [Destroyed]
↓ payment fail
[Suspended]
↓ payment restored
[Assigned]
Status
2 slices currently running on production (ports 5001, 5003).