Skip to content

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_website
  • sadeem_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

  1. Subscription Type - Extended with Docker option
  2. Docker Image - Portainer image for subscriptions (required when type is docker)

Additional Add-on Type

  1. Workers - New add-on type for configuring Docker worker count

How It Works

  1. Plan is configured with type Docker and a Docker image
  2. Optionally add a workers add-on to allow customers to configure worker count
  3. Customer purchases the plan through the website flow
  4. After payment, get_best_environment() selects the optimal Portainer environment
  5. Worker count is mapped from the workers add-on quantity
  6. All environment-related fields (IP, ports, domain, Cloudflare, Nginx) are set from the environment
  7. 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_publish raises ValidationError if saas_subscription_type = 'docker' and no docker_image is set on the plan.
  • Docker image required to purchase: _validate_subscription_creation raises ValidationError if no docker_image is configured at the time of subscription creation.
  • Workers add-on: The workers add-on type quantity is automatically mapped to docker_worker_count on the created subscription.
  • No new persistent models: This module only inherits and extends existing models.