Module Architecture
flowchart TD
WEBSITE["sadeem_subscription_website\nWebsite Plans"]
DOCKER["sadeem_saas_docker\nDocker SAAS"]
PLAN["sadeem.subscription.plan (inherit)\nDocker image field\nworkers add-on type added"]
IMGTAG["sadeem.portainer.image.tag\nDocker image version\nassigned to plan"]
ENV["sadeem.portainer.environment\nPortainer environment\nauto-selected by get_best_environment()"]
ADDON["sadeem.subscription.plan.addon (inherit)\nadds workers add-on type\nquantity = worker count"]
ORDER["sadeem.subscription.plan.order (inherit)\nmaps workers add-on to\ndocker_worker_count on subscription"]
SUB["sadeem.subscription\ntype=docker\nimage + ports + workers auto-set"]
WEBSITE --> PLAN
DOCKER --> PLAN
PLAN --> IMGTAG
PLAN --> ADDON
PLAN --> A1([action_publish override\nvalidate Docker image configured])
IMGTAG --> A2([get_best_environment\nselect Portainer env by capacity])
A2 --> ENV
ORDER --> A3([action_create_subscription override\napply Docker image + worker count])
A3 --> SUB
ENV --> A4([_apply_environment_defaults\nset IP · ports · domain · Nginx · Cloudflare])
A4 --> SUB
SUB --> A5([action_confirm\nauto-assign ports + deploy Docker stack])
EXT[/Portainer API\nDocker stack deploy/]
A5 --> EXT
Module Description
SAAS Website Plans - Docker Extension. Adds Docker image configuration to website subscription plans, enabling plan purchases to be deployed as Docker containers.
Dependencies
sadeem_subscription_websitesadeem_saas_docker
Extension
This module extends website subscription plans with a Docker Image field and adds a workers add-on type. When the subscription type is set to docker, the system uses the Docker image to auto-select the best Portainer environment and deploy a container.
Additional Plan Fields
- Subscription Type - Extended with
Dockeroption - Docker Image - Portainer image for subscriptions (required when type is
docker)
Additional Add-on Type
- Workers - New add-on type for configuring Docker worker count
How It Works
- Plan is configured with type
Dockerand a Docker image - Optionally add a
workersadd-on to allow customers to configure worker count - Customer purchases the plan through the website flow
- After payment,
get_best_environment()selects the optimal Portainer environment - Worker count is mapped from the
workersadd-on quantity - All environment-related fields (IP, ports, domain, Cloudflare, Nginx) are set from the environment
- Subscription is created and a Docker stack is deployed in Portainer
Publishing Validation
When publishing a Docker plan, the system validates that a Docker Image is configured.
Key Fields
Subscription Plan — Docker additions (sadeem.subscription.plan inherit)
| Field | Type | Description |
|---|---|---|
| saas_subscription_type | Selection | Extended with ('docker', 'Docker') |
| docker_image | Many2one | Portainer image used for Docker subscriptions created from this plan |
Plan Add-on — Docker additions (sadeem.subscription.plan.addon inherit)
| Field | Type | Description |
|---|---|---|
| addon_type | Selection | Extended with ('workers', 'Workers') — quantity maps to Docker worker count |
Key Actions
| Action | Model | Description |
|---|---|---|
_validate_publish (override) |
sadeem.subscription.plan | Validates that docker_image is configured before allowing publish when type is docker |
_validate_subscription_creation (override) |
sadeem.subscription.plan.order | Validates Docker image is configured on the plan |
action_create_subscription (override) |
sadeem.subscription.plan.order | Creates subscription with Docker image and maps workers add-on to docker_worker_count |
Warnings & Important Notes
- Docker image required to publish:
_validate_publishraisesValidationErrorifsaas_subscription_type = 'docker'and nodocker_imageis set on the plan. - Docker image required to purchase:
_validate_subscription_creationraisesValidationErrorif nodocker_imageis configured at the time of subscription creation. - Workers add-on: The
workersadd-on type quantity is automatically mapped todocker_worker_counton the created subscription. - No new persistent models: This module only inherits and extends existing models.