Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e68e875ac | |||
| a30260e336 | |||
| be53f179ab | |||
| db52934f35 | |||
| d29257dcf7 | |||
| 3b2b806165 | |||
| 070c936a69 | |||
| 3f15cbda80 |
@@ -3,6 +3,44 @@
|
|||||||
## Pending
|
## Pending
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-05-25 - 2.0.0
|
||||||
|
|
||||||
|
### Breaking Changes
|
||||||
|
|
||||||
|
- switch Onebox App Store resolution to the shared appstore client
|
||||||
|
- Uses `@serve.zone/appstore` and `@serve.zone/interfaces` for App Store metadata, parsing, and Docker digest resolution
|
||||||
|
- Renames App Store typed request methods to `getAppStoreTemplates`, `getAppStoreConfig`, `installAppStoreApp`, and `getUpgradeableAppStoreServices`
|
||||||
|
- Removes local duplicated App Store DTO and resolver code while preserving Onebox install and upgrade behavior
|
||||||
|
|
||||||
|
## 2026-05-25 - 1.31.0
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- resolve repo manifests and docker digest-tracked images (appstore)
|
||||||
|
- Add catalog source, resolved source, channel, runtime, upgrade strategy, and version metadata types for appstore manifests.
|
||||||
|
- Resolve catalog entries from repo manifests and pin digest-tracked Docker images using registry digests.
|
||||||
|
- Propagate resolved image digests into app version configs and service creation options.
|
||||||
|
- Add runtime coverage for repo manifest resolution and digest-tracked latest images.
|
||||||
|
|
||||||
|
## 2026-05-24 - 1.30.2
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
- reduce remaining reverse proxy wording to required legacy SmartProxy cleanup and migration identifiers
|
||||||
|
- clean up legacy reverse proxy naming for SmartProxy (smartproxy)
|
||||||
|
- Update legacy reverse proxy service naming and logs used during SmartProxy startup cleanup.
|
||||||
|
- Clarify migration and documentation wording for the legacy reverse proxy to SmartProxy transition.
|
||||||
|
- Bump @serve.zone/catalog to ^2.12.6 and add pnpm workspace build dependency settings.
|
||||||
|
|
||||||
|
## 2026-05-24 - 1.30.1
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
- align Onebox settings gateway cards with the dees-tile footer action pattern
|
||||||
|
- align settings gateway cards with dees-tile footer actions (settings-ui)
|
||||||
|
- Replaces custom gateway card wrappers with dees-tile header and footer slots.
|
||||||
|
- Uses tile-styled action buttons for Admin UI and dcrouter settings saves.
|
||||||
|
|
||||||
## 2026-05-24 - 1.30.0
|
## 2026-05-24 - 1.30.0
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@serve.zone/onebox",
|
"name": "@serve.zone/onebox",
|
||||||
"version": "1.30.0",
|
"version": "2.0.0",
|
||||||
"exports": "./mod.ts",
|
"exports": "./mod.ts",
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"test": "deno test --allow-all test/",
|
"test": "deno test --allow-all test/",
|
||||||
@@ -27,7 +27,9 @@
|
|||||||
"@push.rocks/smartguard": "npm:@push.rocks/smartguard@^3.1.0",
|
"@push.rocks/smartguard": "npm:@push.rocks/smartguard@^3.1.0",
|
||||||
"@push.rocks/smartjwt": "npm:@push.rocks/smartjwt@^2.2.2",
|
"@push.rocks/smartjwt": "npm:@push.rocks/smartjwt@^2.2.2",
|
||||||
"@api.global/typedsocket": "npm:@api.global/typedsocket@^4.1.3",
|
"@api.global/typedsocket": "npm:@api.global/typedsocket@^4.1.3",
|
||||||
"@serve.zone/containerarchive": "npm:@serve.zone/containerarchive@^0.1.3"
|
"@serve.zone/containerarchive": "npm:@serve.zone/containerarchive@^0.1.3",
|
||||||
|
"@serve.zone/interfaces": "npm:@serve.zone/interfaces@^6.0.0",
|
||||||
|
"@serve.zone/appstore": "npm:@serve.zone/appstore@^0.2.0"
|
||||||
},
|
},
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": [
|
"lib": [
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@serve.zone/onebox",
|
"name": "@serve.zone/onebox",
|
||||||
"version": "1.30.0",
|
"version": "2.0.0",
|
||||||
"description": "Self-hosted container platform with automatic SSL and DNS - a mini Heroku for single servers",
|
"description": "Self-hosted container platform with automatic SSL and DNS - a mini Heroku for single servers",
|
||||||
"main": "mod.ts",
|
"main": "mod.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -58,7 +58,9 @@
|
|||||||
"@api.global/typedsocket": "^4.1.3",
|
"@api.global/typedsocket": "^4.1.3",
|
||||||
"@design.estate/dees-catalog": "^3.81.0",
|
"@design.estate/dees-catalog": "^3.81.0",
|
||||||
"@design.estate/dees-element": "^2.2.4",
|
"@design.estate/dees-element": "^2.2.4",
|
||||||
"@serve.zone/catalog": "^2.12.5"
|
"@serve.zone/appstore": "^0.2.0",
|
||||||
|
"@serve.zone/catalog": "^2.12.6",
|
||||||
|
"@serve.zone/interfaces": "^6.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbundle": "^2.10.4",
|
"@git.zone/tsbundle": "^2.10.4",
|
||||||
|
|||||||
Generated
+27
-5
@@ -20,9 +20,15 @@ importers:
|
|||||||
'@design.estate/dees-element':
|
'@design.estate/dees-element':
|
||||||
specifier: ^2.2.4
|
specifier: ^2.2.4
|
||||||
version: 2.2.4
|
version: 2.2.4
|
||||||
|
'@serve.zone/appstore':
|
||||||
|
specifier: ^0.2.0
|
||||||
|
version: 0.2.0
|
||||||
'@serve.zone/catalog':
|
'@serve.zone/catalog':
|
||||||
specifier: ^2.12.5
|
specifier: ^2.12.6
|
||||||
version: 2.12.5(@tiptap/pm@2.27.2)
|
version: 2.12.6(@tiptap/pm@2.27.2)
|
||||||
|
'@serve.zone/interfaces':
|
||||||
|
specifier: ^6.0.0
|
||||||
|
version: 6.0.0
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@git.zone/tsbundle':
|
'@git.zone/tsbundle':
|
||||||
specifier: ^2.10.4
|
specifier: ^2.10.4
|
||||||
@@ -977,8 +983,14 @@ packages:
|
|||||||
'@sec-ant/readable-stream@0.4.1':
|
'@sec-ant/readable-stream@0.4.1':
|
||||||
resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==}
|
resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==}
|
||||||
|
|
||||||
'@serve.zone/catalog@2.12.5':
|
'@serve.zone/appstore@0.2.0':
|
||||||
resolution: {integrity: sha512-0AgHnxonJ7xyYdA02s4tN9/aZG8yBYml4sAA7AUt9fYpRtKYMuZXUcUOS3Rz/FvUu1PrKe7QLtex9VK5IqZDPw==}
|
resolution: {integrity: sha512-qt2LVaRpzfJdUywllm+F0njwnN3aHc2aZHEcjc9REn1VDT47UuUEGaKkfNiosGK0GJqb1hPI/GwyuGMe4H4q7w==}
|
||||||
|
|
||||||
|
'@serve.zone/catalog@2.12.6':
|
||||||
|
resolution: {integrity: sha512-FjieZNCHTCHufMre8OSP8bFP9L4DPL9yNtd7UMwD1yQ8wublgAq6eWrx6Tfb+3k8Hyof33BBt4rbFyrvIEBk+A==}
|
||||||
|
|
||||||
|
'@serve.zone/interfaces@6.0.0':
|
||||||
|
resolution: {integrity: sha512-nCidhOH0XlX+7e6xaJDq6fwnwaWasB/4w2LHkV7A96G+m+7EXZqbbaKSboUlaiGDly0dWNajk2FrYFo64ZucPA==}
|
||||||
|
|
||||||
'@tempfix/lenis@1.3.20':
|
'@tempfix/lenis@1.3.20':
|
||||||
resolution: {integrity: sha512-ypeB0FuHLHOCQXW4d0RQ69txPJJH+1CHcpsZIUdcv2t1vR0IVyQr2vHihtde9UOXhjzqEnUphWon/UcJNsa0YA==}
|
resolution: {integrity: sha512-ypeB0FuHLHOCQXW4d0RQ69txPJJH+1CHcpsZIUdcv2t1vR0IVyQr2vHihtde9UOXhjzqEnUphWon/UcJNsa0YA==}
|
||||||
@@ -3572,7 +3584,11 @@ snapshots:
|
|||||||
|
|
||||||
'@sec-ant/readable-stream@0.4.1': {}
|
'@sec-ant/readable-stream@0.4.1': {}
|
||||||
|
|
||||||
'@serve.zone/catalog@2.12.5(@tiptap/pm@2.27.2)':
|
'@serve.zone/appstore@0.2.0':
|
||||||
|
dependencies:
|
||||||
|
'@serve.zone/interfaces': 6.0.0
|
||||||
|
|
||||||
|
'@serve.zone/catalog@2.12.6(@tiptap/pm@2.27.2)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@design.estate/dees-catalog': 3.81.0(@tiptap/pm@2.27.2)
|
'@design.estate/dees-catalog': 3.81.0(@tiptap/pm@2.27.2)
|
||||||
'@design.estate/dees-domtools': 2.5.6
|
'@design.estate/dees-domtools': 2.5.6
|
||||||
@@ -3585,6 +3601,12 @@ snapshots:
|
|||||||
- supports-color
|
- supports-color
|
||||||
- vue
|
- vue
|
||||||
|
|
||||||
|
'@serve.zone/interfaces@6.0.0':
|
||||||
|
dependencies:
|
||||||
|
'@api.global/typedrequest-interfaces': 3.0.19
|
||||||
|
'@push.rocks/smartlog-interfaces': 3.0.2
|
||||||
|
'@tsclass/tsclass': 9.5.1
|
||||||
|
|
||||||
'@tempfix/lenis@1.3.20': {}
|
'@tempfix/lenis@1.3.20': {}
|
||||||
|
|
||||||
'@tempfix/webcontainer__api@1.6.1': {}
|
'@tempfix/webcontainer__api@1.6.1': {}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
allowBuilds:
|
||||||
|
esbuild: true
|
||||||
|
ignoredBuiltDependencies:
|
||||||
|
- '@design.estate/dees-catalog'
|
||||||
+1
-1
@@ -46,7 +46,7 @@ ts/database/
|
|||||||
|
|
||||||
## Current Migration Version: 15
|
## Current Migration Version: 15
|
||||||
|
|
||||||
Migration 15 renames the core reverse proxy platform service from `caddy` to `smartproxy`.
|
Migration 15 renames the legacy core reverse proxy platform service type to `smartproxy`.
|
||||||
|
|
||||||
## Reverse Proxy (April 2026 - SmartProxy Docker Service)
|
## Reverse Proxy (April 2026 - SmartProxy Docker Service)
|
||||||
|
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ onebox config set cloudflareZoneId zone-id
|
|||||||
|
|
||||||
## App Store
|
## App Store
|
||||||
|
|
||||||
The App Store manager fetches catalog data from `serve.zone/appstore-apptemplates` and caches it briefly. Templates can declare platform requirements, so installing an app can automatically provision MongoDB, S3-compatible storage, ClickHouse, Redis, or MariaDB resources and inject the resulting credentials as environment variables.
|
The App Store manager fetches metadata from `serve.zone/appstore` through `@serve.zone/appstore` and caches it briefly. Templates can declare platform requirements, so installing an app can automatically provision MongoDB, S3-compatible storage, ClickHouse, Redis, or MariaDB resources and inject the resulting credentials as environment variables.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
onebox appstore list
|
onebox appstore list
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ import { assertEquals, assertThrows } from '@std/assert';
|
|||||||
|
|
||||||
import { AppStoreManager } from '../ts/classes/appstore.ts';
|
import { AppStoreManager } from '../ts/classes/appstore.ts';
|
||||||
import { OneboxDockerManager } from '../ts/classes/docker.ts';
|
import { OneboxDockerManager } from '../ts/classes/docker.ts';
|
||||||
import type { IAppVersionConfig } from '../ts/classes/appstore-types.ts';
|
import type * as servezoneInterfaces from '@serve.zone/interfaces';
|
||||||
import type { IService } from '../ts/types.ts';
|
import type { IService } from '../ts/types.ts';
|
||||||
|
|
||||||
|
type IAppStoreVersionConfig = servezoneInterfaces.appstore.IAppStoreVersionConfig;
|
||||||
|
|
||||||
const createAppStore = () => new AppStoreManager({} as any);
|
const createAppStore = () => new AppStoreManager({} as any);
|
||||||
|
|
||||||
const baseConfig: IAppVersionConfig = {
|
const baseConfig: IAppStoreVersionConfig = {
|
||||||
image: 'example/app:1.0.0',
|
image: 'example/app:1.0.0',
|
||||||
port: 3000,
|
port: 3000,
|
||||||
envVars: [
|
envVars: [
|
||||||
@@ -81,6 +83,96 @@ Deno.test('appstore rejects invalid template ports and volumes', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test('appstore resolves repo manifests and docker digest-tracked latest images', async () => {
|
||||||
|
const appStoreBaseUrl = 'https://appstore.example.test';
|
||||||
|
const manifestUrl = 'https://code.example.test/cloudly/servezone.appstore.json';
|
||||||
|
const digest = 'sha256:1234567890abcdef';
|
||||||
|
|
||||||
|
const fakeFetch: typeof fetch = async (input, init) => {
|
||||||
|
const url = input instanceof Request ? input.url : input.toString();
|
||||||
|
const method = init?.method || 'GET';
|
||||||
|
|
||||||
|
if (url === `${appStoreBaseUrl}/appstore.resolved.json`) {
|
||||||
|
return new Response('not found', { status: 404 });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url === `${appStoreBaseUrl}/appstore.json`) {
|
||||||
|
return Response.json({
|
||||||
|
schemaVersion: 1,
|
||||||
|
updatedAt: '2026-05-24T00:00:00Z',
|
||||||
|
apps: [
|
||||||
|
{
|
||||||
|
id: 'cloudly',
|
||||||
|
name: 'Cloudly',
|
||||||
|
description: 'Central metadata can stay curated.',
|
||||||
|
category: 'Dev Tools',
|
||||||
|
latestVersion: '1.0.0',
|
||||||
|
source: {
|
||||||
|
type: 'repoManifest',
|
||||||
|
url: manifestUrl,
|
||||||
|
ref: 'main',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url === manifestUrl) {
|
||||||
|
return Response.json({
|
||||||
|
schemaVersion: 1,
|
||||||
|
app: {
|
||||||
|
id: 'cloudly',
|
||||||
|
name: 'Cloudly',
|
||||||
|
description: 'Manifest-owned app metadata.',
|
||||||
|
category: 'Dev Tools',
|
||||||
|
maintainer: 'serve.zone',
|
||||||
|
},
|
||||||
|
latestVersion: 'latest',
|
||||||
|
source: {
|
||||||
|
type: 'dockerImage',
|
||||||
|
image: 'registry.example.test/serve.zone/cloudly:latest',
|
||||||
|
tracking: 'digest',
|
||||||
|
},
|
||||||
|
runtime: {
|
||||||
|
image: 'registry.example.test/serve.zone/cloudly:latest',
|
||||||
|
port: 80,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
url === 'https://registry.example.test/v2/serve.zone/cloudly/manifests/latest' &&
|
||||||
|
method === 'HEAD'
|
||||||
|
) {
|
||||||
|
return new Response(null, {
|
||||||
|
status: 200,
|
||||||
|
headers: { 'docker-content-digest': digest },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response(`unexpected ${method} ${url}`, { status: 500 });
|
||||||
|
};
|
||||||
|
|
||||||
|
const appStore = new AppStoreManager({} as any, {
|
||||||
|
baseUrl: appStoreBaseUrl,
|
||||||
|
fetch: fakeFetch,
|
||||||
|
});
|
||||||
|
|
||||||
|
const appStoreIndex = await appStore.getAppStore();
|
||||||
|
assertEquals(appStoreIndex.apps[0].latestVersion, `latest@${digest}`);
|
||||||
|
assertEquals(appStoreIndex.apps[0].resolvedSource?.manifestHash?.length, 64);
|
||||||
|
assertEquals(appStoreIndex.apps[0].upgradeStrategy, 'dockerDigest');
|
||||||
|
|
||||||
|
const appMeta = await appStore.getAppMeta('cloudly');
|
||||||
|
assertEquals(appMeta.latestVersion, `latest@${digest}`);
|
||||||
|
assertEquals(appMeta.versions, [`latest@${digest}`]);
|
||||||
|
|
||||||
|
const config = await appStore.getAppVersionConfig('cloudly', appMeta.latestVersion);
|
||||||
|
assertEquals(config.image, 'registry.example.test/serve.zone/cloudly:latest');
|
||||||
|
assertEquals(config.appStoreVersion, `latest@${digest}`);
|
||||||
|
assertEquals(config.resolvedImageDigest, digest);
|
||||||
|
});
|
||||||
|
|
||||||
Deno.test('docker service spec validation rejects unsafe volume and port declarations', () => {
|
Deno.test('docker service spec validation rejects unsafe volume and port declarations', () => {
|
||||||
const dockerManager = new OneboxDockerManager();
|
const dockerManager = new OneboxDockerManager();
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@serve.zone/onebox',
|
name: '@serve.zone/onebox',
|
||||||
version: '1.30.0',
|
version: '2.0.0',
|
||||||
description: 'Self-hosted container platform with automatic SSL and DNS - a mini Heroku for single servers'
|
description: 'Self-hosted container platform with automatic SSL and DNS - a mini Heroku for single servers'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
/**
|
|
||||||
* App Store type definitions
|
|
||||||
*/
|
|
||||||
|
|
||||||
export interface ICatalog {
|
|
||||||
schemaVersion: number;
|
|
||||||
updatedAt: string;
|
|
||||||
apps: ICatalogApp[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ICatalogApp {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
description: string;
|
|
||||||
category: string;
|
|
||||||
iconName?: string;
|
|
||||||
iconUrl?: string;
|
|
||||||
latestVersion: string;
|
|
||||||
tags?: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IAppCatalogVolume {
|
|
||||||
name?: string;
|
|
||||||
source?: string;
|
|
||||||
mountPath: string;
|
|
||||||
driver?: string;
|
|
||||||
readOnly?: boolean;
|
|
||||||
backup?: boolean;
|
|
||||||
options?: Record<string, string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type TAppCatalogVolumeSpec = string | IAppCatalogVolume;
|
|
||||||
|
|
||||||
export interface IAppCatalogPublishedPort {
|
|
||||||
targetPort: number;
|
|
||||||
targetPortEnd?: number;
|
|
||||||
publishedPort?: number;
|
|
||||||
publishedPortEnd?: number;
|
|
||||||
protocol?: 'tcp' | 'udp';
|
|
||||||
hostIp?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IAppMeta {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
description: string;
|
|
||||||
category: string;
|
|
||||||
iconName?: string;
|
|
||||||
latestVersion: string;
|
|
||||||
versions: string[];
|
|
||||||
maintainer?: string;
|
|
||||||
links?: Record<string, string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IAppVersionConfig {
|
|
||||||
image: string;
|
|
||||||
port: number;
|
|
||||||
envVars?: Array<{ key: string; value: string; description: string; required?: boolean }>;
|
|
||||||
volumes?: TAppCatalogVolumeSpec[];
|
|
||||||
publishedPorts?: IAppCatalogPublishedPort[];
|
|
||||||
platformRequirements?: {
|
|
||||||
mongodb?: boolean;
|
|
||||||
s3?: boolean;
|
|
||||||
clickhouse?: boolean;
|
|
||||||
redis?: boolean;
|
|
||||||
mariadb?: boolean;
|
|
||||||
};
|
|
||||||
minOneboxVersion?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IAppInstallOptions {
|
|
||||||
appId: string;
|
|
||||||
version?: string;
|
|
||||||
serviceName: string;
|
|
||||||
domain?: string;
|
|
||||||
port?: number;
|
|
||||||
publishedPorts?: IAppCatalogPublishedPort[];
|
|
||||||
envVars?: Record<string, string>;
|
|
||||||
autoDNS?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IMigrationContext {
|
|
||||||
service: {
|
|
||||||
name: string;
|
|
||||||
image: string;
|
|
||||||
envVars: Record<string, string>;
|
|
||||||
port: number;
|
|
||||||
};
|
|
||||||
fromVersion: string;
|
|
||||||
toVersion: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IMigrationResult {
|
|
||||||
success: boolean;
|
|
||||||
envVars?: Record<string, string>;
|
|
||||||
image?: string;
|
|
||||||
port?: number;
|
|
||||||
volumes?: IAppCatalogVolume[];
|
|
||||||
publishedPorts?: IAppCatalogPublishedPort[];
|
|
||||||
warnings: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IUpgradeableService {
|
|
||||||
serviceName: string;
|
|
||||||
appTemplateId: string;
|
|
||||||
currentVersion: string;
|
|
||||||
latestVersion: string;
|
|
||||||
hasMigration: boolean;
|
|
||||||
}
|
|
||||||
+178
-282
@@ -1,117 +1,144 @@
|
|||||||
/**
|
/**
|
||||||
* App Store Manager
|
* App Store Manager
|
||||||
* Fetches, caches, and serves app templates from the remote appstore-apptemplates repo.
|
* Fetches, caches, and serves app templates from the remote App Store repo.
|
||||||
* The remote repo is the single source of truth — no fallback catalog.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type {
|
import * as plugins from '../plugins.ts';
|
||||||
ICatalog,
|
|
||||||
ICatalogApp,
|
|
||||||
IAppMeta,
|
|
||||||
IAppCatalogVolume,
|
|
||||||
IAppInstallOptions,
|
|
||||||
IAppVersionConfig,
|
|
||||||
IMigrationContext,
|
|
||||||
IMigrationResult,
|
|
||||||
IUpgradeableService,
|
|
||||||
} from './appstore-types.ts';
|
|
||||||
import { logger } from '../logging.ts';
|
import { logger } from '../logging.ts';
|
||||||
import { getErrorMessage } from '../utils/error.ts';
|
import { getErrorMessage } from '../utils/error.ts';
|
||||||
import type { Onebox } from './onebox.ts';
|
import type { Onebox } from './onebox.ts';
|
||||||
import type { IService, IServiceVolume } from '../types.ts';
|
import type { IService, IServicePublishedPort, IServiceVolume } from '../types.ts';
|
||||||
import { projectInfo } from '../info.ts';
|
import { projectInfo } from '../info.ts';
|
||||||
|
|
||||||
export class AppStoreManager {
|
type IAppStoreIndex = plugins.servezoneInterfaces.appstore.IAppStoreIndex;
|
||||||
private oneboxRef: Onebox;
|
type IAppStoreApp = plugins.servezoneInterfaces.appstore.IAppStoreApp;
|
||||||
private catalogCache: ICatalog | null = null;
|
type IAppStoreAppMeta = plugins.servezoneInterfaces.appstore.IAppStoreAppMeta;
|
||||||
private lastFetchTime = 0;
|
type IAppStoreVersionConfig = plugins.servezoneInterfaces.appstore.IAppStoreVersionConfig;
|
||||||
private readonly repoBaseUrl = 'https://code.foss.global/serve.zone/appstore-apptemplates/raw/branch/main';
|
type IAppStoreInstallOptions = plugins.servezoneInterfaces.appstore.IAppStoreInstallRequest & {
|
||||||
private readonly cacheTtlMs = 5 * 60 * 1000; // 5 minutes
|
autoDNS?: boolean;
|
||||||
|
};
|
||||||
|
type IUpgradeableAppStoreService = plugins.servezoneInterfaces.appstore.IUpgradeableAppStoreService;
|
||||||
|
|
||||||
constructor(oneboxRef: Onebox) {
|
export interface IAppStoreManagerOptions {
|
||||||
this.oneboxRef = oneboxRef;
|
baseUrl?: string;
|
||||||
|
fetch?: typeof fetch;
|
||||||
|
resolveDockerDigests?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
async init(): Promise<void> {
|
export interface IMigrationContext {
|
||||||
|
service: {
|
||||||
|
name: string;
|
||||||
|
image: string;
|
||||||
|
envVars: Record<string, string>;
|
||||||
|
port: number;
|
||||||
|
};
|
||||||
|
fromVersion: string;
|
||||||
|
toVersion: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IMigrationResult {
|
||||||
|
success: boolean;
|
||||||
|
envVars?: Record<string, string>;
|
||||||
|
image?: string;
|
||||||
|
imageDigest?: string;
|
||||||
|
port?: number;
|
||||||
|
volumes?: IServiceVolume[];
|
||||||
|
publishedPorts?: IServicePublishedPort[];
|
||||||
|
warnings: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AppStoreManager {
|
||||||
|
private appStoreCache: IAppStoreIndex | null = null;
|
||||||
|
private appStoreResolver: plugins.servezoneAppstore.AppStoreResolver;
|
||||||
|
private lastFetchTime = 0;
|
||||||
|
private readonly appStoreBaseUrl: string;
|
||||||
|
private readonly fetchRef: typeof fetch;
|
||||||
|
private readonly resolveDockerDigests: boolean;
|
||||||
|
private readonly cacheTtlMs = 5 * 60 * 1000;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private oneboxRef: Onebox,
|
||||||
|
optionsArg: IAppStoreManagerOptions = {},
|
||||||
|
) {
|
||||||
|
this.appStoreBaseUrl = optionsArg.baseUrl || 'https://code.foss.global/serve.zone/appstore/raw/branch/main';
|
||||||
|
this.fetchRef = optionsArg.fetch || fetch;
|
||||||
|
this.resolveDockerDigests = optionsArg.resolveDockerDigests ?? true;
|
||||||
|
this.appStoreResolver = this.createAppStoreResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async init(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await this.getCatalog();
|
await this.getAppStore();
|
||||||
logger.info(`App Store initialized with ${this.catalogCache?.apps.length || 0} templates`);
|
logger.info(`App Store initialized with ${this.appStoreCache?.apps.length || 0} templates`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.warn(`App Store initialization failed: ${getErrorMessage(error)}`);
|
logger.warn(`App Store initialization failed: ${getErrorMessage(error)}`);
|
||||||
logger.warn('App Store will retry on next request');
|
logger.warn('App Store will retry on next request');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public async getAppStore(): Promise<IAppStoreIndex> {
|
||||||
* Get the catalog (cached, refreshes after TTL)
|
|
||||||
*/
|
|
||||||
async getCatalog(): Promise<ICatalog> {
|
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
if (this.catalogCache && (now - this.lastFetchTime) < this.cacheTtlMs) {
|
if (this.appStoreCache && (now - this.lastFetchTime) < this.cacheTtlMs) {
|
||||||
return this.catalogCache;
|
return this.appStoreCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const catalog = await this.fetchJson('catalog.json') as ICatalog;
|
const resolver = this.createAppStoreResolver();
|
||||||
if (catalog && catalog.apps && Array.isArray(catalog.apps)) {
|
const appStore = await resolver.getAppStoreIndex();
|
||||||
this.catalogCache = catalog;
|
this.appStoreResolver = resolver;
|
||||||
|
this.appStoreCache = appStore;
|
||||||
this.lastFetchTime = now;
|
this.lastFetchTime = now;
|
||||||
return catalog;
|
return appStore;
|
||||||
}
|
|
||||||
throw new Error('Invalid catalog format');
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.warn(`Failed to fetch remote catalog: ${getErrorMessage(error)}`);
|
logger.warn(`Failed to fetch remote App Store: ${getErrorMessage(error)}`);
|
||||||
// Return cached if available, otherwise return empty catalog
|
if (this.appStoreCache) {
|
||||||
if (this.catalogCache) {
|
return this.appStoreCache;
|
||||||
return this.catalogCache;
|
|
||||||
}
|
}
|
||||||
return { schemaVersion: 1, updatedAt: '', apps: [] };
|
return { schemaVersion: 1, updatedAt: '', apps: [] };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public async getApps(): Promise<IAppStoreApp[]> {
|
||||||
* Get the catalog apps list (convenience method for the API)
|
return (await this.getAppStore()).apps;
|
||||||
*/
|
|
||||||
async getApps(): Promise<ICatalogApp[]> {
|
|
||||||
const catalog = await this.getCatalog();
|
|
||||||
return catalog.apps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public async getAppMeta(appIdArg: string): Promise<IAppStoreAppMeta> {
|
||||||
* Fetch app metadata (versions list, etc.)
|
|
||||||
*/
|
|
||||||
async getAppMeta(appId: string): Promise<IAppMeta> {
|
|
||||||
try {
|
try {
|
||||||
return await this.fetchJson(`apps/${appId}/app.json`) as IAppMeta;
|
await this.getAppStore();
|
||||||
|
return await this.appStoreResolver.getAppMeta(appIdArg);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`Failed to fetch metadata for app '${appId}': ${getErrorMessage(error)}`);
|
throw new Error(`Failed to fetch metadata for app '${appIdArg}': ${getErrorMessage(error)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public async getAppVersionConfig(
|
||||||
* Fetch full config for an app version
|
appIdArg: string,
|
||||||
*/
|
versionArg?: string,
|
||||||
async getAppVersionConfig(appId: string, version: string): Promise<IAppVersionConfig> {
|
): Promise<IAppStoreVersionConfig> {
|
||||||
try {
|
try {
|
||||||
const config = await this.fetchJson(`apps/${appId}/versions/${version}/config.json`) as IAppVersionConfig;
|
const version = versionArg || (await this.getAppMeta(appIdArg)).latestVersion;
|
||||||
this.validateAppVersionConfig(config, `${appId}@${version}`);
|
await this.getAppStore();
|
||||||
return config;
|
return await this.appStoreResolver.getAppVersionConfig(appIdArg, version);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`Failed to fetch config for ${appId}@${version}: ${getErrorMessage(error)}`);
|
throw new Error(`Failed to fetch config for ${appIdArg}@${versionArg || 'latest'}: ${getErrorMessage(error)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async installApp(optionsArg: IAppInstallOptions): Promise<IService> {
|
public async installApp(optionsArg: IAppStoreInstallOptions): Promise<IService> {
|
||||||
this.validateInstallOptions(optionsArg);
|
this.validateInstallOptions(optionsArg);
|
||||||
const appMeta = await this.getAppMeta(optionsArg.appId);
|
const appMeta = await this.getAppMeta(optionsArg.appId);
|
||||||
const version = optionsArg.version || appMeta.latestVersion;
|
const version = optionsArg.version || appMeta.latestVersion;
|
||||||
const config = await this.getAppVersionConfig(optionsArg.appId, version);
|
const config = await this.getAppVersionConfig(optionsArg.appId, version);
|
||||||
|
const appStoreVersion = config.appStoreVersion || version;
|
||||||
this.assertRuntimeCompatibility(config);
|
this.assertRuntimeCompatibility(config);
|
||||||
const servicePort = optionsArg.port || config.port;
|
const servicePort = optionsArg.port || config.port;
|
||||||
this.assertValidPort(servicePort, 'install service port');
|
this.assertValidPort(servicePort, 'install service port');
|
||||||
const volumes = this.normalizeVolumes(config.volumes);
|
const volumes = this.normalizeVolumes(config.volumes);
|
||||||
const publishedPorts = optionsArg.publishedPorts || config.publishedPorts || [];
|
const publishedPorts = optionsArg.publishedPorts || config.publishedPorts || [];
|
||||||
this.validatePublishedPorts(publishedPorts, `${optionsArg.appId}@${version}`);
|
this.validateAppVersionConfig(
|
||||||
|
{ ...config, port: servicePort, publishedPorts },
|
||||||
|
`${optionsArg.appId}@${version} install`,
|
||||||
|
);
|
||||||
|
|
||||||
const envVars = this.getAppStoreEnvVars(config, optionsArg.envVars || {});
|
const envVars = this.getAppStoreEnvVars(config, optionsArg.envVars || {});
|
||||||
if (this.requiresTemplateValue(envVars, 'SERVICE_DOMAIN') && !optionsArg.domain) {
|
if (this.requiresTemplateValue(envVars, 'SERVICE_DOMAIN') && !optionsArg.domain) {
|
||||||
@@ -133,105 +160,95 @@ export class AppStoreManager {
|
|||||||
enableRedis: Boolean(config.platformRequirements?.redis),
|
enableRedis: Boolean(config.platformRequirements?.redis),
|
||||||
enableMariaDB: Boolean(config.platformRequirements?.mariadb),
|
enableMariaDB: Boolean(config.platformRequirements?.mariadb),
|
||||||
appTemplateId: optionsArg.appId,
|
appTemplateId: optionsArg.appId,
|
||||||
appTemplateVersion: version,
|
appTemplateVersion: appStoreVersion,
|
||||||
|
imageDigest: config.resolvedImageDigest,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public async getUpgradeableAppStoreServices(): Promise<IUpgradeableAppStoreService[]> {
|
||||||
* Compare deployed services against catalog to find those with available upgrades
|
const appStore = await this.getAppStore();
|
||||||
*/
|
|
||||||
async getUpgradeableServices(): Promise<IUpgradeableService[]> {
|
|
||||||
const catalog = await this.getCatalog();
|
|
||||||
const services = this.oneboxRef.database.getAllServices();
|
const services = this.oneboxRef.database.getAllServices();
|
||||||
const upgradeable: IUpgradeableService[] = [];
|
const upgradeable: IUpgradeableAppStoreService[] = [];
|
||||||
|
|
||||||
for (const service of services) {
|
for (const service of services) {
|
||||||
if (!service.appTemplateId || !service.appTemplateVersion) continue;
|
if (!service.appTemplateId || !service.appTemplateVersion) continue;
|
||||||
|
|
||||||
const catalogApp = catalog.apps.find(a => a.id === service.appTemplateId);
|
const appStoreApp = appStore.apps.find((appArg: IAppStoreApp) => appArg.id === service.appTemplateId);
|
||||||
if (!catalogApp) continue;
|
if (!appStoreApp || appStoreApp.latestVersion === service.appTemplateVersion) continue;
|
||||||
|
|
||||||
if (catalogApp.latestVersion !== service.appTemplateVersion) {
|
|
||||||
// Check if a migration script exists
|
|
||||||
const hasMigration = await this.hasMigrationScript(
|
|
||||||
service.appTemplateId,
|
|
||||||
service.appTemplateVersion,
|
|
||||||
catalogApp.latestVersion,
|
|
||||||
);
|
|
||||||
|
|
||||||
upgradeable.push({
|
upgradeable.push({
|
||||||
serviceName: service.name,
|
serviceName: service.name,
|
||||||
appTemplateId: service.appTemplateId,
|
appTemplateId: service.appTemplateId,
|
||||||
currentVersion: service.appTemplateVersion,
|
currentVersion: service.appTemplateVersion,
|
||||||
latestVersion: catalogApp.latestVersion,
|
latestVersion: appStoreApp.latestVersion,
|
||||||
hasMigration,
|
hasMigration: await this.hasMigrationScript(
|
||||||
|
service.appTemplateId,
|
||||||
|
service.appTemplateVersion,
|
||||||
|
appStoreApp.latestVersion,
|
||||||
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return upgradeable;
|
return upgradeable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public async hasMigrationScript(
|
||||||
* Check if a migration script exists for a specific version transition
|
appIdArg: string,
|
||||||
*/
|
fromVersionArg: string,
|
||||||
async hasMigrationScript(appId: string, fromVersion: string, toVersion: string): Promise<boolean> {
|
toVersionArg: string,
|
||||||
|
): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const scriptPath = `apps/${appId}/versions/${toVersion}/migrate-from-${fromVersion}.ts`;
|
await this.fetchText(`apps/${appIdArg}/versions/${toVersionArg}/migrate-from-${fromVersionArg}.ts`);
|
||||||
await this.fetchText(scriptPath);
|
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public async executeMigration(
|
||||||
* Execute a migration in a sandboxed Deno child process
|
serviceArg: IService,
|
||||||
*/
|
fromVersionArg: string,
|
||||||
async executeMigration(service: IService, fromVersion: string, toVersion: string): Promise<IMigrationResult> {
|
toVersionArg: string,
|
||||||
const appId = service.appTemplateId;
|
): Promise<IMigrationResult> {
|
||||||
|
const appId = serviceArg.appTemplateId;
|
||||||
if (!appId) {
|
if (!appId) {
|
||||||
throw new Error('Service has no appTemplateId');
|
throw new Error('Service has no appTemplateId');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the migration script
|
const scriptPath = `apps/${appId}/versions/${toVersionArg}/migrate-from-${fromVersionArg}.ts`;
|
||||||
const scriptPath = `apps/${appId}/versions/${toVersion}/migrate-from-${fromVersion}.ts`;
|
|
||||||
let scriptContent: string;
|
let scriptContent: string;
|
||||||
try {
|
try {
|
||||||
scriptContent = await this.fetchText(scriptPath);
|
scriptContent = await this.fetchText(scriptPath);
|
||||||
} catch {
|
} catch {
|
||||||
// No migration script — do a simple config-based upgrade
|
logger.info(`No migration script for ${appId} ${fromVersionArg} -> ${toVersionArg}, using config-only upgrade`);
|
||||||
logger.info(`No migration script for ${appId} ${fromVersion} -> ${toVersion}, using config-only upgrade`);
|
const config = await this.getAppVersionConfig(appId, toVersionArg);
|
||||||
const config = await this.getAppVersionConfig(appId, toVersion);
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
image: config.image,
|
image: config.image,
|
||||||
|
imageDigest: config.resolvedImageDigest,
|
||||||
port: config.port,
|
port: config.port,
|
||||||
volumes: this.normalizeVolumes(config.volumes),
|
volumes: this.normalizeVolumes(config.volumes),
|
||||||
publishedPorts: config.publishedPorts,
|
publishedPorts: config.publishedPorts,
|
||||||
envVars: undefined, // Keep existing env vars
|
envVars: undefined,
|
||||||
warnings: [],
|
warnings: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write to temp file
|
|
||||||
const tempFile = `/tmp/onebox-migration-${crypto.randomUUID()}.ts`;
|
const tempFile = `/tmp/onebox-migration-${crypto.randomUUID()}.ts`;
|
||||||
await Deno.writeTextFile(tempFile, scriptContent);
|
await Deno.writeTextFile(tempFile, scriptContent);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Prepare context
|
|
||||||
const context: IMigrationContext = {
|
const context: IMigrationContext = {
|
||||||
service: {
|
service: {
|
||||||
name: service.name,
|
name: serviceArg.name,
|
||||||
image: service.image,
|
image: serviceArg.image,
|
||||||
envVars: service.envVars,
|
envVars: serviceArg.envVars,
|
||||||
port: service.port,
|
port: serviceArg.port,
|
||||||
},
|
},
|
||||||
fromVersion,
|
fromVersion: fromVersionArg,
|
||||||
toVersion,
|
toVersion: toVersionArg,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Execute in sandboxed Deno child process
|
|
||||||
const cmd = new Deno.Command('deno', {
|
const cmd = new Deno.Command('deno', {
|
||||||
args: ['run', '--allow-env', '--allow-net=none', '--allow-read=none', '--allow-write=none', tempFile],
|
args: ['run', '--allow-env', '--allow-net=none', '--allow-read=none', '--allow-write=none', tempFile],
|
||||||
stdin: 'piped',
|
stdin: 'piped',
|
||||||
@@ -240,27 +257,22 @@ export class AppStoreManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const child = cmd.spawn();
|
const child = cmd.spawn();
|
||||||
|
|
||||||
// Write context to stdin
|
|
||||||
const writer = child.stdin.getWriter();
|
const writer = child.stdin.getWriter();
|
||||||
await writer.write(new TextEncoder().encode(JSON.stringify(context)));
|
await writer.write(new TextEncoder().encode(JSON.stringify(context)));
|
||||||
await writer.close();
|
await writer.close();
|
||||||
|
|
||||||
// Read result
|
|
||||||
const output = await child.output();
|
const output = await child.output();
|
||||||
const exitCode = output.code;
|
|
||||||
const stdout = new TextDecoder().decode(output.stdout);
|
const stdout = new TextDecoder().decode(output.stdout);
|
||||||
const stderr = new TextDecoder().decode(output.stderr);
|
const stderr = new TextDecoder().decode(output.stderr);
|
||||||
|
|
||||||
if (exitCode !== 0) {
|
if (output.code !== 0) {
|
||||||
logger.error(`Migration script failed (exit ${exitCode}): ${stderr.substring(0, 500)}`);
|
logger.error(`Migration script failed (exit ${output.code}): ${stderr.substring(0, 500)}`);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
warnings: [`Migration script failed: ${stderr.substring(0, 200)}`],
|
warnings: [`Migration script failed: ${stderr.substring(0, 200)}`],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse result from stdout
|
|
||||||
try {
|
try {
|
||||||
const result = JSON.parse(stdout) as IMigrationResult;
|
const result = JSON.parse(stdout) as IMigrationResult;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
@@ -273,58 +285,49 @@ export class AppStoreManager {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
// Cleanup temp file
|
|
||||||
try {
|
try {
|
||||||
await Deno.remove(tempFile);
|
await Deno.remove(tempFile);
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore cleanup errors
|
// Ignore cleanup errors.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public async applyUpgrade(
|
||||||
* Apply an upgrade: update image, env vars, recreate container
|
serviceNameArg: string,
|
||||||
*/
|
migrationResultArg: IMigrationResult,
|
||||||
async applyUpgrade(
|
newVersionArg: string,
|
||||||
serviceName: string,
|
|
||||||
migrationResult: IMigrationResult,
|
|
||||||
newVersion: string,
|
|
||||||
): Promise<IService> {
|
): Promise<IService> {
|
||||||
const service = this.oneboxRef.database.getServiceByName(serviceName);
|
const service = this.oneboxRef.database.getServiceByName(serviceNameArg);
|
||||||
if (!service) {
|
if (!service) {
|
||||||
throw new Error(`Service not found: ${serviceName}`);
|
throw new Error(`Service not found: ${serviceNameArg}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop the existing container
|
|
||||||
if (service.containerID && service.status === 'running') {
|
if (service.containerID && service.status === 'running') {
|
||||||
await this.oneboxRef.services.stopService(serviceName);
|
await this.oneboxRef.services.stopService(serviceNameArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update service record
|
|
||||||
const updates: Partial<IService> = {
|
const updates: Partial<IService> = {
|
||||||
appTemplateVersion: newVersion,
|
appTemplateVersion: newVersionArg,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (migrationResult.image) {
|
if (migrationResultArg.image) {
|
||||||
updates.image = migrationResult.image;
|
updates.image = migrationResultArg.image;
|
||||||
}
|
}
|
||||||
|
if (migrationResultArg.imageDigest !== undefined) {
|
||||||
if (migrationResult.port) {
|
updates.imageDigest = migrationResultArg.imageDigest;
|
||||||
updates.port = migrationResult.port;
|
|
||||||
}
|
}
|
||||||
|
if (migrationResultArg.port) {
|
||||||
if (migrationResult.volumes) {
|
updates.port = migrationResultArg.port;
|
||||||
updates.volumes = migrationResult.volumes;
|
|
||||||
}
|
}
|
||||||
|
if (migrationResultArg.volumes) {
|
||||||
if (migrationResult.publishedPorts) {
|
updates.volumes = migrationResultArg.volumes;
|
||||||
updates.publishedPorts = migrationResult.publishedPorts;
|
|
||||||
}
|
}
|
||||||
|
if (migrationResultArg.publishedPorts) {
|
||||||
if (migrationResult.envVars) {
|
updates.publishedPorts = migrationResultArg.publishedPorts;
|
||||||
// Merge: migration result provides base, user overrides preserved
|
}
|
||||||
const mergedEnvVars = { ...migrationResult.envVars };
|
if (migrationResultArg.envVars) {
|
||||||
// Keep any user-set env vars that aren't in the migration result
|
const mergedEnvVars = { ...migrationResultArg.envVars };
|
||||||
for (const [key, value] of Object.entries(service.envVars)) {
|
for (const [key, value] of Object.entries(service.envVars)) {
|
||||||
if (!(key in mergedEnvVars)) {
|
if (!(key in mergedEnvVars)) {
|
||||||
mergedEnvVars[key] = value;
|
mergedEnvVars[key] = value;
|
||||||
@@ -335,98 +338,55 @@ export class AppStoreManager {
|
|||||||
|
|
||||||
this.oneboxRef.database.updateService(service.id!, updates);
|
this.oneboxRef.database.updateService(service.id!, updates);
|
||||||
|
|
||||||
// Pull new image if changed
|
const newImage = migrationResultArg.image || service.image;
|
||||||
const newImage = migrationResult.image || service.image;
|
if (migrationResultArg.image && migrationResultArg.image !== service.image) {
|
||||||
if (migrationResult.image && migrationResult.image !== service.image) {
|
|
||||||
await this.oneboxRef.docker.pullImage(newImage);
|
await this.oneboxRef.docker.pullImage(newImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recreate and start container
|
const updatedService = this.oneboxRef.database.getServiceByName(serviceNameArg)!;
|
||||||
const updatedService = this.oneboxRef.database.getServiceByName(serviceName)!;
|
|
||||||
|
|
||||||
// Remove old container
|
|
||||||
if (service.containerID) {
|
if (service.containerID) {
|
||||||
try {
|
try {
|
||||||
await this.oneboxRef.docker.removeContainer(service.containerID, true);
|
await this.oneboxRef.docker.removeContainer(service.containerID, true);
|
||||||
} catch {
|
} catch {
|
||||||
// Container might already be gone
|
// Container might already be gone.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new container
|
|
||||||
const containerID = await this.oneboxRef.docker.createContainer(updatedService);
|
const containerID = await this.oneboxRef.docker.createContainer(updatedService);
|
||||||
this.oneboxRef.database.updateService(service.id!, { containerID, status: 'starting' });
|
this.oneboxRef.database.updateService(service.id!, { containerID, status: 'starting' });
|
||||||
|
|
||||||
// Start container
|
|
||||||
await this.oneboxRef.docker.startContainer(containerID);
|
await this.oneboxRef.docker.startContainer(containerID);
|
||||||
this.oneboxRef.database.updateService(service.id!, { status: 'running' });
|
this.oneboxRef.database.updateService(service.id!, { status: 'running' });
|
||||||
|
|
||||||
logger.success(`Service '${serviceName}' upgraded to template version ${newVersion}`);
|
logger.success(`Service '${serviceNameArg}' upgraded to App Store version ${newVersionArg}`);
|
||||||
return this.oneboxRef.database.getServiceByName(serviceName)!;
|
return this.oneboxRef.database.getServiceByName(serviceNameArg)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public normalizeVolumes(volumesArg: IAppStoreVersionConfig['volumes'] = []): IServiceVolume[] {
|
||||||
* Fetch JSON from the remote repo
|
return this.appStoreResolver.normalizeVolumes(volumesArg) as IServiceVolume[];
|
||||||
*/
|
|
||||||
private async fetchJson(path: string): Promise<unknown> {
|
|
||||||
const url = `${this.repoBaseUrl}/${path}`;
|
|
||||||
const response = await fetch(url);
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP ${response.status} for ${url}`);
|
|
||||||
}
|
|
||||||
return response.json();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public validateAppVersionConfig(configArg: IAppStoreVersionConfig, labelArg = 'app config'): void {
|
||||||
* Fetch text from the remote repo
|
this.appStoreResolver.validateAppStoreVersionConfig(configArg, labelArg);
|
||||||
*/
|
}
|
||||||
private async fetchText(path: string): Promise<string> {
|
|
||||||
const url = `${this.repoBaseUrl}/${path}`;
|
private createAppStoreResolver(): plugins.servezoneAppstore.AppStoreResolver {
|
||||||
const response = await fetch(url);
|
return new plugins.servezoneAppstore.AppStoreResolver({
|
||||||
|
baseUrl: this.appStoreBaseUrl,
|
||||||
|
fetch: this.fetchRef,
|
||||||
|
resolveDockerDigests: this.resolveDockerDigests,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async fetchText(pathArg: string): Promise<string> {
|
||||||
|
const url = `${this.appStoreBaseUrl}/${pathArg}`;
|
||||||
|
const response = await this.fetchRef(url);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP ${response.status} for ${url}`);
|
throw new Error(`HTTP ${response.status} for ${url}`);
|
||||||
}
|
}
|
||||||
return response.text();
|
return response.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
public normalizeVolumes(volumesArg: IAppVersionConfig['volumes'] = []): IServiceVolume[] {
|
private validateInstallOptions(optionsArg: IAppStoreInstallOptions): void {
|
||||||
return volumesArg.map((volumeArg, indexArg): IAppCatalogVolume => {
|
|
||||||
if (typeof volumeArg === 'string') {
|
|
||||||
return { mountPath: volumeArg };
|
|
||||||
}
|
|
||||||
return volumeArg;
|
|
||||||
}).map((volumeArg, indexArg) => {
|
|
||||||
this.validateVolume(volumeArg, `volume ${indexArg + 1}`);
|
|
||||||
return volumeArg;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public validateAppVersionConfig(configArg: IAppVersionConfig, labelArg = 'app config'): void {
|
|
||||||
if (!configArg || typeof configArg !== 'object') {
|
|
||||||
throw new Error(`Invalid ${labelArg}: config must be an object`);
|
|
||||||
}
|
|
||||||
if (!configArg.image || typeof configArg.image !== 'string') {
|
|
||||||
throw new Error(`Invalid ${labelArg}: image is required`);
|
|
||||||
}
|
|
||||||
if (configArg.image.endsWith(':latest')) {
|
|
||||||
logger.warn(`App template ${labelArg} uses a mutable ':latest' image tag`);
|
|
||||||
}
|
|
||||||
this.assertValidPort(configArg.port, `${labelArg} port`);
|
|
||||||
|
|
||||||
for (const envVar of configArg.envVars || []) {
|
|
||||||
if (!envVar.key || !/^[A-Z_][A-Z0-9_]*$/.test(envVar.key)) {
|
|
||||||
throw new Error(`Invalid ${labelArg}: env var key '${envVar.key}' is not valid`);
|
|
||||||
}
|
|
||||||
if (envVar.value !== undefined && typeof envVar.value !== 'string') {
|
|
||||||
throw new Error(`Invalid ${labelArg}: env var '${envVar.key}' value must be a string`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.normalizeVolumes(configArg.volumes);
|
|
||||||
this.validatePublishedPorts(configArg.publishedPorts || [], labelArg);
|
|
||||||
}
|
|
||||||
|
|
||||||
private validateInstallOptions(optionsArg: IAppInstallOptions): void {
|
|
||||||
if (!optionsArg.appId || !/^[a-z0-9][a-z0-9-]*$/.test(optionsArg.appId)) {
|
if (!optionsArg.appId || !/^[a-z0-9][a-z0-9-]*$/.test(optionsArg.appId)) {
|
||||||
throw new Error(`Invalid app id: ${optionsArg.appId}`);
|
throw new Error(`Invalid app id: ${optionsArg.appId}`);
|
||||||
}
|
}
|
||||||
@@ -436,66 +396,6 @@ export class AppStoreManager {
|
|||||||
if (optionsArg.port !== undefined) {
|
if (optionsArg.port !== undefined) {
|
||||||
this.assertValidPort(optionsArg.port, 'install service port');
|
this.assertValidPort(optionsArg.port, 'install service port');
|
||||||
}
|
}
|
||||||
if (optionsArg.publishedPorts) {
|
|
||||||
this.validatePublishedPorts(optionsArg.publishedPorts, `install options for ${optionsArg.appId}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private validateVolume(volumeArg: IAppCatalogVolume, labelArg: string): void {
|
|
||||||
if (!volumeArg.mountPath || !volumeArg.mountPath.startsWith('/')) {
|
|
||||||
throw new Error(`Invalid ${labelArg}: mountPath must be an absolute path`);
|
|
||||||
}
|
|
||||||
if (volumeArg.mountPath.includes(':')) {
|
|
||||||
throw new Error(`Invalid ${labelArg}: mountPath must not contain ':'`);
|
|
||||||
}
|
|
||||||
if ((volumeArg.source || volumeArg.name)?.includes(':')) {
|
|
||||||
throw new Error(`Invalid ${labelArg}: source/name must not contain ':'`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private validatePublishedPorts(
|
|
||||||
publishedPortsArg: IAppVersionConfig['publishedPorts'] = [],
|
|
||||||
labelArg: string,
|
|
||||||
): void {
|
|
||||||
const seenPublishedPorts = new Set<string>();
|
|
||||||
for (const portArg of publishedPortsArg) {
|
|
||||||
const protocol = portArg.protocol || 'tcp';
|
|
||||||
const targetStart = portArg.targetPort;
|
|
||||||
const targetEnd = portArg.targetPortEnd || targetStart;
|
|
||||||
const publishedStart = portArg.publishedPort || targetStart;
|
|
||||||
const publishedEnd = portArg.publishedPortEnd || (publishedStart + (targetEnd - targetStart));
|
|
||||||
const hostIp = portArg.hostIp || '0.0.0.0';
|
|
||||||
|
|
||||||
if (!['tcp', 'udp'].includes(protocol)) {
|
|
||||||
throw new Error(`Invalid ${labelArg}: published port protocol '${protocol}' is not supported`);
|
|
||||||
}
|
|
||||||
this.assertValidPort(targetStart, `${labelArg} targetPort`);
|
|
||||||
this.assertValidPort(targetEnd, `${labelArg} targetPortEnd`);
|
|
||||||
this.assertValidPort(publishedStart, `${labelArg} publishedPort`);
|
|
||||||
this.assertValidPort(publishedEnd, `${labelArg} publishedPortEnd`);
|
|
||||||
if (targetEnd < targetStart || publishedEnd < publishedStart) {
|
|
||||||
throw new Error(`Invalid ${labelArg}: published port ranges must be ascending`);
|
|
||||||
}
|
|
||||||
if ((targetEnd - targetStart) !== (publishedEnd - publishedStart)) {
|
|
||||||
throw new Error(`Invalid ${labelArg}: target and published port ranges must have the same size`);
|
|
||||||
}
|
|
||||||
if ((targetEnd - targetStart) > 1000) {
|
|
||||||
throw new Error(`Invalid ${labelArg}: published port ranges may not exceed 1001 ports`);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let offset = 0; offset <= targetEnd - targetStart; offset++) {
|
|
||||||
const publishedPort = publishedStart + offset;
|
|
||||||
const publishedKey = `${hostIp}/${protocol}/${publishedPort}`;
|
|
||||||
const wildcardKey = `0.0.0.0/${protocol}/${publishedPort}`;
|
|
||||||
const conflictsWithWildcard = hostIp === '0.0.0.0'
|
|
||||||
? Array.from(seenPublishedPorts).some((keyArg) => keyArg.endsWith(`/${protocol}/${publishedPort}`))
|
|
||||||
: seenPublishedPorts.has(wildcardKey);
|
|
||||||
if (seenPublishedPorts.has(publishedKey) || conflictsWithWildcard) {
|
|
||||||
throw new Error(`Invalid ${labelArg}: duplicate published port ${hostIp}:${publishedPort}/${protocol}`);
|
|
||||||
}
|
|
||||||
seenPublishedPorts.add(publishedKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private assertValidPort(portArg: number, labelArg: string): void {
|
private assertValidPort(portArg: number, labelArg: string): void {
|
||||||
@@ -505,7 +405,7 @@ export class AppStoreManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getAppStoreEnvVars(
|
private getAppStoreEnvVars(
|
||||||
configArg: IAppVersionConfig,
|
configArg: IAppStoreVersionConfig,
|
||||||
overridesArg: Record<string, string>,
|
overridesArg: Record<string, string>,
|
||||||
): Record<string, string> {
|
): Record<string, string> {
|
||||||
const envVars: Record<string, string> = {};
|
const envVars: Record<string, string> = {};
|
||||||
@@ -519,14 +419,10 @@ export class AppStoreManager {
|
|||||||
envVars[envVar.key] = value;
|
envVars[envVar.key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [key, value] of Object.entries(overridesArg)) {
|
Object.assign(envVars, overridesArg);
|
||||||
envVars[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (missingRequiredEnvVars.length > 0) {
|
if (missingRequiredEnvVars.length > 0) {
|
||||||
throw new Error(
|
throw new Error(`Missing required app env var(s): ${missingRequiredEnvVars.join(', ')}`);
|
||||||
`Missing required app env var(s): ${missingRequiredEnvVars.join(', ')}`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return envVars;
|
return envVars;
|
||||||
@@ -536,7 +432,7 @@ export class AppStoreManager {
|
|||||||
return Object.values(envVarsArg).some((value) => value.includes(`\${${templateNameArg}}`));
|
return Object.values(envVarsArg).some((value) => value.includes(`\${${templateNameArg}}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
private assertRuntimeCompatibility(configArg: IAppVersionConfig): void {
|
private assertRuntimeCompatibility(configArg: IAppStoreVersionConfig): void {
|
||||||
if (!configArg.minOneboxVersion) return;
|
if (!configArg.minOneboxVersion) return;
|
||||||
if (this.compareVersions(projectInfo.version, configArg.minOneboxVersion) < 0) {
|
if (this.compareVersions(projectInfo.version, configArg.minOneboxVersion) < 0) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ export class OneboxServicesManager {
|
|||||||
registryRepository: options.useOneboxRegistry ? options.name : undefined,
|
registryRepository: options.useOneboxRegistry ? options.name : undefined,
|
||||||
registryImageTag: options.registryImageTag || 'latest',
|
registryImageTag: options.registryImageTag || 'latest',
|
||||||
autoUpdateOnPush: options.autoUpdateOnPush,
|
autoUpdateOnPush: options.autoUpdateOnPush,
|
||||||
|
imageDigest: options.imageDigest,
|
||||||
// Platform requirements
|
// Platform requirements
|
||||||
platformRequirements,
|
platformRequirements,
|
||||||
// App Store template tracking
|
// App Store template tracking
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { logger } from '../logging.ts';
|
|||||||
import { getErrorMessage } from '../utils/error.ts';
|
import { getErrorMessage } from '../utils/error.ts';
|
||||||
|
|
||||||
const SMARTPROXY_SERVICE_NAME = 'onebox-smartproxy';
|
const SMARTPROXY_SERVICE_NAME = 'onebox-smartproxy';
|
||||||
const LEGACY_CADDY_SERVICE_NAME = 'onebox-caddy';
|
const LEGACY_REVERSE_PROXY_SERVICE_NAME = 'onebox-caddy';
|
||||||
const SMARTPROXY_IMAGE = 'code.foss.global/host.today/ht-docker-smartproxy:latest';
|
const SMARTPROXY_IMAGE = 'code.foss.global/host.today/ht-docker-smartproxy:latest';
|
||||||
const SMARTPROXY_ADMIN_CONTAINER_PORT = 3000;
|
const SMARTPROXY_ADMIN_CONTAINER_PORT = 3000;
|
||||||
const SMARTPROXY_HTTP_CONTAINER_PORT = 80;
|
const SMARTPROXY_HTTP_CONTAINER_PORT = 80;
|
||||||
@@ -102,10 +102,12 @@ export class SmartProxyManager {
|
|||||||
|
|
||||||
logger.info('Starting SmartProxy Docker service...');
|
logger.info('Starting SmartProxy Docker service...');
|
||||||
|
|
||||||
const legacyService = await this.getExistingService(LEGACY_CADDY_SERVICE_NAME);
|
const legacyService = await this.getExistingService(LEGACY_REVERSE_PROXY_SERVICE_NAME);
|
||||||
if (legacyService) {
|
if (legacyService) {
|
||||||
logger.info('Legacy Caddy service exists, removing it before SmartProxy startup...');
|
logger.info(
|
||||||
await this.removeService(LEGACY_CADDY_SERVICE_NAME);
|
`Legacy reverse proxy service ${LEGACY_REVERSE_PROXY_SERVICE_NAME} exists, removing it before SmartProxy startup...`,
|
||||||
|
);
|
||||||
|
await this.removeService(LEGACY_REVERSE_PROXY_SERVICE_NAME);
|
||||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import { Onebox } from './classes/onebox.ts';
|
|||||||
import { OneboxDaemon } from './classes/daemon.ts';
|
import { OneboxDaemon } from './classes/daemon.ts';
|
||||||
import { OneboxSystemd } from './classes/systemd.ts';
|
import { OneboxSystemd } from './classes/systemd.ts';
|
||||||
import { OneboxUpdateManager } from './classes/update-manager.ts';
|
import { OneboxUpdateManager } from './classes/update-manager.ts';
|
||||||
import type { IAppVersionConfig } from './classes/appstore-types.ts';
|
import type * as servezoneInterfaces from '@serve.zone/interfaces';
|
||||||
|
|
||||||
|
type IAppStoreVersionConfig = servezoneInterfaces.appstore.IAppStoreVersionConfig;
|
||||||
|
|
||||||
export async function runCli(): Promise<void> {
|
export async function runCli(): Promise<void> {
|
||||||
const args = Deno.args;
|
const args = Deno.args;
|
||||||
@@ -591,7 +593,7 @@ function parseEnvArgs(args: string[]): Record<string, string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getAppStoreEnvVars(
|
function getAppStoreEnvVars(
|
||||||
configArg: IAppVersionConfig,
|
configArg: IAppStoreVersionConfig,
|
||||||
overridesArg: Record<string, string>,
|
overridesArg: Record<string, string>,
|
||||||
): Record<string, string> {
|
): Record<string, string> {
|
||||||
const envVars: Record<string, string> = {};
|
const envVars: Record<string, string> = {};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { TQueryFunction } from '../types.ts';
|
|||||||
|
|
||||||
export class Migration015SmartProxyPlatformService extends BaseMigration {
|
export class Migration015SmartProxyPlatformService extends BaseMigration {
|
||||||
readonly version = 15;
|
readonly version = 15;
|
||||||
readonly description = 'Rename Caddy platform service to SmartProxy';
|
readonly description = 'Rename legacy reverse proxy platform service to SmartProxy';
|
||||||
|
|
||||||
up(query: TQueryFunction): void {
|
up(query: TQueryFunction): void {
|
||||||
query(
|
query(
|
||||||
|
|||||||
@@ -13,10 +13,9 @@ export class AppStoreHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private registerHandlers(): void {
|
private registerHandlers(): void {
|
||||||
// Get app templates (catalog)
|
|
||||||
this.typedrouter.addTypedHandler(
|
this.typedrouter.addTypedHandler(
|
||||||
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetAppTemplates>(
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetAppStoreTemplates>(
|
||||||
'getAppTemplates',
|
'getAppStoreTemplates',
|
||||||
async (dataArg) => {
|
async (dataArg) => {
|
||||||
await requireAdminIdentity(this.opsServerRef.adminHandler, dataArg);
|
await requireAdminIdentity(this.opsServerRef.adminHandler, dataArg);
|
||||||
const apps = await this.opsServerRef.oneboxRef.appStore.getApps();
|
const apps = await this.opsServerRef.oneboxRef.appStore.getApps();
|
||||||
@@ -25,10 +24,9 @@ export class AppStoreHandler {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get app config for a specific version
|
|
||||||
this.typedrouter.addTypedHandler(
|
this.typedrouter.addTypedHandler(
|
||||||
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetAppConfig>(
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetAppStoreConfig>(
|
||||||
'getAppConfig',
|
'getAppStoreConfig',
|
||||||
async (dataArg) => {
|
async (dataArg) => {
|
||||||
await requireAdminIdentity(this.opsServerRef.adminHandler, dataArg);
|
await requireAdminIdentity(this.opsServerRef.adminHandler, dataArg);
|
||||||
const config = await this.opsServerRef.oneboxRef.appStore.getAppVersionConfig(
|
const config = await this.opsServerRef.oneboxRef.appStore.getAppVersionConfig(
|
||||||
@@ -42,8 +40,8 @@ export class AppStoreHandler {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.typedrouter.addTypedHandler(
|
this.typedrouter.addTypedHandler(
|
||||||
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_InstallAppTemplate>(
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_InstallAppStoreApp>(
|
||||||
'installAppTemplate',
|
'installAppStoreApp',
|
||||||
async (dataArg) => {
|
async (dataArg) => {
|
||||||
await requireAdminIdentity(this.opsServerRef.adminHandler, dataArg);
|
await requireAdminIdentity(this.opsServerRef.adminHandler, dataArg);
|
||||||
const service = await this.opsServerRef.oneboxRef.appStore.installApp(dataArg.install);
|
const service = await this.opsServerRef.oneboxRef.appStore.installApp(dataArg.install);
|
||||||
@@ -52,22 +50,20 @@ export class AppStoreHandler {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get services with available upgrades
|
|
||||||
this.typedrouter.addTypedHandler(
|
this.typedrouter.addTypedHandler(
|
||||||
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetUpgradeableServices>(
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetUpgradeableAppStoreServices>(
|
||||||
'getUpgradeableServices',
|
'getUpgradeableAppStoreServices',
|
||||||
async (dataArg) => {
|
async (dataArg) => {
|
||||||
await requireAdminIdentity(this.opsServerRef.adminHandler, dataArg);
|
await requireAdminIdentity(this.opsServerRef.adminHandler, dataArg);
|
||||||
const services = await this.opsServerRef.oneboxRef.appStore.getUpgradeableServices();
|
const services = await this.opsServerRef.oneboxRef.appStore.getUpgradeableAppStoreServices();
|
||||||
return { services };
|
return { services };
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Upgrade a service to a new template version
|
|
||||||
this.typedrouter.addTypedHandler(
|
this.typedrouter.addTypedHandler(
|
||||||
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_UpgradeService>(
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_UpgradeAppStoreService>(
|
||||||
'upgradeService',
|
'upgradeAppStoreService',
|
||||||
async (dataArg) => {
|
async (dataArg) => {
|
||||||
await requireAdminIdentity(this.opsServerRef.adminHandler, dataArg);
|
await requireAdminIdentity(this.opsServerRef.adminHandler, dataArg);
|
||||||
|
|
||||||
@@ -84,7 +80,6 @@ export class AppStoreHandler {
|
|||||||
|
|
||||||
logger.info(`Upgrading service '${dataArg.serviceName}' from v${existingService.appTemplateVersion} to v${dataArg.targetVersion}`);
|
logger.info(`Upgrading service '${dataArg.serviceName}' from v${existingService.appTemplateVersion} to v${dataArg.targetVersion}`);
|
||||||
|
|
||||||
// Execute migration
|
|
||||||
const migrationResult = await this.opsServerRef.oneboxRef.appStore.executeMigration(
|
const migrationResult = await this.opsServerRef.oneboxRef.appStore.executeMigration(
|
||||||
existingService,
|
existingService,
|
||||||
existingService.appTemplateVersion,
|
existingService.appTemplateVersion,
|
||||||
@@ -97,7 +92,6 @@ export class AppStoreHandler {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the upgrade
|
|
||||||
const updatedService = await this.opsServerRef.oneboxRef.appStore.applyUpgrade(
|
const updatedService = await this.opsServerRef.oneboxRef.appStore.applyUpgrade(
|
||||||
dataArg.serviceName,
|
dataArg.serviceName,
|
||||||
migrationResult,
|
migrationResult,
|
||||||
|
|||||||
@@ -82,6 +82,11 @@ export { smartguard, smartjwt };
|
|||||||
import { ContainerArchive } from '@serve.zone/containerarchive';
|
import { ContainerArchive } from '@serve.zone/containerarchive';
|
||||||
export { ContainerArchive };
|
export { ContainerArchive };
|
||||||
|
|
||||||
|
// serve.zone App Store contracts and resolver
|
||||||
|
import * as servezoneInterfaces from '@serve.zone/interfaces';
|
||||||
|
import * as servezoneAppstore from '@serve.zone/appstore';
|
||||||
|
export { servezoneInterfaces, servezoneAppstore };
|
||||||
|
|
||||||
// Node.js compat for streaming
|
// Node.js compat for streaming
|
||||||
import * as nodeFs from 'node:fs';
|
import * as nodeFs from 'node:fs';
|
||||||
import * as nodeStream from 'node:stream';
|
import * as nodeStream from 'node:stream';
|
||||||
|
|||||||
@@ -333,6 +333,7 @@ export interface IServiceDeployOptions {
|
|||||||
useOneboxRegistry?: boolean;
|
useOneboxRegistry?: boolean;
|
||||||
registryImageTag?: string;
|
registryImageTag?: string;
|
||||||
autoUpdateOnPush?: boolean;
|
autoUpdateOnPush?: boolean;
|
||||||
|
imageDigest?: string;
|
||||||
// Platform service requirements
|
// Platform service requirements
|
||||||
enableMongoDB?: boolean;
|
enableMongoDB?: boolean;
|
||||||
enableS3?: boolean;
|
enableS3?: boolean;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,125 +1,77 @@
|
|||||||
|
import type * as servezoneInterfaces from '@serve.zone/interfaces';
|
||||||
import * as plugins from '../plugins.ts';
|
import * as plugins from '../plugins.ts';
|
||||||
import * as data from '../data/index.ts';
|
import * as data from '../data/index.ts';
|
||||||
|
|
||||||
export interface ICatalogApp {
|
export type IAppStoreApp = servezoneInterfaces.appstore.IAppStoreApp;
|
||||||
id: string;
|
export type IAppStoreVersionConfig = servezoneInterfaces.appstore.IAppStoreVersionConfig;
|
||||||
name: string;
|
export type IAppStoreAppMeta = servezoneInterfaces.appstore.IAppStoreAppMeta;
|
||||||
description: string;
|
export type IUpgradeableAppStoreService = servezoneInterfaces.appstore.IUpgradeableAppStoreService;
|
||||||
category: string;
|
|
||||||
iconName?: string;
|
|
||||||
iconUrl?: string;
|
|
||||||
latestVersion: string;
|
|
||||||
tags?: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IAppVersionConfig {
|
export interface IAppStoreInstallOptions extends servezoneInterfaces.appstore.IAppStoreInstallRequest {
|
||||||
image: string;
|
|
||||||
port: number;
|
|
||||||
envVars?: Array<{ key: string; value: string; description: string; required?: boolean }>;
|
|
||||||
volumes?: Array<string | data.IServiceVolume>;
|
|
||||||
publishedPorts?: data.IServicePublishedPort[];
|
|
||||||
platformRequirements?: {
|
|
||||||
mongodb?: boolean;
|
|
||||||
s3?: boolean;
|
|
||||||
clickhouse?: boolean;
|
|
||||||
redis?: boolean;
|
|
||||||
mariadb?: boolean;
|
|
||||||
};
|
|
||||||
minOneboxVersion?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IAppInstallOptions {
|
|
||||||
appId: string;
|
|
||||||
version?: string;
|
|
||||||
serviceName: string;
|
|
||||||
domain?: string;
|
|
||||||
port?: number;
|
|
||||||
publishedPorts?: data.IServicePublishedPort[];
|
|
||||||
envVars?: Record<string, string>;
|
|
||||||
autoDNS?: boolean;
|
autoDNS?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IAppMeta {
|
export interface IReq_GetAppStoreTemplates extends plugins.typedrequestInterfaces.implementsTR<
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
description: string;
|
|
||||||
category: string;
|
|
||||||
iconName?: string;
|
|
||||||
latestVersion: string;
|
|
||||||
versions: string[];
|
|
||||||
maintainer?: string;
|
|
||||||
links?: Record<string, string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IUpgradeableService {
|
|
||||||
serviceName: string;
|
|
||||||
appTemplateId: string;
|
|
||||||
currentVersion: string;
|
|
||||||
latestVersion: string;
|
|
||||||
hasMigration: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IReq_GetAppTemplates extends plugins.typedrequestInterfaces.implementsTR<
|
|
||||||
plugins.typedrequestInterfaces.ITypedRequest,
|
plugins.typedrequestInterfaces.ITypedRequest,
|
||||||
IReq_GetAppTemplates
|
IReq_GetAppStoreTemplates
|
||||||
> {
|
> {
|
||||||
method: 'getAppTemplates';
|
method: 'getAppStoreTemplates';
|
||||||
request: {
|
request: {
|
||||||
identity: data.IIdentity;
|
identity: data.IIdentity;
|
||||||
};
|
};
|
||||||
response: {
|
response: {
|
||||||
apps: ICatalogApp[];
|
apps: IAppStoreApp[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IReq_GetAppConfig extends plugins.typedrequestInterfaces.implementsTR<
|
export interface IReq_GetAppStoreConfig extends plugins.typedrequestInterfaces.implementsTR<
|
||||||
plugins.typedrequestInterfaces.ITypedRequest,
|
plugins.typedrequestInterfaces.ITypedRequest,
|
||||||
IReq_GetAppConfig
|
IReq_GetAppStoreConfig
|
||||||
> {
|
> {
|
||||||
method: 'getAppConfig';
|
method: 'getAppStoreConfig';
|
||||||
request: {
|
request: {
|
||||||
identity: data.IIdentity;
|
identity: data.IIdentity;
|
||||||
appId: string;
|
appId: string;
|
||||||
version: string;
|
version: string;
|
||||||
};
|
};
|
||||||
response: {
|
response: {
|
||||||
config: IAppVersionConfig;
|
config: IAppStoreVersionConfig;
|
||||||
appMeta: IAppMeta;
|
appMeta: IAppStoreAppMeta;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IReq_InstallAppTemplate extends plugins.typedrequestInterfaces.implementsTR<
|
export interface IReq_InstallAppStoreApp extends plugins.typedrequestInterfaces.implementsTR<
|
||||||
plugins.typedrequestInterfaces.ITypedRequest,
|
plugins.typedrequestInterfaces.ITypedRequest,
|
||||||
IReq_InstallAppTemplate
|
IReq_InstallAppStoreApp
|
||||||
> {
|
> {
|
||||||
method: 'installAppTemplate';
|
method: 'installAppStoreApp';
|
||||||
request: {
|
request: {
|
||||||
identity: data.IIdentity;
|
identity: data.IIdentity;
|
||||||
install: IAppInstallOptions;
|
install: IAppStoreInstallOptions;
|
||||||
};
|
};
|
||||||
response: {
|
response: {
|
||||||
service: data.IService;
|
service: data.IService;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IReq_GetUpgradeableServices extends plugins.typedrequestInterfaces.implementsTR<
|
export interface IReq_GetUpgradeableAppStoreServices extends plugins.typedrequestInterfaces.implementsTR<
|
||||||
plugins.typedrequestInterfaces.ITypedRequest,
|
plugins.typedrequestInterfaces.ITypedRequest,
|
||||||
IReq_GetUpgradeableServices
|
IReq_GetUpgradeableAppStoreServices
|
||||||
> {
|
> {
|
||||||
method: 'getUpgradeableServices';
|
method: 'getUpgradeableAppStoreServices';
|
||||||
request: {
|
request: {
|
||||||
identity: data.IIdentity;
|
identity: data.IIdentity;
|
||||||
};
|
};
|
||||||
response: {
|
response: {
|
||||||
services: IUpgradeableService[];
|
services: IUpgradeableAppStoreService[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IReq_UpgradeService extends plugins.typedrequestInterfaces.implementsTR<
|
export interface IReq_UpgradeAppStoreService extends plugins.typedrequestInterfaces.implementsTR<
|
||||||
plugins.typedrequestInterfaces.ITypedRequest,
|
plugins.typedrequestInterfaces.ITypedRequest,
|
||||||
IReq_UpgradeService
|
IReq_UpgradeAppStoreService
|
||||||
> {
|
> {
|
||||||
method: 'upgradeService';
|
method: 'upgradeAppStoreService';
|
||||||
request: {
|
request: {
|
||||||
identity: data.IIdentity;
|
identity: data.IIdentity;
|
||||||
serviceName: string;
|
serviceName: string;
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@serve.zone/onebox',
|
name: '@serve.zone/onebox',
|
||||||
version: '1.30.0',
|
version: '2.0.0',
|
||||||
description: 'Self-hosted container platform with automatic SSL and DNS - a mini Heroku for single servers'
|
description: 'Self-hosted container platform with automatic SSL and DNS - a mini Heroku for single servers'
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -58,8 +58,8 @@ export interface ISettingsState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IAppStoreState {
|
export interface IAppStoreState {
|
||||||
apps: interfaces.requests.ICatalogApp[];
|
apps: interfaces.requests.IAppStoreApp[];
|
||||||
upgradeableServices: interfaces.requests.IUpgradeableService[];
|
upgradeableServices: interfaces.requests.IUpgradeableAppStoreService[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IUiState {
|
export interface IUiState {
|
||||||
@@ -1226,13 +1226,13 @@ async function disconnectSocket() {
|
|||||||
// App Store Actions
|
// App Store Actions
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
export const fetchAppTemplatesAction = appStoreStatePart.createAction(
|
export const fetchAppStoreTemplatesAction = appStoreStatePart.createAction(
|
||||||
async (statePartArg) => {
|
async (statePartArg) => {
|
||||||
const context = getActionContext();
|
const context = getActionContext();
|
||||||
try {
|
try {
|
||||||
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
||||||
interfaces.requests.IReq_GetAppTemplates
|
interfaces.requests.IReq_GetAppStoreTemplates
|
||||||
>('/typedrequest', 'getAppTemplates');
|
>('/typedrequest', 'getAppStoreTemplates');
|
||||||
const response = await typedRequest.fire({ identity: context.identity! });
|
const response = await typedRequest.fire({ identity: context.identity! });
|
||||||
return { ...statePartArg.getState(), apps: response.apps };
|
return { ...statePartArg.getState(), apps: response.apps };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -1242,13 +1242,13 @@ export const fetchAppTemplatesAction = appStoreStatePart.createAction(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export const fetchUpgradeableServicesAction = appStoreStatePart.createAction(
|
export const fetchUpgradeableAppStoreServicesAction = appStoreStatePart.createAction(
|
||||||
async (statePartArg) => {
|
async (statePartArg) => {
|
||||||
const context = getActionContext();
|
const context = getActionContext();
|
||||||
try {
|
try {
|
||||||
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
||||||
interfaces.requests.IReq_GetUpgradeableServices
|
interfaces.requests.IReq_GetUpgradeableAppStoreServices
|
||||||
>('/typedrequest', 'getUpgradeableServices');
|
>('/typedrequest', 'getUpgradeableAppStoreServices');
|
||||||
const response = await typedRequest.fire({ identity: context.identity! });
|
const response = await typedRequest.fire({ identity: context.identity! });
|
||||||
return { ...statePartArg.getState(), upgradeableServices: response.services };
|
return { ...statePartArg.getState(), upgradeableServices: response.services };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -1258,15 +1258,15 @@ export const fetchUpgradeableServicesAction = appStoreStatePart.createAction(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export const upgradeServiceAction = appStoreStatePart.createAction<{
|
export const upgradeAppStoreServiceAction = appStoreStatePart.createAction<{
|
||||||
serviceName: string;
|
serviceName: string;
|
||||||
targetVersion: string;
|
targetVersion: string;
|
||||||
}>(async (statePartArg, dataArg) => {
|
}>(async (statePartArg, dataArg) => {
|
||||||
const context = getActionContext();
|
const context = getActionContext();
|
||||||
try {
|
try {
|
||||||
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
||||||
interfaces.requests.IReq_UpgradeService
|
interfaces.requests.IReq_UpgradeAppStoreService
|
||||||
>('/typedrequest', 'upgradeService');
|
>('/typedrequest', 'upgradeAppStoreService');
|
||||||
await typedRequest.fire({
|
await typedRequest.fire({
|
||||||
identity: context.identity!,
|
identity: context.identity!,
|
||||||
serviceName: dataArg.serviceName,
|
serviceName: dataArg.serviceName,
|
||||||
@@ -1274,8 +1274,8 @@ export const upgradeServiceAction = appStoreStatePart.createAction<{
|
|||||||
});
|
});
|
||||||
// Re-fetch upgradeable services and services list
|
// Re-fetch upgradeable services and services list
|
||||||
const upgradeReq = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
const upgradeReq = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
||||||
interfaces.requests.IReq_GetUpgradeableServices
|
interfaces.requests.IReq_GetUpgradeableAppStoreServices
|
||||||
>('/typedrequest', 'getUpgradeableServices');
|
>('/typedrequest', 'getUpgradeableAppStoreServices');
|
||||||
const upgradeResp = await upgradeReq.fire({ identity: context.identity! });
|
const upgradeResp = await upgradeReq.fire({ identity: context.identity! });
|
||||||
return { ...statePartArg.getState(), upgradeableServices: upgradeResp.services };
|
return { ...statePartArg.getState(), upgradeableServices: upgradeResp.services };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ export class ObViewAppStore extends DeesElement {
|
|||||||
accessor currentView: 'grid' | 'detail' = 'grid';
|
accessor currentView: 'grid' | 'detail' = 'grid';
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
accessor selectedApp: interfaces.requests.ICatalogApp | null = null;
|
accessor selectedApp: interfaces.requests.IAppStoreApp | null = null;
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
accessor selectedAppMeta: interfaces.requests.IAppMeta | null = null;
|
accessor selectedAppMeta: interfaces.requests.IAppStoreAppMeta | null = null;
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
accessor selectedAppConfig: interfaces.requests.IAppVersionConfig | null = null;
|
accessor selectedAppConfig: interfaces.requests.IAppStoreVersionConfig | null = null;
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
accessor selectedVersion: string = '';
|
accessor selectedVersion: string = '';
|
||||||
@@ -331,7 +331,7 @@ export class ObViewAppStore extends DeesElement {
|
|||||||
|
|
||||||
async connectedCallback() {
|
async connectedCallback() {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
await appstate.appStoreStatePart.dispatchAction(appstate.fetchAppTemplatesAction, null);
|
await appstate.appStoreStatePart.dispatchAction(appstate.fetchAppStoreTemplatesAction, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(): TemplateResult {
|
public render(): TemplateResult {
|
||||||
@@ -541,7 +541,7 @@ export class ObViewAppStore extends DeesElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderDeploymentFootprint(config: interfaces.requests.IAppVersionConfig): TemplateResult | '' {
|
private renderDeploymentFootprint(config: interfaces.requests.IAppStoreVersionConfig): TemplateResult | '' {
|
||||||
const volumes = this.getConfigVolumes(config);
|
const volumes = this.getConfigVolumes(config);
|
||||||
const publishedPorts = config.publishedPorts || [];
|
const publishedPorts = config.publishedPorts || [];
|
||||||
|
|
||||||
@@ -577,7 +577,7 @@ export class ObViewAppStore extends DeesElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderDeployConfirmation(config: interfaces.requests.IAppVersionConfig): TemplateResult | '' {
|
private renderDeployConfirmation(config: interfaces.requests.IAppStoreVersionConfig): TemplateResult | '' {
|
||||||
const volumes = this.getConfigVolumes(config);
|
const volumes = this.getConfigVolumes(config);
|
||||||
const publishedPorts = config.publishedPorts || [];
|
const publishedPorts = config.publishedPorts || [];
|
||||||
if (volumes.length === 0 && publishedPorts.length === 0) return '';
|
if (volumes.length === 0 && publishedPorts.length === 0) return '';
|
||||||
@@ -590,7 +590,7 @@ export class ObViewAppStore extends DeesElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getConfigVolumes(config: interfaces.requests.IAppVersionConfig): interfaces.data.IServiceVolume[] {
|
private getConfigVolumes(config: interfaces.requests.IAppStoreVersionConfig): interfaces.data.IServiceVolume[] {
|
||||||
return (config.volumes || []).map((volume) => {
|
return (config.volumes || []).map((volume) => {
|
||||||
if (typeof volume === 'string') {
|
if (typeof volume === 'string') {
|
||||||
return { mountPath: volume };
|
return { mountPath: volume };
|
||||||
@@ -658,8 +658,8 @@ export class ObViewAppStore extends DeesElement {
|
|||||||
if (!identity) return;
|
if (!identity) return;
|
||||||
|
|
||||||
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
||||||
interfaces.requests.IReq_GetAppConfig
|
interfaces.requests.IReq_GetAppStoreConfig
|
||||||
>('/typedrequest', 'getAppConfig');
|
>('/typedrequest', 'getAppStoreConfig');
|
||||||
|
|
||||||
const response = await typedRequest.fire({ identity, appId, version });
|
const response = await typedRequest.fire({ identity, appId, version });
|
||||||
|
|
||||||
@@ -728,8 +728,8 @@ export class ObViewAppStore extends DeesElement {
|
|||||||
const identity = appstate.loginStatePart.getState().identity;
|
const identity = appstate.loginStatePart.getState().identity;
|
||||||
if (!identity) return;
|
if (!identity) return;
|
||||||
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
||||||
interfaces.requests.IReq_InstallAppTemplate
|
interfaces.requests.IReq_InstallAppStoreApp
|
||||||
>('/typedrequest', 'installAppTemplate');
|
>('/typedrequest', 'installAppStoreApp');
|
||||||
await typedRequest.fire({
|
await typedRequest.fire({
|
||||||
identity,
|
identity,
|
||||||
install: {
|
install: {
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ export class ObViewServices extends DeesElement {
|
|||||||
await Promise.all([
|
await Promise.all([
|
||||||
appstate.servicesStatePart.dispatchAction(appstate.fetchServicesAction, null),
|
appstate.servicesStatePart.dispatchAction(appstate.fetchServicesAction, null),
|
||||||
appstate.servicesStatePart.dispatchAction(appstate.fetchPlatformServicesAction, null),
|
appstate.servicesStatePart.dispatchAction(appstate.fetchPlatformServicesAction, null),
|
||||||
appstate.appStoreStatePart.dispatchAction(appstate.fetchUpgradeableServicesAction, null),
|
appstate.appStoreStatePart.dispatchAction(appstate.fetchUpgradeableAppStoreServicesAction, null),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// If a platform service was selected from the dashboard, navigate to its detail
|
// If a platform service was selected from the dashboard, navigate to its detail
|
||||||
@@ -497,7 +497,7 @@ export class ObViewServices extends DeesElement {
|
|||||||
class="deploy-button"
|
class="deploy-button"
|
||||||
style="padding: 8px 16px; font-size: 13px;"
|
style="padding: 8px 16px; font-size: 13px;"
|
||||||
@click=${async () => {
|
@click=${async () => {
|
||||||
await appstate.appStoreStatePart.dispatchAction(appstate.upgradeServiceAction, {
|
await appstate.appStoreStatePart.dispatchAction(appstate.upgradeAppStoreServiceAction, {
|
||||||
serviceName: upgradeInfo.serviceName,
|
serviceName: upgradeInfo.serviceName,
|
||||||
targetVersion: upgradeInfo.latestVersion,
|
targetVersion: upgradeInfo.latestVersion,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -48,31 +48,45 @@ export class ObViewSettings extends DeesElement {
|
|||||||
cssManager.defaultStyles,
|
cssManager.defaultStyles,
|
||||||
shared.viewHostCss,
|
shared.viewHostCss,
|
||||||
css`
|
css`
|
||||||
.gateway-card {
|
dees-tile {
|
||||||
|
display: block;
|
||||||
margin-bottom: 24px;
|
margin-bottom: 24px;
|
||||||
border: 1px solid ${cssManager.bdTheme('#e4e4e7', '#27272a')};
|
|
||||||
border-radius: 12px;
|
|
||||||
background: ${cssManager.bdTheme('#ffffff', '#09090b')};
|
|
||||||
overflow: hidden;
|
|
||||||
box-shadow: 0 1px 2px ${cssManager.bdTheme('rgba(0,0,0,0.04)', 'rgba(0,0,0,0.2)')};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.gateway-header {
|
.gateway-header {
|
||||||
padding: 16px 20px;
|
height: 36px;
|
||||||
border-bottom: 1px solid ${cssManager.bdTheme('#f4f4f5', '#27272a')};
|
display: flex;
|
||||||
background: ${cssManager.bdTheme('#fafafa', '#101013')};
|
align-items: center;
|
||||||
|
padding: 0 16px;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gateway-heading {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 8px;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gateway-title {
|
.gateway-title {
|
||||||
font-size: 15px;
|
font-size: 13px;
|
||||||
font-weight: 600;
|
font-weight: 500;
|
||||||
color: ${cssManager.bdTheme('#18181b', '#fafafa')};
|
letter-spacing: -0.01em;
|
||||||
|
color: var(--dees-color-text-secondary);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gateway-subtitle {
|
.gateway-subtitle {
|
||||||
margin-top: 4px;
|
font-size: 12px;
|
||||||
font-size: 13px;
|
color: var(--dees-color-text-muted);
|
||||||
color: ${cssManager.bdTheme('#71717a', '#a1a1aa')};
|
letter-spacing: -0.01em;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gateway-content {
|
.gateway-content {
|
||||||
@@ -176,8 +190,51 @@ export class ObViewSettings extends DeesElement {
|
|||||||
|
|
||||||
.gateway-footer {
|
.gateway-footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
padding: 0 20px 20px;
|
align-items: center;
|
||||||
|
gap: 0;
|
||||||
|
height: 36px;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tile-button {
|
||||||
|
padding: 0 16px;
|
||||||
|
height: 100%;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
border-left: 1px solid var(--dees-color-border-subtle);
|
||||||
|
color: var(--dees-color-text-muted);
|
||||||
|
white-space: nowrap;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tile-button:first-child {
|
||||||
|
border-left: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tile-button:hover {
|
||||||
|
background: var(--dees-color-hover);
|
||||||
|
color: var(--dees-color-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tile-button.primary {
|
||||||
|
color: ${cssManager.bdTheme('hsl(217.2 91.2% 59.8%)', 'hsl(213.1 93.9% 67.8%)')};
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tile-button.primary:hover {
|
||||||
|
background: ${cssManager.bdTheme('hsl(217.2 91.2% 59.8% / 0.08)', 'hsl(213.1 93.9% 67.8% / 0.08)')};
|
||||||
|
color: ${cssManager.bdTheme('hsl(217.2 91.2% 50%)', 'hsl(213.1 93.9% 75%)')};
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 700px) {
|
@media (max-width: 700px) {
|
||||||
@@ -249,24 +306,23 @@ export class ObViewSettings extends DeesElement {
|
|||||||
private renderAdminUiSettings(): TemplateResult {
|
private renderAdminUiSettings(): TemplateResult {
|
||||||
const settings = this.settingsState.settings;
|
const settings = this.settingsState.settings;
|
||||||
return html`
|
return html`
|
||||||
<section class="gateway-card">
|
<dees-tile>
|
||||||
<div class="gateway-header">
|
<div slot="header" class="gateway-header">
|
||||||
<div class="gateway-title">Onebox Admin UI</div>
|
<div class="gateway-heading">
|
||||||
<div class="gateway-subtitle">Configure the public hostname for this Onebox dashboard. Onebox keeps this route separate from app service domains.</div>
|
<span class="gateway-title">Onebox Admin UI</span>
|
||||||
|
<span class="gateway-subtitle">Configure the public hostname for this Onebox dashboard</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="gateway-content">
|
<div class="gateway-content">
|
||||||
${this.renderGatewayInput('adminUiDomain', 'Admin UI Domain', settings?.adminUiDomain || '', 'Example: onebox.example.com. Leave empty to disable the public Admin UI route.')}
|
${this.renderGatewayInput('adminUiDomain', 'Admin UI Domain', settings?.adminUiDomain || '', 'Example: onebox.example.com. Leave empty to disable the public Admin UI route.')}
|
||||||
${this.renderGatewayReadonly('Local Target', 'Onebox OpsServer on port 3000', 'The external gateway forwards to SmartProxy, which forwards this hostname to the Onebox Admin UI.')}
|
${this.renderGatewayReadonly('Local Target', 'Onebox OpsServer on port 3000', 'The external gateway forwards to SmartProxy, which forwards this hostname to the Onebox Admin UI.')}
|
||||||
</div>
|
</div>
|
||||||
<div class="gateway-footer">
|
<div slot="footer" class="gateway-footer">
|
||||||
<dees-button
|
<button class="tile-button primary" type="button" @click=${() => this.saveAdminUiSettings()}>
|
||||||
.text=${'Save Admin UI Domain'}
|
Save Admin UI Domain
|
||||||
.type=${'default'}
|
</button>
|
||||||
.icon=${'lucide:Save'}
|
|
||||||
@click=${() => this.saveAdminUiSettings()}
|
|
||||||
></dees-button>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</dees-tile>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,10 +330,12 @@ export class ObViewSettings extends DeesElement {
|
|||||||
const settings = this.settingsState.settings;
|
const settings = this.settingsState.settings;
|
||||||
const mode = settings?.dcrouterMode || 'managed';
|
const mode = settings?.dcrouterMode || 'managed';
|
||||||
return html`
|
return html`
|
||||||
<section class="gateway-card">
|
<dees-tile>
|
||||||
<div class="gateway-header">
|
<div slot="header" class="gateway-header">
|
||||||
<div class="gateway-title">dcrouter Gateway</div>
|
<div class="gateway-heading">
|
||||||
<div class="gateway-subtitle">Run a local managed dcrouter or delegate routing, DNS, and certificates to an external dcrouter.</div>
|
<span class="gateway-title">dcrouter Gateway</span>
|
||||||
|
<span class="gateway-subtitle">Run a local managed dcrouter or delegate routing to an external dcrouter</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="gateway-mode-row">
|
<div class="gateway-mode-row">
|
||||||
${this.renderModeButton('managed', 'Managed Local', mode)}
|
${this.renderModeButton('managed', 'Managed Local', mode)}
|
||||||
@@ -303,15 +361,12 @@ export class ObViewSettings extends DeesElement {
|
|||||||
<div class="gateway-disabled">dcrouter route delegation is disabled. Onebox will keep using its local SmartProxy directly.</div>
|
<div class="gateway-disabled">dcrouter route delegation is disabled. Onebox will keep using its local SmartProxy directly.</div>
|
||||||
`}
|
`}
|
||||||
</div>
|
</div>
|
||||||
<div class="gateway-footer">
|
<div slot="footer" class="gateway-footer">
|
||||||
<dees-button
|
<button class="tile-button primary" type="button" @click=${() => this.saveExternalGatewaySettings()}>
|
||||||
.text=${'Save dcrouter Settings'}
|
Save dcrouter Settings
|
||||||
.type=${'default'}
|
</button>
|
||||||
.icon=${'lucide:Save'}
|
|
||||||
@click=${() => this.saveExternalGatewaySettings()}
|
|
||||||
></dees-button>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</dees-tile>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user