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.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
Refactor to consistently use app.root_path and update deployment model
Juan Denis2fa790ac85c7
diff --git a/backend/app/api/backups.py b/backend/app/api/backups.pyindex 6d9c7f06..856b2ebc 100644--- a/backend/app/api/backups.py+++ b/backend/app/api/backups.py@@ -81,7 +81,7 @@ def backup_application():result = BackupService.backup_application(app_name=app.name,- app_path=app.path,+ app_path=app.root_path,include_db=data.get('include_db', False),db_config=data.get('db_config'))diff --git a/backend/app/api/builds.py b/backend/app/api/builds.pyindex 934d1bb3..ccce7760 100644--- a/backend/app/api/builds.py+++ b/backend/app/api/builds.py@@ -69,7 +69,7 @@ def configure_build(app_id):result = BuildService.configure_build(app_id=app_id,- app_path=app.root_path or app.path,+ app_path=app.root_path,build_method=data.get('build_method', 'auto'),dockerfile_path=data.get('dockerfile_path'),custom_build_cmd=data.get('custom_build_cmd'),@@ -113,7 +113,7 @@ def detect_build_method(app_id):if user.role != 'admin' and app.user_id != current_user_id:return jsonify({'error': 'Access denied'}), 403- detection = BuildService.detect_build_method(app.root_path or app.path)+ detection = BuildService.detect_build_method(app.root_path)return jsonify(detection), 200@@ -131,7 +131,7 @@ def get_nixpacks_plan(app_id):if user.role != 'admin' and app.user_id != current_user_id:return jsonify({'error': 'Access denied'}), 403- result = BuildService.get_nixpacks_plan(app.root_path or app.path)+ result = BuildService.get_nixpacks_plan(app.root_path)return jsonify(result), 200 if result.get('success') else 400diff --git a/backend/app/api/deploy.py b/backend/app/api/deploy.pyindex fe33272f..78e0aa5f 100644--- a/backend/app/api/deploy.py+++ b/backend/app/api/deploy.py@@ -62,7 +62,7 @@ def configure_deployment(app_id):result = GitService.configure_deployment(app_id=app_id,- app_path=app.path,+ app_path=app.root_path,repo_url=data['repo_url'],branch=data.get('branch', 'main'),auto_deploy=data.get('auto_deploy', True),@@ -117,7 +117,7 @@ def pull_changes(app_id):return jsonify({'error': 'Access denied'}), 403data = request.get_json() or {}- result = GitService.pull_changes(app.path, data.get('branch'))+ result = GitService.pull_changes(app.root_path, data.get('branch'))return jsonify(result), 200 if result['success'] else 400@@ -136,7 +136,7 @@ def get_git_status(app_id):if user.role != 'admin' and app.user_id != current_user_id:return jsonify({'error': 'Access denied'}), 403- status = GitService.get_git_status(app.path)+ status = GitService.get_git_status(app.root_path)return jsonify(status), 200@@ -154,7 +154,7 @@ def get_commit_info(app_id):if user.role != 'admin' and app.user_id != current_user_id:return jsonify({'error': 'Access denied'}), 403- commit_info = GitService.get_commit_info(app.path)+ commit_info = GitService.get_commit_info(app.root_path)if commit_info:return jsonify({'commit': commit_info}), 200return jsonify({'error': 'Not a Git repository'}), 404@@ -209,7 +209,7 @@ def get_branches(app_id):if user.role != 'admin' and app.user_id != current_user_id:return jsonify({'error': 'Access denied'}), 403- result = GitService.get_remote_branches(app.path)+ result = GitService.get_remote_branches(app.root_path)return jsonify(result), 200 if result.get('success') else 400diff --git a/backend/app/models/deployment.py b/backend/app/models/deployment.pyindex ebdb5909..be1538b8 100644--- a/backend/app/models/deployment.py+++ b/backend/app/models/deployment.py@@ -54,28 +54,29 @@ class Deployment(db.Model):error_message = db.Column(db.Text, nullable=True)# Metadata (JSON for flexibility)- metadata = db.Column(db.Text, default='{}')+ # Note: 'metadata' is reserved by SQLAlchemy, so we use 'extra_data'+ extra_data = db.Column(db.Text, default='{}')# Relationships- app = db.relationship('Application', backref=db.backref('deployments', lazy='dynamic', order_by='Deployment.version.desc()'))- deployer = db.relationship('User', backref='deployments')+ app = db.relationship('Application', backref=db.backref('deployments', lazy='dynamic'))+ deployer = db.relationship('User', backref=db.backref('user_deployments', lazy='dynamic'))def get_metadata(self):"""Get metadata as dict."""try:- return json.loads(self.metadata) if self.metadata else {}+ return json.loads(self.extra_data) if self.extra_data else {}except (json.JSONDecodeError, TypeError):return {}def set_metadata(self, data):"""Set metadata from dict."""- self.metadata = json.dumps(data)+ self.extra_data = json.dumps(data)def update_metadata(self, key, value):"""Update a single metadata field."""meta = self.get_metadata()meta[key] = value- self.metadata = json.dumps(meta)+ self.extra_data = json.dumps(meta)@propertydef duration(self):diff --git a/backend/app/services/deployment_service.py b/backend/app/services/deployment_service.pyindex ce030167..0249c808 100644--- a/backend/app/services/deployment_service.py+++ b/backend/app/services/deployment_service.py@@ -52,7 +52,7 @@ class DeploymentService:if build_config:build_method = build_config.get('build_method', 'auto')if build_method == 'auto':- detection = BuildService.detect_build_method(app.root_path or app.path)+ detection = BuildService.detect_build_method(app.root_path)build_method = detection.get('build_method')# Create deployment record@@ -287,7 +287,7 @@ class DeploymentService:log_callback("Pulling latest changes...")pull_result = GitService.pull_changes(- app.root_path or app.path,+ app.root_path,deploy_config.get('branch'))@@ -301,7 +301,7 @@ class DeploymentService:script_result = GitService._run_script(deploy_config['post_deploy_script'],- app.root_path or app.path+ app.root_path)if not script_result.get('success'):@@ -434,7 +434,7 @@ class DeploymentService:if not target.commit_hash:return {'success': False, 'error': 'No commit hash to rollback to'}- app_path = app.root_path or app.path+ app_path = app.root_pathtry:if log_callback:@@ -483,7 +483,7 @@ class DeploymentService:returnapp = Application.query.get(deployment.app_id)- app_path = app.root_path or app.path+ app_path = app.root_path# Get git diffresult = subprocess.run(diff --git a/frontend/dist/index.html b/frontend/dist/index.htmlindex c7e27ce5..3c74aea7 100644--- a/frontend/dist/index.html+++ b/frontend/dist/index.html@@ -6,8 +6,8 @@<link rel="icon" type="image/svg+xml" href="/vite.svg" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>React Dashboard Template</title>- <script type="module" crossorigin src="/assets/index-URe4pgfM.js"></script>- <link rel="stylesheet" crossorigin href="/assets/index-B_wqBYsy.css">+ <script type="module" crossorigin src="/assets/index-ClQee1fk.js"></script>+ <link rel="stylesheet" crossorigin href="/assets/index-DytIiSKP.css"></head><body>diff --git a/frontend/src/pages/Templates.jsx b/frontend/src/pages/Templates.jsxindex ac43797b..f1328f09 100644--- a/frontend/src/pages/Templates.jsx+++ b/frontend/src/pages/Templates.jsx@@ -1,7 +1,7 @@import { useState, useEffect } from 'react';import { useNavigate } from 'react-router-dom';import api from '../services/api';-import { useToast } from '../components/Toast';+import { useToast } from '../contexts/ToastContext';const Templates = () => {const navigate = useNavigate();diff --git a/frontend/src/styles/_variables.less b/frontend/src/styles/_variables.lessindex dccddea2..2d4409fd 100644--- a/frontend/src/styles/_variables.less+++ b/frontend/src/styles/_variables.less@@ -13,6 +13,7 @@// --------------------------------------------// COLORS - Borders// --------------------------------------------+@border-default: #27272a;@border-subtle: #27272a;@border-active: #3f3f46;@@ -74,6 +75,7 @@@font-size-lg: 18px;@font-size-xl: 20px;@font-size-2xl: 24px;+@font-size-3xl: 30px;@font-weight-normal: 400;@font-weight-medium: 500;