vyft 0.1.1-alpha → 0.3.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -16
- package/dist/cli.js +192 -10
- package/dist/context.d.ts +39 -0
- package/dist/context.js +101 -0
- package/dist/docker.d.ts +14 -9
- package/dist/docker.js +145 -317
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/init.js +19 -2
- package/dist/interpolate.d.ts +11 -0
- package/dist/interpolate.js +11 -0
- package/dist/proxy.d.ts +16 -0
- package/dist/proxy.js +0 -0
- package/dist/resource.d.ts +97 -1
- package/dist/resource.js +11 -1
- package/dist/runtime.d.ts +4 -0
- package/dist/services/index.d.ts +24 -0
- package/dist/services/index.js +20 -0
- package/dist/services/minio.d.ts +36 -0
- package/dist/services/minio.js +53 -0
- package/dist/services/mongo.d.ts +28 -0
- package/dist/services/mongo.js +45 -0
- package/dist/services/mysql.d.ts +28 -0
- package/dist/services/mysql.js +44 -0
- package/dist/services/nats.d.ts +26 -0
- package/dist/services/nats.js +38 -0
- package/dist/services/postgres.d.ts +28 -0
- package/dist/services/postgres.js +45 -0
- package/dist/services/rabbitmq.d.ts +28 -0
- package/dist/services/rabbitmq.js +44 -0
- package/dist/services/redis.d.ts +28 -0
- package/dist/services/redis.js +49 -0
- package/dist/services/storage.d.ts +39 -0
- package/dist/services/storage.js +94 -0
- package/dist/swarm/factories.d.ts +12 -4
- package/dist/swarm/factories.js +50 -43
- package/dist/swarm/index.d.ts +10 -0
- package/dist/swarm/proxy.d.ts +24 -0
- package/dist/swarm/proxy.js +339 -0
- package/dist/swarm/types.d.ts +11 -10
- package/dist/symbols.d.ts +5 -0
- package/dist/symbols.js +1 -0
- package/package.json +2 -5
- package/templates/fullstack/vyft.config.ts +13 -28
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Interpolation, Secret, Service, Volume } from "../resource.js";
|
|
2
|
+
import type { Primitives } from "./index.js";
|
|
3
|
+
import { type BackupConfig } from "./storage.js";
|
|
4
|
+
/** Configuration for a managed RabbitMQ instance. */
|
|
5
|
+
export interface RabbitmqConfig {
|
|
6
|
+
/** Major RabbitMQ version. @defaultValue `4` */
|
|
7
|
+
version?: number;
|
|
8
|
+
/** Volume size hint (e.g. `"5GB"`). */
|
|
9
|
+
size?: string;
|
|
10
|
+
/** Backup configuration. */
|
|
11
|
+
backup?: BackupConfig;
|
|
12
|
+
}
|
|
13
|
+
/** A managed RabbitMQ instance with its associated resources. */
|
|
14
|
+
export interface Rabbitmq {
|
|
15
|
+
/** The underlying service running RabbitMQ. */
|
|
16
|
+
service: Service;
|
|
17
|
+
/** Persistent volume for RabbitMQ data. */
|
|
18
|
+
volume: Volume;
|
|
19
|
+
/** Auto-generated `RABBITMQ_DEFAULT_PASS` secret. */
|
|
20
|
+
password: Secret;
|
|
21
|
+
/** Internal hostname reachable by other services. */
|
|
22
|
+
host: string;
|
|
23
|
+
/** Port RabbitMQ listens on (`5672`). */
|
|
24
|
+
port: number;
|
|
25
|
+
/** AMQP connection string with credentials injected at deploy time. */
|
|
26
|
+
url: Interpolation;
|
|
27
|
+
}
|
|
28
|
+
export declare function createRabbitmq(p: Primitives): (id: string, config?: RabbitmqConfig) => Rabbitmq;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { interpolate } from "../interpolate.js";
|
|
2
|
+
import { validateId } from "../resource.js";
|
|
3
|
+
import { createBackupSidecar } from "./storage.js";
|
|
4
|
+
export function createRabbitmq(p) {
|
|
5
|
+
return function rabbitmq(id, config = {}) {
|
|
6
|
+
validateId(id);
|
|
7
|
+
const version = config.version ?? 4;
|
|
8
|
+
const password = p.secret(`${id}-password`, { length: 32 });
|
|
9
|
+
const vol = p.volume(`${id}-data`, { size: config.size });
|
|
10
|
+
const svc = p.service(id, {
|
|
11
|
+
image: `rabbitmq:${version}`,
|
|
12
|
+
port: 5672,
|
|
13
|
+
volumes: [{ volume: vol, mount: "/var/lib/rabbitmq" }],
|
|
14
|
+
env: {
|
|
15
|
+
RABBITMQ_DEFAULT_PASS: password,
|
|
16
|
+
},
|
|
17
|
+
healthCheck: {
|
|
18
|
+
command: ["rabbitmq-diagnostics", "check_running"],
|
|
19
|
+
interval: "10s",
|
|
20
|
+
timeout: "10s",
|
|
21
|
+
retries: 5,
|
|
22
|
+
startPeriod: "30s",
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
if (config.backup) {
|
|
26
|
+
createBackupSidecar(p, {
|
|
27
|
+
id,
|
|
28
|
+
image: `rabbitmq:${version}`,
|
|
29
|
+
svc,
|
|
30
|
+
backup: config.backup,
|
|
31
|
+
dumpScript: `TIMESTAMP=$(date +%Y%m%d-%H%M%S) && rabbitmqctl export_definitions - | gzip | mc pipe backup/${config.backup.storage.bucket}/${id}-$TIMESTAMP.json.gz`,
|
|
32
|
+
env: { DB_PASSWORD: password },
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
service: svc,
|
|
37
|
+
volume: vol,
|
|
38
|
+
password,
|
|
39
|
+
host: svc.host,
|
|
40
|
+
port: 5672,
|
|
41
|
+
url: interpolate `amqp://guest:${password}@${svc.host}:5672`,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Interpolation, Secret, Service, Volume } from "../resource.js";
|
|
2
|
+
import type { Primitives } from "./index.js";
|
|
3
|
+
import { type BackupConfig } from "./storage.js";
|
|
4
|
+
/** Configuration for a managed Redis instance. */
|
|
5
|
+
export interface RedisConfig {
|
|
6
|
+
/** Major Redis version. @defaultValue `7` */
|
|
7
|
+
version?: number;
|
|
8
|
+
/** Volume size hint (e.g. `"5GB"`). */
|
|
9
|
+
size?: string;
|
|
10
|
+
/** Backup configuration. */
|
|
11
|
+
backup?: BackupConfig;
|
|
12
|
+
}
|
|
13
|
+
/** A managed Redis instance with its associated resources. */
|
|
14
|
+
export interface Redis {
|
|
15
|
+
/** The underlying service running Redis. */
|
|
16
|
+
service: Service;
|
|
17
|
+
/** Persistent volume for Redis data. */
|
|
18
|
+
volume: Volume;
|
|
19
|
+
/** Auto-generated `REDIS_PASSWORD` secret. */
|
|
20
|
+
password: Secret;
|
|
21
|
+
/** Internal hostname reachable by other services. */
|
|
22
|
+
host: string;
|
|
23
|
+
/** Port Redis listens on (`6379`). */
|
|
24
|
+
port: number;
|
|
25
|
+
/** Connection string with the password injected at deploy time. */
|
|
26
|
+
url: Interpolation;
|
|
27
|
+
}
|
|
28
|
+
export declare function createRedis(p: Primitives): (id: string, config?: RedisConfig) => Redis;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { interpolate } from "../interpolate.js";
|
|
2
|
+
import { validateId } from "../resource.js";
|
|
3
|
+
import { createBackupSidecar } from "./storage.js";
|
|
4
|
+
export function createRedis(p) {
|
|
5
|
+
return function redis(id, config = {}) {
|
|
6
|
+
validateId(id);
|
|
7
|
+
const version = config.version ?? 7;
|
|
8
|
+
const password = p.secret(`${id}-password`, { length: 32 });
|
|
9
|
+
const vol = p.volume(`${id}-data`, { size: config.size });
|
|
10
|
+
const svc = p.service(id, {
|
|
11
|
+
image: `redis:${version}`,
|
|
12
|
+
port: 6379,
|
|
13
|
+
command: [
|
|
14
|
+
"sh",
|
|
15
|
+
"-c",
|
|
16
|
+
'redis-server --requirepass "$(cat /run/secrets/*-password)"',
|
|
17
|
+
],
|
|
18
|
+
volumes: [{ volume: vol, mount: "/data" }],
|
|
19
|
+
env: {
|
|
20
|
+
REDIS_PASSWORD: password,
|
|
21
|
+
},
|
|
22
|
+
healthCheck: {
|
|
23
|
+
command: ["redis-cli", "ping"],
|
|
24
|
+
interval: "5s",
|
|
25
|
+
timeout: "5s",
|
|
26
|
+
retries: 5,
|
|
27
|
+
startPeriod: "5s",
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
if (config.backup) {
|
|
31
|
+
createBackupSidecar(p, {
|
|
32
|
+
id,
|
|
33
|
+
image: `redis:${version}`,
|
|
34
|
+
svc,
|
|
35
|
+
backup: config.backup,
|
|
36
|
+
dumpScript: `TIMESTAMP=$(date +%Y%m%d-%H%M%S) && redis-cli -h ${svc.host} -a $(cat $DB_PASSWORD_FILE) --rdb /tmp/dump.rdb && gzip -c /tmp/dump.rdb | mc pipe backup/${config.backup.storage.bucket}/${id}-$TIMESTAMP.rdb.gz && rm -f /tmp/dump.rdb`,
|
|
37
|
+
env: { DB_PASSWORD: password },
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
service: svc,
|
|
42
|
+
volume: vol,
|
|
43
|
+
password,
|
|
44
|
+
host: svc.host,
|
|
45
|
+
port: 6379,
|
|
46
|
+
url: interpolate `redis://:${password}@${svc.host}:6379`,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { EnvValue, Secret, Service } from "../resource.js";
|
|
2
|
+
import type { Primitives } from "./index.js";
|
|
3
|
+
/** Configuration for a managed storage backend. */
|
|
4
|
+
export interface StorageConfig {
|
|
5
|
+
/** Volume size hint for the backing store. */
|
|
6
|
+
size?: string;
|
|
7
|
+
/** MinIO image tag. @defaultValue `"latest"` */
|
|
8
|
+
version?: string;
|
|
9
|
+
}
|
|
10
|
+
/** An S3-compatible storage bucket provisioned by the shared storage backend. */
|
|
11
|
+
export interface Storage {
|
|
12
|
+
/** The backing MinIO service (for dependsOn). */
|
|
13
|
+
service: Service;
|
|
14
|
+
/** Root access key. */
|
|
15
|
+
accessKey: Secret;
|
|
16
|
+
/** Root secret key. */
|
|
17
|
+
secretKey: Secret;
|
|
18
|
+
/** S3-compatible endpoint URL (e.g. `http://<host>:9000`). */
|
|
19
|
+
endpoint: string;
|
|
20
|
+
/** Bucket name (matches the storage id). */
|
|
21
|
+
bucket: string;
|
|
22
|
+
}
|
|
23
|
+
/** Backup configuration accepted by service factories. */
|
|
24
|
+
export interface BackupConfig {
|
|
25
|
+
/** Storage target for backups. */
|
|
26
|
+
storage: Storage;
|
|
27
|
+
/** Cron expression for backup schedule. @defaultValue `"0 3 * * *"` (daily 3am) */
|
|
28
|
+
schedule?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Create a backup sidecar service for a database. */
|
|
31
|
+
export declare function createBackupSidecar(p: Primitives, opts: {
|
|
32
|
+
id: string;
|
|
33
|
+
image: string;
|
|
34
|
+
svc: Service;
|
|
35
|
+
backup: BackupConfig;
|
|
36
|
+
dumpScript: string;
|
|
37
|
+
env?: Record<string, EnvValue>;
|
|
38
|
+
}): void;
|
|
39
|
+
export declare function createStorage(p: Primitives): (id: string, config?: StorageConfig) => Storage;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { validateId } from "../resource.js";
|
|
2
|
+
/** Convert a cron expression to a sleep interval in seconds. */
|
|
3
|
+
function cronToSeconds(cron) {
|
|
4
|
+
const parts = cron.trim().split(/\s+/);
|
|
5
|
+
if (parts.length !== 5)
|
|
6
|
+
return 86400;
|
|
7
|
+
const min = parts[0];
|
|
8
|
+
const hour = parts[1];
|
|
9
|
+
if (min.startsWith("*/"))
|
|
10
|
+
return Number.parseInt(min.slice(2), 10) * 60;
|
|
11
|
+
if (hour.startsWith("*/"))
|
|
12
|
+
return Number.parseInt(hour.slice(2), 10) * 3600;
|
|
13
|
+
return 86400;
|
|
14
|
+
}
|
|
15
|
+
const MC_URL = "https://dl.min.io/client/mc/release/linux-amd64/mc";
|
|
16
|
+
/** Create a backup sidecar service for a database. */
|
|
17
|
+
export function createBackupSidecar(p, opts) {
|
|
18
|
+
const interval = cronToSeconds(opts.backup.schedule ?? "0 3 * * *");
|
|
19
|
+
p.service(`${opts.id}-backup`, {
|
|
20
|
+
image: opts.image,
|
|
21
|
+
command: [
|
|
22
|
+
"sh",
|
|
23
|
+
"-c",
|
|
24
|
+
[
|
|
25
|
+
`(curl -sLo /usr/local/bin/mc ${MC_URL} 2>/dev/null || wget -qO /usr/local/bin/mc ${MC_URL})`,
|
|
26
|
+
"chmod +x /usr/local/bin/mc",
|
|
27
|
+
`mc alias set backup ${opts.backup.storage.endpoint} $(cat $STORAGE_ACCESS_KEY_FILE) $(cat $STORAGE_SECRET_KEY_FILE)`,
|
|
28
|
+
`while true; do ${opts.dumpScript}; sleep ${interval}; done`,
|
|
29
|
+
].join(" && "),
|
|
30
|
+
],
|
|
31
|
+
env: {
|
|
32
|
+
STORAGE_ACCESS_KEY: opts.backup.storage.accessKey,
|
|
33
|
+
STORAGE_SECRET_KEY: opts.backup.storage.secretKey,
|
|
34
|
+
...opts.env,
|
|
35
|
+
},
|
|
36
|
+
dependsOn: [opts.svc, opts.backup.storage.service],
|
|
37
|
+
restartPolicy: "any",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function createStorage(p) {
|
|
41
|
+
let shared = null;
|
|
42
|
+
function ensureMinio(config) {
|
|
43
|
+
if (shared)
|
|
44
|
+
return shared;
|
|
45
|
+
const version = config?.version ?? "latest";
|
|
46
|
+
const accessKey = p.secret("storage-access-key", { length: 16 });
|
|
47
|
+
const secretKey = p.secret("storage-secret-key", { length: 32 });
|
|
48
|
+
const vol = p.volume("storage-data", { size: config?.size });
|
|
49
|
+
const svc = p.service("storage", {
|
|
50
|
+
image: `minio/minio:${version}`,
|
|
51
|
+
port: 9000,
|
|
52
|
+
command: ["server", "/data"],
|
|
53
|
+
volumes: [{ volume: vol, mount: "/data" }],
|
|
54
|
+
env: {
|
|
55
|
+
MINIO_ROOT_USER: accessKey,
|
|
56
|
+
MINIO_ROOT_PASSWORD: secretKey,
|
|
57
|
+
},
|
|
58
|
+
healthCheck: {
|
|
59
|
+
command: ["mc", "ready", "local"],
|
|
60
|
+
interval: "5s",
|
|
61
|
+
timeout: "5s",
|
|
62
|
+
retries: 5,
|
|
63
|
+
startPeriod: "5s",
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
shared = { service: svc, accessKey, secretKey, host: svc.host, vol };
|
|
67
|
+
return shared;
|
|
68
|
+
}
|
|
69
|
+
return function storage(id, config) {
|
|
70
|
+
validateId(id);
|
|
71
|
+
const minio = ensureMinio(config);
|
|
72
|
+
p.service(`storage-bucket-${id}`, {
|
|
73
|
+
image: "minio/mc:latest",
|
|
74
|
+
command: [
|
|
75
|
+
"sh",
|
|
76
|
+
"-c",
|
|
77
|
+
`mc alias set minio http://${minio.host}:9000 $(cat $ACCESS_KEY_FILE) $(cat $SECRET_KEY_FILE) && mc mb --ignore-existing minio/${id}`,
|
|
78
|
+
],
|
|
79
|
+
env: {
|
|
80
|
+
ACCESS_KEY: minio.accessKey,
|
|
81
|
+
SECRET_KEY: minio.secretKey,
|
|
82
|
+
},
|
|
83
|
+
dependsOn: [minio.service],
|
|
84
|
+
restartPolicy: "none",
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
service: minio.service,
|
|
88
|
+
accessKey: minio.accessKey,
|
|
89
|
+
secretKey: minio.secretKey,
|
|
90
|
+
endpoint: `http://${minio.host}:9000`,
|
|
91
|
+
bucket: id,
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { Secret, SecretConfig, Service, Site, SiteConfig, Volume } from "../resource.js";
|
|
2
2
|
import type { StorageDriver, SwarmConfig, SwarmServiceConfig, SwarmVolumeConfig } from "./types.js";
|
|
3
3
|
export declare function createFactories<D extends StorageDriver = "local">(swarmConfig: SwarmConfig<D>): {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
postgres: (id: string, config?: import("./index.js").PostgresConfig) => import("./index.js").Postgres;
|
|
5
|
+
redis: (id: string, config?: import("./index.js").RedisConfig) => import("./index.js").Redis;
|
|
6
|
+
rabbitmq: (id: string, config?: import("./index.js").RabbitmqConfig) => import("./index.js").Rabbitmq;
|
|
7
|
+
nats: (id: string, config?: import("./index.js").NatsConfig) => import("./index.js").Nats;
|
|
8
|
+
mysql: (id: string, config?: import("./index.js").MysqlConfig) => import("./index.js").Mysql;
|
|
9
|
+
mongo: (id: string, config?: import("./index.js").MongoConfig) => import("./index.js").Mongo;
|
|
10
|
+
minio: (id: string, config?: import("./index.js").MinioConfig) => import("./index.js").Minio;
|
|
11
|
+
storage: (id: string, config?: import("./index.js").StorageConfig) => import("./index.js").Storage;
|
|
12
|
+
volume: (id: string, config?: SwarmVolumeConfig<D>) => Volume;
|
|
13
|
+
service: (id: string, config: SwarmServiceConfig) => Service;
|
|
14
|
+
secret: (id: string, config?: SecretConfig) => Secret;
|
|
15
|
+
site: (id: string, config: SiteConfig) => Site;
|
|
8
16
|
};
|
package/dist/swarm/factories.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { validateId, validateRoute } from "../resource.js";
|
|
2
|
+
import { createServices } from "../services/index.js";
|
|
2
3
|
import { VYFT_RUNTIME } from "../symbols.js";
|
|
3
4
|
function attachRuntime(obj, config) {
|
|
4
5
|
return Object.assign(obj, {
|
|
@@ -8,49 +9,55 @@ function attachRuntime(obj, config) {
|
|
|
8
9
|
export function createFactories(swarmConfig) {
|
|
9
10
|
const project = process.env.VYFT_PROJECT;
|
|
10
11
|
const prefix = project ? `${project}-` : "";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (config.route) {
|
|
20
|
-
validateRoute(config.route);
|
|
21
|
-
}
|
|
22
|
-
const fullId = `${prefix}${id}`;
|
|
23
|
-
const port = config.port || 3000;
|
|
24
|
-
return attachRuntime({
|
|
25
|
-
type: "service",
|
|
26
|
-
id: fullId,
|
|
27
|
-
config,
|
|
28
|
-
host: fullId,
|
|
29
|
-
port,
|
|
30
|
-
url: config.route
|
|
31
|
-
? `https://${config.route}`
|
|
32
|
-
: `http://${fullId}:${port}`,
|
|
33
|
-
}, swarmConfig);
|
|
34
|
-
},
|
|
35
|
-
secret(id, config = {}) {
|
|
36
|
-
validateId(id);
|
|
37
|
-
const fullId = `${prefix}${id}`;
|
|
38
|
-
return attachRuntime({
|
|
39
|
-
type: "secret",
|
|
40
|
-
id: fullId,
|
|
41
|
-
config,
|
|
42
|
-
}, swarmConfig);
|
|
43
|
-
},
|
|
44
|
-
site(id, config) {
|
|
45
|
-
validateId(id);
|
|
12
|
+
function volume(id, config = {}) {
|
|
13
|
+
validateId(id);
|
|
14
|
+
const fullId = `${prefix}${id}`;
|
|
15
|
+
return attachRuntime({ type: "volume", id: fullId, config }, swarmConfig);
|
|
16
|
+
}
|
|
17
|
+
function service(id, config) {
|
|
18
|
+
validateId(id);
|
|
19
|
+
if (config.route) {
|
|
46
20
|
validateRoute(config.route);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
21
|
+
}
|
|
22
|
+
const fullId = `${prefix}${id}`;
|
|
23
|
+
const port = config.port || 3000;
|
|
24
|
+
return attachRuntime({
|
|
25
|
+
type: "service",
|
|
26
|
+
id: fullId,
|
|
27
|
+
config,
|
|
28
|
+
host: fullId,
|
|
29
|
+
port,
|
|
30
|
+
url: config.route
|
|
31
|
+
? `https://${config.route}`
|
|
32
|
+
: `http://${fullId}:${port}`,
|
|
33
|
+
}, swarmConfig);
|
|
34
|
+
}
|
|
35
|
+
function secret(id, config = {}) {
|
|
36
|
+
validateId(id);
|
|
37
|
+
const fullId = `${prefix}${id}`;
|
|
38
|
+
return attachRuntime({
|
|
39
|
+
type: "secret",
|
|
40
|
+
id: fullId,
|
|
41
|
+
config,
|
|
42
|
+
}, swarmConfig);
|
|
43
|
+
}
|
|
44
|
+
function site(id, config) {
|
|
45
|
+
validateId(id);
|
|
46
|
+
validateRoute(config.route);
|
|
47
|
+
const fullId = `${prefix}${id}`;
|
|
48
|
+
return attachRuntime({
|
|
49
|
+
type: "site",
|
|
50
|
+
id: fullId,
|
|
51
|
+
config,
|
|
52
|
+
url: `https://${config.route}`,
|
|
53
|
+
}, swarmConfig);
|
|
54
|
+
}
|
|
55
|
+
const services = createServices({ volume, service, secret });
|
|
56
|
+
return {
|
|
57
|
+
volume,
|
|
58
|
+
service,
|
|
59
|
+
secret,
|
|
60
|
+
site,
|
|
61
|
+
...services,
|
|
55
62
|
};
|
|
56
63
|
}
|
package/dist/swarm/index.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
export type { BackupConfig, Bucket, Minio, MinioConfig, Mongo, MongoConfig, Mysql, MysqlConfig, Nats, NatsConfig, Postgres, PostgresConfig, Rabbitmq, RabbitmqConfig, Redis, RedisConfig, Storage, StorageConfig, } from "../services/index.js";
|
|
1
2
|
export { createFactories } from "./factories.js";
|
|
2
3
|
export type { DriverVolumeOptions, StorageDriver, SwarmConfig, SwarmServiceConfig, SwarmVolumeConfig, } from "./types.js";
|
|
3
4
|
import type { Secret, SecretConfig, Service, Site, SiteConfig, Volume } from "../resource.js";
|
|
5
|
+
import type { Minio, MinioConfig, Mongo, MongoConfig, Mysql, MysqlConfig, Nats, NatsConfig, Postgres, PostgresConfig, Rabbitmq, RabbitmqConfig, Redis, RedisConfig, Storage, StorageConfig } from "../services/index.js";
|
|
4
6
|
import type { StorageDriver, SwarmConfig, SwarmServiceConfig, SwarmVolumeConfig } from "./types.js";
|
|
5
7
|
export declare function swarm<D extends StorageDriver = "local">(config?: SwarmConfig<D>): {
|
|
6
8
|
volume: (id: string, config?: SwarmVolumeConfig<D>) => Volume;
|
|
7
9
|
service: (id: string, config: SwarmServiceConfig) => Service;
|
|
8
10
|
secret: (id: string, config?: SecretConfig) => Secret;
|
|
9
11
|
site: (id: string, config: SiteConfig) => Site;
|
|
12
|
+
postgres: (id: string, config?: PostgresConfig) => Postgres;
|
|
13
|
+
mysql: (id: string, config?: MysqlConfig) => Mysql;
|
|
14
|
+
redis: (id: string, config?: RedisConfig) => Redis;
|
|
15
|
+
rabbitmq: (id: string, config?: RabbitmqConfig) => Rabbitmq;
|
|
16
|
+
nats: (id: string, config?: NatsConfig) => Nats;
|
|
17
|
+
mongo: (id: string, config?: MongoConfig) => Mongo;
|
|
18
|
+
minio: (id: string, config?: MinioConfig) => Minio;
|
|
19
|
+
storage: (id: string, config?: StorageConfig) => Storage;
|
|
10
20
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type Docker from "dockerode";
|
|
2
|
+
import type { Logger } from "pino";
|
|
3
|
+
import type { ReverseProxy } from "../proxy.js";
|
|
4
|
+
export declare function buildCaddyRoute(resourceId: string, route: string, handler: Record<string, unknown>): Record<string, unknown>;
|
|
5
|
+
export declare class CaddyProxy implements ReverseProxy {
|
|
6
|
+
private docker;
|
|
7
|
+
private log;
|
|
8
|
+
constructor(docker: Docker, log: Logger);
|
|
9
|
+
ensure(): Promise<void>;
|
|
10
|
+
addRoute(resourceId: string, route: string, target: {
|
|
11
|
+
host: string;
|
|
12
|
+
port: number;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
removeRoute(resourceId: string): Promise<void>;
|
|
15
|
+
logs(options: {
|
|
16
|
+
follow?: boolean;
|
|
17
|
+
tail?: number;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
private findProxyContainer;
|
|
20
|
+
private caddyApiRequest;
|
|
21
|
+
private seedCaddyConfig;
|
|
22
|
+
private serviceExists;
|
|
23
|
+
private ensureNetwork;
|
|
24
|
+
}
|