Easypanel Templates

repository·main·Indexed 42 days ago

https://github.com/easypanel-io/templates

A framework and collection of source code and definitions for creating, testing, and contributing application templates for Easypanel. It includes guidelines for defining templates using meta.yaml and index.ts, implementing the generate() function to orchestrate services (app, postgres, redis), and best practices for Docker image stability and security.

Tokens
139.8K
Snippets
411
Records
441
Agent score
52%

What's inside Easypanel Templates

  1. Pull Request checklist for templates

    main

    Before submitting a PR, verify the following requirements:

    Assets

    • Logo: High quality, square aspect ratio, containing only the logo mark (icon).
    • Screenshot: High quality, shows actual content (not an empty state), is not a banner, and does not show the entire desktop.

    Configuration (meta.yaml)

    • Use specific, static versions (e.g., 2.1.7 instead of 2.1 or 2).
    • Include all relevant links (website, docs, GitHub).
    • Include deployment instructions.
    • Use official images (or explain why not).

    Logic (index.ts)

    • No unused variables.
    • No hardcoded secrets (use random generation).
    • Extract reused environment variables.
    • Ensure volumes are included.

    Validation

    • Test the template using the templates playground.
  2. Best practices for Easypanel templates

    main

    Follow these guidelines to ensure template quality and stability:

    • Build & Format: Always run npm run build to verify successful compilation and npm run prettier to ensure consistent file formatting.
    • Docker Image Stability: Avoid using the latest tag for Docker images; use specific version tags instead.
    • Docker Image Security: Use only official Docker images. If an official image is unavailable, you must provide an explanation in the template metadata.
    • Code Quality:
      • Ensure index.ts has no unused variables.
      • Never hardcode secrets; generate random values instead.
      • Extract environment variables that are used multiple times.
      • Ensure all necessary volumes are defined.
  3. How to define and develop Easypanel templates

    main

    To create a new template, follow these steps:

    1. Initialize: Duplicate an existing template from the /templates directory.
    2. Development Environment: Run npm run dev to launch the testing playground.
    3. Customization:
      • Edit meta.yaml and index.ts. Do not edit meta.ts as it is a generated file.
      • Logo: Provide logo.png or logo.svg.
      • Screenshots: Provide screenshot.png or screenshot.jpg. For multiple screenshots, use the naming convention screenshot1.png, screenshot2.png, etc.
    4. Testing: Use the Easypanel instance feature that allows creating a template from JSON to verify the output of your template.
    5. Submission: Submit your changes via a Pull Request.
    npm run dev
  4. Lago service architecture

    main

    A Lago deployment generated by this template consists of the following service types:

    Service NameTypePurpose
    ${appServiceName}-dbpostgresPrimary database
    ${appServiceName}-redisredisCache and background job store
    ${appServiceName}-pdfappPDF generation service
    ${appServiceName}-migrateappRuns ./scripts/migrate.sh to update the database schema
    ${appServiceName}-apiappThe main API service, runs ./scripts/start.api.sh and mounts /app/storage
    ${appServiceName}-frontendappThe user interface, runs on port 80
    ${appServiceName}-workerappBackground worker, runs ./scripts/start.worker.sh and mounts /app/storage
    ${appServiceName}-clockappScheduled tasks, runs ./scripts/start.clock.sh
  5. Configure LLM providers in Inbox Zero

    main

    The Inbox Zero template supports multiple LLM providers through the input.llmProvider field. The generate function maps these providers to specific environment variables:

    ProviderEnvironment Variables Set
    openaiOPENAI_API_KEY
    anthropicANTHROPIC_API_KEY
    googleGOOGLE_API_KEY
    groqGROQ_API_KEY
    bedrockBEDROCK_ACCESS_KEY, BEDROCK_SECRET_KEY, BEDROCK_REGION
    ollamaOLLAMA_BASE_URL, NEXT_PUBLIC_OLLAMA_MODEL
    openrouterOPENROUTER_API_KEY

    Additionally, if input.economyLlmProvider is provided (and not 'none'), it sets ECONOMY_LLM_PROVIDER and ECONOMY_LLM_MODEL.

  6. Budibase service architecture and environment variables

    main

    The Budibase template deploys a multi-service architecture. Each service relies on specific environment variables and internal networking patterns using $(PROJECT_NAME) and $(EASYPANEL_DOMAIN) placeholders.

    Services Deployed:

    1. Redis (type: "redis")

      • Provides caching and session management.
      • Uses REDIS_URL and REDIS_PASSWORD for connection.
    2. CouchDB (type: "app")

      • The primary database.
      • Image: budibase/couchdb:v3.3.3-sqs-v2.1.1.
      • Mounts: couchdb-data volume at /opt/couchdb/data.
      • Connection: COUCH_DB_URL (format: http://user:pass@$(PROJECT_NAME)_service-couchdb:5984).
    3. MinIO (type: "app")

      • Object storage.
      • Image: quay.io/minio/minio:latest.
      • Mounts: data volume at /data.
      • Domains:
        • $(EASYPANEL_DOMAIN) on port 9000 (API).
        • console-$(EASYPANEL_DOMAIN) on port 9001 (Console).
      • Command: minio server /data --console-address ":9001".
    4. Worker (type: "app")

      • Background task processor.
      • Image: Defined by input.workerServiceImage.
      • Key Envs: SELF_HOSTED=1, PORT=4003, MINIO_URL, COUCH_DB_URL, REDIS_URL.
    5. App (type: "app")

      • The main Budibase application.
      • Image: Defined by input.appServiceImage.
      • Key Envs: BB_ADMIN_USER_EMAIL, BB_ADMIN_USER_PASSWORD, BUDIBASE_ENVIRONMENT=PRODUCTION, PORT=4002.
    6. Proxy (type: "app")

      • The entrypoint for external traffic.
      • Image: budibase/proxy.
      • Domain: $(EASYPANEL_DOMAIN) on port 10000.
      • Upstream URLs: Routes traffic to app, worker, minio, and couchdb services using their internal network names.
  7. DevLake template service structure

    main

    A DevLake deployment via this template includes the following services:

    • {appServiceName}-ui: The frontend interface. It connects to the backend and Grafana via environment variables. It listens on port 4000.
    • {appServiceName}-backend: The core engine. It requires a volume mount at /app/logs for persistent logging. It listens on port 8080.
    • {appServiceName}-grafana: A visualization service configured to use the DevLake MySQL database. It uses a volume mount at /var/lib/grafana for storage and listens on port 3000.
    • {appServiceName}-db: A MySQL database service used for storing DevLake data.
  8. Template object structure and metadata

    main

    Templates are objects that follow a specific structure used for selection and form generation:

    • slug: A unique identifier used for routing and selection.
    • meta.name: The human-readable name of the template.
    • meta.schema: A JSON schema used by @rjsf/validator-ajv8 to render the configuration form.
    • generate(formData): A function that processes the form data to produce the final output.
  9. Configure AdGuard Home Sync via YAML

    main

    The AdGuard Home Sync service is configured using a YAML file. The configuration supports cron scheduling, origin instance details, and replica management (single or multiple).

    cron: "*/10 * * * "
    
    origin:
      # url of the origin instance
      url: https://192.168.1.2:3000
      # apiPath: define an api path if other than "/control"
      # insecureSkipVerify: true # disable tls check
      username: username
      password: password
    
    # replica instance (optional, if only one)
    replica:
      # url of the replica instance
      url: http://192.168.1.3
      username: username
      password: password
    
    # replicas instances (optional, if more than one)
    # replicas:
    #   - url: http://192.168.1.3
    #     username: username
    #     password: password
    #   - url: http://192.168.1.4
    #     username: ${input.apiUsername}
    #     password: ${input.apiPassword}
    
    # Configure the sync API server, disabled if api port is 0
    api:
      # Port, default 8080
      port: 8080
      # if username and password are defined, basic auth is applied to the sync API
      username: username
      password: password
  10. Libredesk configuration via config.toml

    main

    The Libredesk application is configured using a config.toml file mounted at /libredesk/config.toml. The template automatically populates several key sections:

    Key Configuration Sections

    • [app]: Contains log_level, env (default prod), check_updates, and the encryption_key.
    • [app.server]: Configures the HTTP server (default address 0.0.0.0:9000, timeouts, and max body size).
    • [upload]: Defines the provider (fs or s3). The template defaults to fs with an upload_path of uploads.
    • [db]: Configures Postgres connection details. The host is automatically set to $(PROJECT_NAME)_${input.appServiceName}-db.
    • [redis]: Configures Redis connection details. The address is set to $(PROJECT_NAME)_${input.appServiceName}-redis:6379.
    • [message], [notification], [automation], [autoassigner], [webhook], [conversation], [sla]: Various worker counts, queue sizes, and interval settings for application logic.
  11. Configure a Select form field in meta.yaml

    main

    You can define a dropdown selection field in your template configuration using the selectField key. The field uses a oneOf structure where each option contains an enum array of values and a title for display.

    selectField:
      type: string
      title: Select Field
      oneOf:
        - enum:
            - first
          title: First Option
        - enum:
            - second
          title: Second Option
        - enum:
            - third
          title: Third Option
  12. Generate Infisical template services

    main

    The generate function is the entrypoint for the Infisical template. It takes an Input object and returns an Output object containing a list of configured services.

    When called, it performs the following actions:

    1. Generates random passwords for the PostgreSQL and Redis services using randomPassword().
    2. Generates 32-character random strings for ENCRYPTION_KEY and AUTH_SECRET using randomString(32).
    3. Constructs a set of common_envs containing database URIs, Redis URLs, and various placeholder environment variables for SMTP, OAuth providers (GitHub, Vercel, etc.), Sentry, PostHog, and OpenTelemetry.
    4. Defines three specific services:
      • Migration App: An app type service running npm run migration:latest using the provided input.appServiceImage.
      • Web App: An app type service running the provided input.appServiceImage on port 80, mapped to the $(EASYPANEL_DOMAIN).
      • PostgreSQL: A postgres type service with a generated password.
      • Redis: A redis type service with a generated password.

    Note: The database and redis connection strings use the pattern $(PROJECT_NAME)_${input.appServiceName}-db and $(PROJECT_NAME)_${input.appServiceName}-redis respectively.

    import { generate } from './templates/infisical/index';
    
    // Example usage (conceptual)
    const output = generate({
      appServiceName: 'my-app',
      appServiceImage: 'infisical/infisical:latest'
    });
    
    console.log(output.services);