Compare commits
7
Commits
7557a6364a
...
v1.11.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e361d9a328 | ||
|
|
aa25bcc053 | ||
|
|
bda08b592e | ||
|
|
0e408974a0 | ||
|
|
f4b35dcc30 | ||
|
|
1c0d765182 | ||
|
|
2cd62208ac |
@@ -342,7 +342,8 @@ const APP_TEMPLATES = {
|
||||
volumes: [
|
||||
"/var/run/docker.sock:/var/run/docker.sock",
|
||||
"/opt/portainer/data:/data"
|
||||
]
|
||||
],
|
||||
environment: {}
|
||||
},
|
||||
subdomain: "portainer",
|
||||
defaultPort: 9000,
|
||||
@@ -393,7 +394,8 @@ const APP_TEMPLATES = {
|
||||
docker: {
|
||||
image: "louislam/uptime-kuma:latest",
|
||||
ports: ["{{PORT}}:3001"],
|
||||
volumes: ["/opt/uptime-kuma:/app/data"]
|
||||
volumes: ["/opt/uptime-kuma:/app/data"],
|
||||
environment: {}
|
||||
},
|
||||
subdomain: "uptime",
|
||||
defaultPort: 3002,
|
||||
@@ -549,7 +551,7 @@ const APP_TEMPLATES = {
|
||||
},
|
||||
subdomain: "dns2",
|
||||
defaultPort: 953,
|
||||
healthCheck: null,
|
||||
healthCheck: "tcp://localhost:53",
|
||||
subpathSupport: 'strip',
|
||||
setupInstructions: [
|
||||
"Configure zone files in /opt/bind9/config/",
|
||||
@@ -640,14 +642,14 @@ const APP_TEMPLATES = {
|
||||
],
|
||||
docker: {
|
||||
image: "coredns/coredns:latest",
|
||||
ports: ["53:53", "53:53/udp"],
|
||||
ports: ["{{PORT}}:53", "53:53", "53:53/udp"],
|
||||
volumes: ["/opt/coredns/config:/etc/coredns"],
|
||||
environment: {},
|
||||
command: ["-conf", "/etc/coredns/Corefile"]
|
||||
},
|
||||
subdomain: "dns4",
|
||||
defaultPort: 53,
|
||||
healthCheck: null,
|
||||
healthCheck: "tcp://localhost:53",
|
||||
subpathSupport: 'strip',
|
||||
setupInstructions: [
|
||||
"Create Corefile in /opt/coredns/config/",
|
||||
@@ -1007,7 +1009,9 @@ const APP_TEMPLATES = {
|
||||
docker: {
|
||||
image: "adminer:latest",
|
||||
ports: ["{{PORT}}:8080"],
|
||||
volumes: [],
|
||||
volumes: [
|
||||
"/opt/adminer:/var/www/html"
|
||||
],
|
||||
environment: {
|
||||
"ADMINER_DEFAULT_SERVER": "postgres"
|
||||
}
|
||||
@@ -1099,6 +1103,7 @@ const APP_TEMPLATES = {
|
||||
popularity: 85,
|
||||
difficulty: "Easy",
|
||||
isDashboardWidget: true,
|
||||
isStaticSite: true,
|
||||
widgetSelector: ".weather-widget-container",
|
||||
subdomain: null,
|
||||
defaultPort: null,
|
||||
@@ -1126,6 +1131,7 @@ const APP_TEMPLATES = {
|
||||
popularity: 80,
|
||||
difficulty: "Easy",
|
||||
isDashboardWidget: true,
|
||||
isStaticSite: true,
|
||||
widgetSelector: ".clock-widget-container",
|
||||
subdomain: null,
|
||||
defaultPort: null,
|
||||
@@ -1908,7 +1914,9 @@ const APP_TEMPLATES = {
|
||||
docker: {
|
||||
image: "traefik/whoami:latest",
|
||||
ports: ["{{PORT}}:80"],
|
||||
volumes: [],
|
||||
volumes: [
|
||||
"/opt/whoami/config:/config"
|
||||
],
|
||||
environment: {}
|
||||
},
|
||||
subdomain: "whoami",
|
||||
@@ -2233,7 +2241,9 @@ const APP_TEMPLATES = {
|
||||
docker: {
|
||||
image: "excalidraw/excalidraw:latest",
|
||||
ports: ["{{PORT}}:80"],
|
||||
volumes: [],
|
||||
volumes: [
|
||||
"/opt/excalidraw/data:/var/lib/excalidraw"
|
||||
],
|
||||
environment: {}
|
||||
},
|
||||
subdomain: "draw",
|
||||
@@ -2258,7 +2268,9 @@ const APP_TEMPLATES = {
|
||||
docker: {
|
||||
image: "corentinth/it-tools:latest",
|
||||
ports: ["{{PORT}}:80"],
|
||||
volumes: [],
|
||||
volumes: [
|
||||
"/opt/it-tools/config:/config"
|
||||
],
|
||||
environment: {}
|
||||
},
|
||||
subdomain: "tools",
|
||||
@@ -2417,7 +2429,7 @@ const APP_TEMPLATES = {
|
||||
},
|
||||
subdomain: "mc",
|
||||
defaultPort: 25565,
|
||||
healthCheck: null,
|
||||
healthCheck: "tcp://localhost:25565",
|
||||
subpathSupport: 'none',
|
||||
setupInstructions: [
|
||||
"Server accepts the Minecraft EULA automatically",
|
||||
@@ -2451,7 +2463,7 @@ const APP_TEMPLATES = {
|
||||
},
|
||||
subdomain: "valheim",
|
||||
defaultPort: 2456,
|
||||
healthCheck: null,
|
||||
healthCheck: "tcp://localhost:2456",
|
||||
subpathSupport: 'none',
|
||||
setupInstructions: [
|
||||
"Connect via Steam: Add Server > IP:2456",
|
||||
|
||||
@@ -102,7 +102,7 @@ const DNS_RECORD_TYPES = ['A', 'AAAA', 'CNAME', 'MX', 'TXT', 'NS', 'SRV', 'PTR',
|
||||
// ── Docker ──────────────────────────────────────────────────────
|
||||
const DOCKER = {
|
||||
CONTAINER_PREFIX: 'sami-',
|
||||
TIMEOUT: 30000, // 30s — timeout for docker pull/create operations
|
||||
TIMEOUT: 300000, // 300s — timeout for docker pull/create operations
|
||||
LOG_CONFIG: {
|
||||
Type: 'json-file',
|
||||
Config: { 'max-size': '10m', 'max-file': '3' } // 30MB max per container
|
||||
|
||||
@@ -317,6 +317,9 @@ class LicenseManager {
|
||||
*/
|
||||
isExpired() {
|
||||
if (!this.activation) return true;
|
||||
// Lifetime licenses never expire
|
||||
if (this.activation.lifetime || this.activation.durationDays === 0) return false;
|
||||
if (!this.activation.expiresAt) return false; // No expiry set = lifetime
|
||||
return Date.now() > new Date(this.activation.expiresAt).getTime();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dashcaddy-api",
|
||||
"version": "1.10.0",
|
||||
"version": "1.11.0",
|
||||
"description": "DashCaddy API server - Dashboard backend for Docker, Caddy & DNS management",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -306,7 +306,7 @@ module.exports = function({ docker, caddy, credentialManager, servicesStateManag
|
||||
} else {
|
||||
containerId = await deployContainer(appId, config, template);
|
||||
log.info('deploy', 'Container deployed', { containerId });
|
||||
await helpers.waitForHealthCheck(containerId, template.healthCheck, config.port || template.defaultPort);
|
||||
await helpers.waitForHealthCheck(containerId, template.healthCheck, config.port || template.defaultPort, 30);
|
||||
log.info('deploy', 'Container is healthy', { containerId });
|
||||
}
|
||||
|
||||
@@ -420,10 +420,11 @@ module.exports = function({ docker, caddy, credentialManager, servicesStateManag
|
||||
|
||||
res.json(response);
|
||||
} catch (error) {
|
||||
await logError('app-deploy', error, { appId, config });
|
||||
log.error('deploy', 'Deployment failed', { appId, error: error.message });
|
||||
try { await logError('app-deploy', error, { appId, config }); } catch (_) { /* logError failure should not mask original error */ }
|
||||
const msg = error?.message || String(error || 'Unknown error');
|
||||
log.error('deploy', 'Deployment failed', { appId, error: msg });
|
||||
const template = ctx.APP_TEMPLATES[appId];
|
||||
ctx.notification.send('deploymentFailed', 'Deployment Failed', `Failed to deploy **${template?.name || appId}**.\nError: ${error.message}`, 'error');
|
||||
try { ctx.notification.send('deploymentFailed', 'Deployment Failed', `Failed to deploy **${template?.name || appId}**.\nError: ${msg}`, 'error'); } catch (_) {}
|
||||
errorResponse(res, 500, ctx.safeErrorMessage(error));
|
||||
}
|
||||
}, 'apps-deploy'));
|
||||
|
||||
@@ -379,9 +379,12 @@ module.exports = function({ docker, caddy, credentialManager, servicesStateManag
|
||||
return content.slice(0, endIdx) + injection + content.slice(endIdx);
|
||||
});
|
||||
|
||||
if (!result.success) {
|
||||
if (!result.success && result.error !== 'No changes to apply') {
|
||||
throw new Error(`[DC-303] Failed to add subpath config for ${subdomain}: ${result.error}`);
|
||||
}
|
||||
if (result.error === 'No changes to apply') {
|
||||
log.info('caddy', 'Subpath config already exists, reusing', { subdomain });
|
||||
}
|
||||
}
|
||||
|
||||
/** Remove a subpath config block from between its markers in the Caddyfile. */
|
||||
|
||||
@@ -25,7 +25,6 @@ module.exports = function(ctx) {
|
||||
asyncHandler: ctx.asyncHandler,
|
||||
errorResponse: ctx.errorResponse,
|
||||
log: ctx.log,
|
||||
// Additional context properties needed by routes
|
||||
APP_TEMPLATES: ctx.APP_TEMPLATES,
|
||||
TEMPLATE_CATEGORIES: ctx.TEMPLATE_CATEGORIES,
|
||||
DIFFICULTY_LEVELS: ctx.DIFFICULTY_LEVELS,
|
||||
@@ -40,26 +39,27 @@ module.exports = function(ctx) {
|
||||
ctx: ctx
|
||||
};
|
||||
|
||||
// Initialize helpers with dependencies (ctx is the Koa context)
|
||||
const helpers = initHelpers({ ...deps, ctx });
|
||||
|
||||
// Mount sub-routes — pass full ctx so sub-routes can reference ctx.* properties
|
||||
const subCtx = Object.assign({}, ctx, { helpers });
|
||||
|
||||
try { router.use('/deploy', initDeploy(subCtx)); }
|
||||
catch(e) { (ctx.log || console).error('[apps] deploy routes init failed:', e.message); }
|
||||
// Mount sub-routers at their prefix paths.
|
||||
// Sub-modules define routes at '/' (root of their sub-router).
|
||||
// Final paths: /api/v1/apps/deploy, /api/v1/apps/remove, /api/v1/apps/templates, etc.
|
||||
|
||||
try { router.use('/remove', initRemoval(subCtx)); }
|
||||
catch(e) { (ctx.log || console).error('[apps] removal routes init failed:', e.message); }
|
||||
try { router.use('/apps', initDeploy(subCtx)); }
|
||||
catch(e) { (ctx.log || console).error('[apps] deploy routes init failed:', e.message, e.stack); }
|
||||
|
||||
try { router.use('/apps', initRemoval(subCtx)); }
|
||||
catch(e) { (ctx.log || console).error('[apps] removal routes init failed:', e.message, e.stack); }
|
||||
|
||||
try { router.use('/apps', initTemplates(subCtx)); }
|
||||
catch(e) { (ctx.log || console).error('[apps] templates routes init failed:', e.message); }
|
||||
catch(e) { (ctx.log || console).error('[apps] templates routes init failed:', e.message, e.stack); }
|
||||
|
||||
try { router.use('/restore', initRestore(Object.assign({}, subCtx, { backupManager: ctx.backupManager }))); }
|
||||
catch(e) { (ctx.log || console).error('[apps] restore routes init failed:', e.message); }
|
||||
try { router.use('/apps', initRestore(Object.assign({}, subCtx, { backupManager: ctx.backupManager }))); }
|
||||
catch(e) { (ctx.log || console).error('[apps] restore routes init failed:', e.message, e.stack); }
|
||||
|
||||
try { router.use('/compose', initCompose(subCtx)); }
|
||||
catch(e) { (ctx.log || console).error('[apps] compose routes init failed:', e.message); }
|
||||
try { router.use('/apps', initCompose(subCtx)); }
|
||||
catch(e) { (ctx.log || console).error('[apps] compose routes init failed:', e.message, e.stack); }
|
||||
|
||||
return router;
|
||||
};
|
||||
|
||||
@@ -73,9 +73,12 @@ process.on('uncaughtException', (error) => {
|
||||
try { bundledWorkflows = require('./bundled-workflows'); } catch { /* optional */ }
|
||||
|
||||
// Initialize workflow engine if bundled-workflows is available
|
||||
// NOTE: createApp() already initializes the workflow engine in src/app.js
|
||||
// This block is kept for backward compat with entry points that don't use createApp()
|
||||
let workflowEngine = null;
|
||||
if (bundledWorkflows) {
|
||||
try {
|
||||
const { fetchT } = require('./src/utils/http');
|
||||
const { WorkflowEngine } = bundledWorkflows;
|
||||
// Create a context with needed services
|
||||
const workflowCtx = {
|
||||
|
||||
@@ -539,7 +539,7 @@ async function createApp() {
|
||||
sslMonitor: ctx.sslMonitor,
|
||||
dnsPropagationChecker: ctx.dnsPropagationChecker
|
||||
}));
|
||||
apiRouter.use(workflowsRoutes({
|
||||
apiRouter.use('/workflows', workflowsRoutes({
|
||||
workflowEngine: ctx.workflowEngine,
|
||||
licenseManager: ctx.licenseManager,
|
||||
asyncHandler: ctx.asyncHandler
|
||||
|
||||
@@ -94,8 +94,12 @@ async function logError(ERROR_LOG_FILE, MAX_ERROR_LOG_SIZE, context, error, addi
|
||||
* Return a safe error message without leaking internals
|
||||
*/
|
||||
function safeErrorMessage(error) {
|
||||
if (!error) return 'An internal error occurred';
|
||||
const msg = error.message || String(error);
|
||||
|
||||
// Always expose DC-prefixed user-facing errors
|
||||
if (/\[DC-\d+\]/.test(msg)) return msg;
|
||||
|
||||
// Detect port conflict errors
|
||||
const portMatch = msg.match(/exposing port TCP [^:]*:(\d+)/);
|
||||
if (portMatch || msg.includes('port is already allocated') || msg.includes('ports are not available')) {
|
||||
@@ -103,7 +107,7 @@ function safeErrorMessage(error) {
|
||||
return `[DC-200] Port ${port} is already in use. Try a different port or stop the service using that port first.`;
|
||||
}
|
||||
|
||||
// Only expose short, user-facing messages
|
||||
// Only expose short, user-facing messages (no paths, stack traces, or internal details)
|
||||
if (msg.length < 200 && !msg.includes('/') && !msg.includes('\\') && !msg.includes(' at ')) {
|
||||
return msg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user