Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

Fix template installation and variable handling

Juan Denise673be785dd6
diff --git a/backend/app/api/templates.py b/backend/app/api/templates.py
index a1f1583a..dd1d5eed 100644
--- a/backend/app/api/templates.py
+++ b/backend/app/api/templates.py
@@ -66,17 +66,34 @@ def get_template(template_id):
template = result['template']
- # Add processed variable info
+ # Add processed variable info - handle both list and dict formats
variables = []
- for var_name, var_config in template.get('variables', {}).items():
- variables.append({
- 'name': var_name,
- 'description': var_config.get('description', ''),
- 'type': var_config.get('type', 'string'),
- 'default': var_config.get('default', ''),
- 'required': var_config.get('required', False),
- 'options': var_config.get('options', None)
- })
+ raw_vars = template.get('variables', [])
+
+ if isinstance(raw_vars, list):
+ # New list format: [{name: 'PORT', type: 'port', ...}, ...]
+ for var in raw_vars:
+ if isinstance(var, dict):
+ variables.append({
+ 'name': var.get('name', ''),
+ 'description': var.get('description', ''),
+ 'type': var.get('type', 'string'),
+ 'default': var.get('default', ''),
+ 'required': var.get('required', False),
+ 'options': var.get('options', None)
+ })
+ elif isinstance(raw_vars, dict):
+ # Old dict format: {PORT: {type: 'port', ...}, ...}
+ for var_name, var_config in raw_vars.items():
+ if isinstance(var_config, dict):
+ variables.append({
+ 'name': var_name,
+ 'description': var_config.get('description', ''),
+ 'type': var_config.get('type', 'string'),
+ 'default': var_config.get('default', ''),
+ 'required': var_config.get('required', False),
+ 'options': var_config.get('options', None)
+ })
return jsonify({
'template': {
diff --git a/backend/app/services/template_service.py b/backend/app/services/template_service.py
index 14a6cd6e..688400f1 100644
--- a/backend/app/services/template_service.py
+++ b/backend/app/services/template_service.py
@@ -320,10 +320,17 @@ class TemplateService:
template = result['template']
- # Prepare variables
- variables = {}
+ # Prepare variables - start with automatic variables
+ variables = {
+ 'APP_NAME': app_name,
+ }
template_vars = template.get('variables', {})
+ # Handle both dict format (new) and list format (old)
+ if isinstance(template_vars, list):
+ # Convert list format to dict
+ template_vars = {v['name']: v for v in template_vars if 'name' in v}
+
for var_name, var_config in template_vars.items():
if user_variables and var_name in user_variables:
variables[var_name] = user_variables[var_name]
diff --git a/backend/templates/node-app.yaml b/backend/templates/node-app.yaml
index a2829c6a..597b62d5 100644
--- a/backend/templates/node-app.yaml
+++ b/backend/templates/node-app.yaml
@@ -12,20 +12,16 @@ categories:
variables:
- name: HTTP_PORT
- description: HTTP port for the application
+ description: HTTP port for the application (auto-assigned if not specified)
type: port
default: "8300"
- name: NODE_VERSION
description: Node.js version (18, 20, 21)
type: string
default: "20"
- - name: APP_PORT
- description: Internal app port
- type: string
- default: "3000"
ports:
- - port: 8300
+ - port: "${HTTP_PORT}"
protocol: tcp
description: Web interface
@@ -47,12 +43,12 @@ compose:
working_dir: /app
command: sh -c "npm install 2>/dev/null || true && npm start"
ports:
- - "${HTTP_PORT}:${APP_PORT:-3000}"
+ - "${HTTP_PORT}:3000"
volumes:
- app_data:/app
environment:
- NODE_ENV=production
- - PORT=${APP_PORT:-3000}
+ - PORT=3000
volumes:
app_data:
diff --git a/backend/templates/portainer.yaml b/backend/templates/portainer.yaml
index dbf6ee2a..3f656cd7 100644
--- a/backend/templates/portainer.yaml
+++ b/backend/templates/portainer.yaml
@@ -1,7 +1,8 @@
-name: portainer
+id: portainer
+name: Portainer
version: "2.19"
-description: Lightweight Docker management UI
-icon: /icons/portainer.png
+description: Lightweight Docker management UI with container visualization
+icon: https://www.portainer.io/hubfs/portainer-logo-white.svg
categories:
- devops
- docker
@@ -10,35 +11,35 @@ website: https://www.portainer.io
documentation: https://docs.portainer.io
variables:
- PORT:
+ - name: HTTP_PORT
type: port
- default: 9000
- description: Port for web interface
- HTTPS_PORT:
+ default: "9000"
+ description: Port for web interface (auto-assigned)
+ - name: HTTPS_PORT
type: port
- default: 9443
- description: Port for HTTPS access
+ default: "9443"
+ description: Port for HTTPS access (auto-assigned)
compose:
services:
- portainer:
+ app:
image: portainer/portainer-ce:latest
- container_name: portainer
+ container_name: ${APP_NAME}
restart: unless-stopped
ports:
- - "${PORT}:9000"
+ - "${HTTP_PORT}:9000"
- "${HTTPS_PORT}:9443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- - portainer-data:/data
+ - data:/data
security_opt:
- no-new-privileges:true
volumes:
- portainer-data:
+ data:
ports:
- - port: "${PORT}"
+ - port: "${HTTP_PORT}"
protocol: http
description: Web Interface
- port: "${HTTPS_PORT}"
@@ -48,3 +49,10 @@ ports:
requirements:
memory: 128MB
storage: 500MB
+
+post_install: |
+ Portainer is now running!
+
+ Access the web interface at: http://your-server:${HTTP_PORT}
+
+ First-time setup will ask you to create an admin account.
diff --git a/backend/templates/uptime-kuma.yaml b/backend/templates/uptime-kuma.yaml
index 630382aa..428d9578 100644
--- a/backend/templates/uptime-kuma.yaml
+++ b/backend/templates/uptime-kuma.yaml
@@ -1,7 +1,8 @@
-name: uptime-kuma
+id: uptime-kuma
+name: Uptime Kuma
version: "1.23"
description: A fancy self-hosted monitoring tool for websites and services
-icon: /icons/uptime-kuma.png
+icon: https://uptime.kuma.pet/img/icon.svg
categories:
- monitoring
- devops
@@ -9,37 +10,40 @@ website: https://uptime.kuma.pet
documentation: https://github.com/louislam/uptime-kuma/wiki
variables:
- PORT:
+ - name: HTTP_PORT
type: port
- default: 3001
- description: Port to expose the web interface
- DATA_PATH:
- type: string
- default: ./data
- description: Path to store data
+ default: "3001"
+ description: Port for web interface (auto-assigned if not specified)
compose:
services:
- uptime-kuma:
+ app:
image: louislam/uptime-kuma:1
- container_name: uptime-kuma
+ container_name: ${APP_NAME}
restart: unless-stopped
ports:
- - "${PORT}:3001"
+ - "${HTTP_PORT}:3001"
volumes:
- - uptime-kuma-data:/app/data
+ - data:/app/data
dns:
- 1.1.1.1
- 8.8.8.8
volumes:
- uptime-kuma-data:
+ data:
ports:
- - port: "${PORT}"
+ - port: "${HTTP_PORT}"
protocol: http
description: Web Interface
requirements:
memory: 256MB
storage: 1GB
+
+post_install: |
+ Uptime Kuma is now running!
+
+ Access the web interface at: http://your-server:${HTTP_PORT}
+
+ First-time setup will ask you to create an admin account.