feat(appstore): add service volumes and published ports

This commit is contained in:
2026-05-24 07:28:18 +00:00
parent e6ebac76b4
commit 5228eeaa23
26 changed files with 1790 additions and 348 deletions
+42 -8
View File
@@ -14,17 +14,19 @@ export class ServiceRepository extends BaseRepository {
const now = Date.now();
this.query(
`INSERT INTO services (
name, image, registry, env_vars, port, domain, container_id, status,
name, image, registry, env_vars, volumes, published_ports, port, domain, container_id, status,
created_at, updated_at,
use_onebox_registry, registry_repository, registry_image_tag,
auto_update_on_push, image_digest, platform_requirements,
app_template_id, app_template_version
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
[
service.name,
service.image,
service.registry || null,
JSON.stringify(service.envVars),
JSON.stringify(service.volumes || []),
JSON.stringify(service.publishedPorts || []),
service.port,
service.domain || null,
service.containerID || null,
@@ -82,6 +84,14 @@ export class ServiceRepository extends BaseRepository {
fields.push('env_vars = ?');
values.push(JSON.stringify(updates.envVars));
}
if (updates.volumes !== undefined) {
fields.push('volumes = ?');
values.push(JSON.stringify(updates.volumes));
}
if (updates.publishedPorts !== undefined) {
fields.push('published_ports = ?');
values.push(JSON.stringify(updates.publishedPorts));
}
if (updates.port !== undefined) {
fields.push('port = ?');
values.push(updates.port);
@@ -169,18 +179,42 @@ export class ServiceRepository extends BaseRepository {
}
}
let volumes = [];
const volumesRaw = row.volumes ?? row[20];
if (volumesRaw && volumesRaw !== 'undefined' && volumesRaw !== 'null') {
try {
volumes = JSON.parse(String(volumesRaw));
} catch (e) {
logger.warn(`Failed to parse volumes for service: ${getErrorMessage(e)}`);
volumes = [];
}
}
let publishedPorts = [];
const publishedPortsRaw = row.published_ports;
if (publishedPortsRaw && publishedPortsRaw !== 'undefined' && publishedPortsRaw !== 'null') {
try {
publishedPorts = JSON.parse(String(publishedPortsRaw));
} catch (e) {
logger.warn(`Failed to parse published_ports for service: ${getErrorMessage(e)}`);
publishedPorts = [];
}
}
return {
id: Number(row.id || row[0]),
name: String(row.name || row[1]),
image: String(row.image || row[2]),
registry: (row.registry || row[3]) ? String(row.registry || row[3]) : undefined,
envVars,
port: Number(row.port || row[5]),
domain: (row.domain || row[6]) ? String(row.domain || row[6]) : undefined,
containerID: (row.container_id || row[7]) ? String(row.container_id || row[7]) : undefined,
status: String(row.status || row[8]) as IService['status'],
createdAt: Number(row.created_at || row[9]),
updatedAt: Number(row.updated_at || row[10]),
volumes,
publishedPorts,
port: Number(row.port ?? row[6] ?? row[5]),
domain: (row.domain ?? row[7] ?? row[6]) ? String(row.domain ?? row[7] ?? row[6]) : undefined,
containerID: (row.container_id ?? row[8] ?? row[7]) ? String(row.container_id ?? row[8] ?? row[7]) : undefined,
status: String(row.status ?? row[9] ?? row[8]) as IService['status'],
createdAt: Number(row.created_at ?? row[10] ?? row[9]),
updatedAt: Number(row.updated_at ?? row[11] ?? row[10]),
useOneboxRegistry: row.use_onebox_registry ? Boolean(row.use_onebox_registry) : undefined,
registryRepository: row.registry_repository ? String(row.registry_repository) : undefined,
registryImageTag: row.registry_image_tag ? String(row.registry_image_tag) : undefined,