Add full REST API for all deployment operations (projects, servers, docker)

Port all IPC handlers to HTTP endpoints so the UI and LLM use the same
API. Adds routes/projects.js (scan, compare, init), routes/servers.js
(CRUD, containers, logs), routes/docker.js (build, deploy, pull, vscode-diff).
Enhanced ssh.js with full SSHService class (SFTP upload/download).
Updated renderer api.js to use fetch instead of window.api IPC.
Added concurrently for npm run dev (API + Vite + Electron).
OpenAPI spec now covers all 24 endpoints.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-27 11:17:40 -06:00
parent 93d40455d9
commit feec35ffce
9 changed files with 1329 additions and 153 deletions

View File

@@ -1,39 +1,312 @@
{
"openapi": "3.1.0",
"info": {
"title": "Coolify Deployment API",
"description": "REST API for managing Coolify applications, Traefik routing, and automated deployments. Used by both the desktop UI and LLM agents.",
"version": "1.0.0"
"title": "Docker Deployment & Coolify API",
"description": "REST API for managing Docker deployments, Coolify applications, Traefik routing, and server management. Used by both the desktop UI and LLM agents.",
"version": "2.0.0"
},
"servers": [
{ "url": "http://localhost:3100", "description": "Local dev" }
],
"tags": [
{ "name": "Projects", "description": "Local project scanning and comparison" },
{ "name": "Servers", "description": "Deployment server CRUD and remote scanning" },
{ "name": "Docker", "description": "Build, deploy, pull files" },
{ "name": "Coolify Apps", "description": "Coolify application management" },
{ "name": "Coolify Environment", "description": "App environment variables" },
{ "name": "Coolify Deploy", "description": "Deployment pipelines and drift checks" },
{ "name": "Coolify Infrastructure", "description": "Traefik routes and port management" },
{ "name": "System", "description": "Health checks and config" }
],
"paths": {
"/api/coolify/apps": {
"/api/projects": {
"get": {
"operationId": "listApps",
"summary": "List all Coolify apps",
"description": "Returns all applications from Coolify, enriched with HOST_PORT env vars and env list.",
"tags": ["Apps"],
"operationId": "scanLocalProjects",
"summary": "Scan local projects",
"description": "Scans the configured projectsRoot directory for projects with Dockerfiles, docker-compose files, coolify.json, etc.",
"tags": ["Projects"],
"responses": {
"200": {
"description": "Array of Coolify applications",
"content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/App" } } } }
"description": "Array of local project info",
"content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/LocalProject" } } } }
}
}
},
}
},
"/api/projects/compare": {
"post": {
"operationId": "createApp",
"summary": "Create a new Coolify application",
"tags": ["Apps"],
"operationId": "compareProject",
"summary": "Compare local vs deployed files",
"description": "Compares docker-compose.yml, .env, data/, and additional configured files between local and remote.",
"tags": ["Projects"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/CreateAppRequest" }
"schema": {
"type": "object",
"properties": {
"projectPath": { "type": "string", "description": "Absolute local path to the project" },
"serverId": { "type": "string", "description": "Server ID to compare against" },
"remotePath": { "type": "string", "description": "Remote path (e.g. ~/containers/myapp)" }
},
"required": ["projectPath", "serverId", "remotePath"]
}
}
}
},
"responses": {
"200": { "description": "Comparison result with file-by-file diff statuses" }
}
}
},
"/api/projects/init": {
"post": {
"operationId": "initProject",
"summary": "Initialize a project with deployment config",
"tags": ["Projects"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"projectPath": { "type": "string" }
},
"required": ["projectPath"]
}
}
}
},
"responses": {
"200": { "description": "Init result" }
}
}
},
"/api/servers": {
"get": {
"operationId": "listServers",
"summary": "List deployment servers",
"tags": ["Servers"],
"responses": {
"200": {
"description": "Array of configured servers",
"content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Server" } } } }
}
}
},
"post": {
"operationId": "saveServer",
"summary": "Add or update a server",
"tags": ["Servers"],
"requestBody": {
"required": true,
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/Server" } } }
},
"responses": {
"200": { "description": "Saved server" }
}
}
},
"/api/servers/{id}": {
"delete": {
"operationId": "deleteServer",
"summary": "Delete a server",
"tags": ["Servers"],
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }
],
"responses": {
"200": { "description": "Deletion confirmation" }
}
}
},
"/api/servers/{id}/scan": {
"get": {
"operationId": "scanServer",
"summary": "Scan remote server for deployed containers",
"description": "Lists ~/containers on the remote server and inspects each for docker-compose.yml, .env, data/, etc.",
"tags": ["Servers"],
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }
],
"responses": {
"200": { "description": "Array of deployed projects on the server" }
}
}
},
"/api/servers/{id}/containers": {
"get": {
"operationId": "getRunningContainers",
"summary": "List running Docker containers on server",
"tags": ["Servers"],
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }
],
"responses": {
"200": {
"description": "Array of running containers",
"content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean" }, "containers": { "type": "array", "items": { "$ref": "#/components/schemas/Container" } } } } } }
}
}
}
},
"/api/servers/{id}/logs": {
"get": {
"operationId": "getContainerLogs",
"summary": "Get container logs from server",
"tags": ["Servers"],
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } },
{ "name": "containerName", "in": "query", "schema": { "type": "string" } },
{ "name": "remotePath", "in": "query", "schema": { "type": "string" } },
{ "name": "lines", "in": "query", "schema": { "type": "integer", "default": 100 } }
],
"responses": {
"200": { "description": "Container logs" }
}
}
},
"/api/docker/build": {
"post": {
"operationId": "buildTar",
"summary": "Build Docker image tar for a project",
"description": "Runs the project's build-image-tar.ps1 script to create a .tar image file.",
"tags": ["Docker"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"projectPath": { "type": "string" }
},
"required": ["projectPath"]
}
}
}
},
"responses": {
"200": { "description": "Build result with output" }
}
}
},
"/api/docker/deploy": {
"post": {
"operationId": "deployProject",
"summary": "Deploy project to server via SSH",
"description": "Uploads tar + compose + env files, loads Docker image, runs docker compose up. Includes health check polling.",
"tags": ["Docker"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"projectPath": { "type": "string", "description": "Local project path" },
"serverId": { "type": "string", "description": "Target server ID" },
"remotePath": { "type": "string", "description": "Remote deploy path (e.g. ~/containers/myapp)" }
},
"required": ["projectPath", "serverId", "remotePath"]
}
}
}
},
"responses": {
"200": {
"description": "Deploy result with health status",
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/DeployResult" } } }
}
}
}
},
"/api/docker/pull": {
"post": {
"operationId": "pullFiles",
"summary": "Pull files from remote server",
"description": "Downloads files/directories from the remote server to local paths via SFTP.",
"tags": ["Docker"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"serverId": { "type": "string" },
"files": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"remotePath": { "type": "string" },
"localPath": { "type": "string" },
"type": { "type": "string", "enum": ["file", "directory"] }
}
}
}
},
"required": ["serverId", "files"]
}
}
}
},
"responses": {
"200": { "description": "Pull result with pulled/errors arrays" }
}
}
},
"/api/docker/vscode-diff": {
"post": {
"operationId": "openVSCodeDiff",
"summary": "Open VS Code diff between local and remote file",
"tags": ["Docker"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"serverId": { "type": "string" },
"localPath": { "type": "string" },
"remoteFilePath": { "type": "string" }
},
"required": ["serverId", "localPath", "remoteFilePath"]
}
}
}
},
"responses": {
"200": { "description": "Success or error" }
}
}
},
"/api/coolify/apps": {
"get": {
"operationId": "listCoolifyApps",
"summary": "List all Coolify apps",
"description": "Returns all applications from Coolify, enriched with HOST_PORT env vars.",
"tags": ["Coolify Apps"],
"responses": {
"200": {
"description": "Array of Coolify applications",
"content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/CoolifyApp" } } } }
}
}
},
"post": {
"operationId": "createCoolifyApp",
"summary": "Create a new Coolify application",
"tags": ["Coolify Apps"],
"requestBody": {
"required": true,
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateCoolifyAppRequest" } } }
},
"responses": {
"200": { "description": "Created app object" }
}
@@ -41,9 +314,9 @@
},
"/api/coolify/apps/find/{name}": {
"get": {
"operationId": "findApp",
"summary": "Find app by name",
"tags": ["Apps"],
"operationId": "findCoolifyApp",
"summary": "Find Coolify app by name",
"tags": ["Coolify Apps"],
"parameters": [
{ "name": "name", "in": "path", "required": true, "schema": { "type": "string" } }
],
@@ -54,9 +327,9 @@
},
"/api/coolify/apps/{uuid}": {
"patch": {
"operationId": "updateApp",
"summary": "Update an existing app",
"tags": ["Apps"],
"operationId": "updateCoolifyApp",
"summary": "Update an existing Coolify app",
"tags": ["Coolify Apps"],
"parameters": [
{ "name": "uuid", "in": "path", "required": true, "schema": { "type": "string" } }
],
@@ -64,38 +337,32 @@
"required": true,
"content": { "application/json": { "schema": { "type": "object" } } }
},
"responses": {
"200": { "description": "Updated app" }
}
"responses": { "200": { "description": "Updated app" } }
},
"delete": {
"operationId": "deleteApp",
"summary": "Delete an app from Coolify",
"tags": ["Apps"],
"operationId": "deleteCoolifyApp",
"summary": "Delete a Coolify app",
"tags": ["Coolify Apps"],
"parameters": [
{ "name": "uuid", "in": "path", "required": true, "schema": { "type": "string" } }
],
"responses": {
"200": { "description": "Deletion confirmation" }
}
"responses": { "200": { "description": "Deletion confirmation" } }
}
},
"/api/coolify/apps/{uuid}/envs": {
"get": {
"operationId": "listEnvs",
"summary": "List env vars for an app",
"tags": ["Environment"],
"operationId": "listCoolifyEnvs",
"summary": "List env vars for a Coolify app",
"tags": ["Coolify Environment"],
"parameters": [
{ "name": "uuid", "in": "path", "required": true, "schema": { "type": "string" } }
],
"responses": {
"200": { "description": "Array of env vars" }
}
"responses": { "200": { "description": "Array of env vars" } }
},
"post": {
"operationId": "setEnv",
"operationId": "setCoolifyEnv",
"summary": "Set an environment variable",
"tags": ["Environment"],
"tags": ["Coolify Environment"],
"parameters": [
{ "name": "uuid", "in": "path", "required": true, "schema": { "type": "string" } }
],
@@ -114,40 +381,34 @@
}
}
},
"responses": {
"200": { "description": "Env var created/updated" }
}
"responses": { "200": { "description": "Env var created/updated" } }
}
},
"/api/coolify/apps/{uuid}/deploy": {
"post": {
"operationId": "deployApp",
"summary": "Trigger deployment for an app",
"tags": ["Deploy"],
"operationId": "deployCoolifyApp",
"summary": "Trigger Coolify deployment",
"tags": ["Coolify Deploy"],
"parameters": [
{ "name": "uuid", "in": "path", "required": true, "schema": { "type": "string" } }
],
"responses": {
"200": { "description": "Deployment triggered" }
}
"responses": { "200": { "description": "Deployment triggered" } }
}
},
"/api/coolify/servers": {
"get": {
"operationId": "listServers",
"operationId": "listCoolifyServers",
"summary": "List all Coolify servers",
"tags": ["Servers"],
"responses": {
"200": { "description": "Array of servers" }
}
"tags": ["Coolify Infrastructure"],
"responses": { "200": { "description": "Array of Coolify servers" } }
}
},
"/api/coolify/next-port": {
"get": {
"operationId": "getNextPort",
"summary": "Get next available HOST_PORT",
"description": "Scans Coolify env vars and Traefik config to find the highest used port, returns max+1.",
"tags": ["Infrastructure"],
"description": "Scans Coolify env vars and Traefik config to find the highest used port.",
"tags": ["Coolify Infrastructure"],
"responses": {
"200": {
"description": "Next port info",
@@ -168,9 +429,9 @@
},
"/api/coolify/routes": {
"post": {
"operationId": "addRoute",
"operationId": "addTraefikRoute",
"summary": "Add a Traefik route via SSH",
"tags": ["Infrastructure"],
"tags": ["Coolify Infrastructure"],
"requestBody": {
"required": true,
"content": {
@@ -178,25 +439,23 @@
"schema": {
"type": "object",
"properties": {
"routeName": { "type": "string", "description": "Traefik service/router name (alphanumeric)" },
"domain": { "type": "string", "description": "Domain name (e.g. timer.dotrepo.com)" },
"port": { "type": "integer", "description": "HOST_PORT on target server" }
"routeName": { "type": "string" },
"domain": { "type": "string" },
"port": { "type": "integer" }
},
"required": ["routeName", "domain", "port"]
}
}
}
},
"responses": {
"200": { "description": "Route added or already exists" }
}
"responses": { "200": { "description": "Route added or already exists" } }
}
},
"/api/coolify/drift": {
"post": {
"operationId": "checkDrift",
"summary": "Check drift between coolify.json and live Coolify state",
"tags": ["Deploy"],
"summary": "Check drift between coolify.json and live state",
"tags": ["Coolify Deploy"],
"requestBody": {
"required": true,
"content": {
@@ -204,25 +463,23 @@
"schema": {
"type": "object",
"properties": {
"projectPath": { "type": "string", "description": "Absolute path to project directory" },
"appName": { "type": "string", "description": "Optional app name when coolify.json has multiple entries" }
"projectPath": { "type": "string" },
"appName": { "type": "string" }
},
"required": ["projectPath"]
}
}
}
},
"responses": {
"200": { "description": "Drift check result with diffs" }
}
"responses": { "200": { "description": "Drift check result" } }
}
},
"/api/coolify/upsert": {
"post": {
"operationId": "upsertApp",
"summary": "Full deploy pipeline: read config → create/update → env → route → deploy",
"description": "Reads coolify.json from the project, creates or updates the Coolify app, sets HOST_PORT, configures Traefik routing, writes changelog, and triggers deployment. This is the primary endpoint for deploying apps.",
"tags": ["Deploy"],
"operationId": "upsertCoolifyApp",
"summary": "Full deploy pipeline: config → create/update → env → route → deploy",
"description": "Reads coolify.json, creates or updates the Coolify app, sets HOST_PORT, configures Traefik, writes changelog, and triggers deployment.",
"tags": ["Coolify Deploy"],
"requestBody": {
"required": true,
"content": {
@@ -230,8 +487,8 @@
"schema": {
"type": "object",
"properties": {
"projectPath": { "type": "string", "description": "Absolute path to project directory containing coolify.json" },
"appName": { "type": "string", "description": "Optional app name when coolify.json has multiple entries" }
"projectPath": { "type": "string" },
"appName": { "type": "string" }
},
"required": ["projectPath"]
}
@@ -240,12 +497,8 @@
},
"responses": {
"200": {
"description": "Upsert result with steps and changelog",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/UpsertResult" }
}
}
"description": "Upsert result with steps",
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/UpsertResult" } } }
}
}
}
@@ -253,14 +506,12 @@
"/api/coolify/config": {
"get": {
"operationId": "readCoolifyConfig",
"summary": "Read coolify.json from a project directory",
"tags": ["Config"],
"summary": "Read coolify.json from a project",
"tags": ["System"],
"parameters": [
{ "name": "path", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Absolute path to project directory" }
{ "name": "path", "in": "query", "required": true, "schema": { "type": "string" } }
],
"responses": {
"200": { "description": "Parsed coolify.json contents" }
}
"responses": { "200": { "description": "Parsed coolify.json" } }
}
},
"/api/health": {
@@ -268,15 +519,55 @@
"operationId": "healthCheck",
"summary": "Health check",
"tags": ["System"],
"responses": {
"200": { "description": "Server status" }
}
"responses": { "200": { "description": "Server status" } }
}
}
},
"components": {
"schemas": {
"App": {
"LocalProject": {
"type": "object",
"properties": {
"name": { "type": "string" },
"path": { "type": "string" },
"hasDockerfile": { "type": "boolean" },
"hasDockerCompose": { "type": "boolean" },
"hasCoolifyJson": { "type": "boolean" },
"dockerStatus": { "type": "string", "enum": ["none", "partial", "configured"] },
"tarFile": { "type": "string", "nullable": true },
"serverId": { "type": "string", "nullable": true },
"remotePath": { "type": "string" }
}
},
"Server": {
"type": "object",
"properties": {
"id": { "type": "string" },
"name": { "type": "string" },
"host": { "type": "string" },
"username": { "type": "string" },
"useSudo": { "type": "boolean" }
}
},
"Container": {
"type": "object",
"properties": {
"name": { "type": "string" },
"status": { "type": "string" },
"ports": { "type": "string" }
}
},
"DeployResult": {
"type": "object",
"properties": {
"success": { "type": "boolean" },
"healthy": { "type": "boolean" },
"status": { "type": "string" },
"uploadedFiles": { "type": "array", "items": { "type": "string" } },
"message": { "type": "string" }
}
},
"CoolifyApp": {
"type": "object",
"properties": {
"uuid": { "type": "string" },
@@ -290,19 +581,19 @@
"_envs": { "type": "array" }
}
},
"CreateAppRequest": {
"CreateCoolifyAppRequest": {
"type": "object",
"properties": {
"name": { "type": "string", "description": "App name in Coolify" },
"name": { "type": "string" },
"buildpack": { "type": "string", "enum": ["dockercompose", "nixpacks"], "default": "dockercompose" },
"gitRepo": { "type": "string", "description": "Git SSH URL" },
"gitRepo": { "type": "string" },
"gitBranch": { "type": "string", "default": "master" },
"isStatic": { "type": "boolean", "default": false },
"publishDir": { "type": "string", "default": "dist" },
"portsExposes": { "type": "string", "default": "3000" },
"baseDirectory": { "type": "string", "default": "/" },
"dockerComposeLocation": { "type": "string", "default": "/docker-compose.yml" },
"serverUuid": { "type": "string", "description": "Override server UUID" }
"serverUuid": { "type": "string" }
},
"required": ["name", "gitRepo"]
},