vyft 0.3.0-alpha → 0.4.1-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/LICENSE +191 -21
- package/README.md +3 -49
- package/dist/commands/context/add.d.ts +4 -0
- package/dist/commands/context/add.d.ts.map +1 -0
- package/dist/commands/context/add.js +98 -0
- package/dist/commands/context/add.js.map +1 -0
- package/dist/commands/context/index.d.ts +4 -0
- package/dist/commands/context/index.d.ts.map +1 -0
- package/dist/commands/context/index.js +12 -0
- package/dist/commands/context/index.js.map +1 -0
- package/dist/commands/context/list.d.ts +4 -0
- package/dist/commands/context/list.d.ts.map +1 -0
- package/dist/commands/context/list.js +25 -0
- package/dist/commands/context/list.js.map +1 -0
- package/dist/commands/context/remove.d.ts +4 -0
- package/dist/commands/context/remove.d.ts.map +1 -0
- package/dist/commands/context/remove.js +36 -0
- package/dist/commands/context/remove.js.map +1 -0
- package/dist/commands/context/use.d.ts +4 -0
- package/dist/commands/context/use.d.ts.map +1 -0
- package/dist/commands/context/use.js +32 -0
- package/dist/commands/context/use.js.map +1 -0
- package/dist/commands/deploy.d.ts +4 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +55 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/destroy.d.ts +4 -0
- package/dist/commands/destroy.d.ts.map +1 -0
- package/dist/commands/destroy.js +70 -0
- package/dist/commands/destroy.js.map +1 -0
- package/dist/commands/diff.d.ts +4 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +52 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +92 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/local/detect.d.ts +7 -0
- package/dist/commands/local/detect.d.ts.map +1 -0
- package/dist/commands/local/detect.js +146 -0
- package/dist/commands/local/detect.js.map +1 -0
- package/dist/commands/local/dev.d.ts +4 -0
- package/dist/commands/local/dev.d.ts.map +1 -0
- package/dist/commands/local/dev.js +339 -0
- package/dist/commands/local/dev.js.map +1 -0
- package/dist/commands/local/down.d.ts +4 -0
- package/dist/commands/local/down.d.ts.map +1 -0
- package/dist/commands/local/down.js +61 -0
- package/dist/commands/local/down.js.map +1 -0
- package/dist/commands/local/index.d.ts +4 -0
- package/dist/commands/local/index.d.ts.map +1 -0
- package/dist/commands/local/index.js +12 -0
- package/dist/commands/local/index.js.map +1 -0
- package/dist/commands/local/reset.d.ts +4 -0
- package/dist/commands/local/reset.d.ts.map +1 -0
- package/dist/commands/local/reset.js +67 -0
- package/dist/commands/local/reset.js.map +1 -0
- package/dist/commands/local/up.d.ts +4 -0
- package/dist/commands/local/up.d.ts.map +1 -0
- package/dist/commands/local/up.js +58 -0
- package/dist/commands/local/up.js.map +1 -0
- package/dist/commands/refresh.d.ts +4 -0
- package/dist/commands/refresh.d.ts.map +1 -0
- package/dist/commands/refresh.js +39 -0
- package/dist/commands/refresh.js.map +1 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +69 -0
- package/dist/config.js.map +1 -0
- package/dist/contexts.d.ts +21 -0
- package/dist/contexts.d.ts.map +1 -0
- package/dist/contexts.js +72 -0
- package/dist/contexts.js.map +1 -0
- package/dist/index.d.ts +2 -8
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -0
- package/dist/lib.d.ts +7 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +6 -0
- package/dist/lib.js.map +1 -0
- package/dist/providers.d.ts +9 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +41 -0
- package/dist/providers.js.map +1 -0
- package/dist/runtime.d.ts +18 -9
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +154 -0
- package/dist/runtime.js.map +1 -0
- package/dist/runtime.test.d.ts +2 -0
- package/dist/runtime.test.d.ts.map +1 -0
- package/dist/runtime.test.js +119 -0
- package/dist/runtime.test.js.map +1 -0
- package/dist/utils/fs.d.ts +4 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +33 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/pm.d.ts +3 -0
- package/dist/utils/pm.d.ts.map +1 -0
- package/dist/utils/pm.js +17 -0
- package/dist/utils/pm.js.map +1 -0
- package/dist/utils/prompts.d.ts +2 -0
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +6 -0
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/templates.d.ts +3 -0
- package/dist/utils/templates.d.ts.map +1 -0
- package/dist/utils/templates.js +48 -0
- package/dist/utils/templates.js.map +1 -0
- package/package.json +31 -46
- package/templates/bun/index.ts +8 -0
- package/templates/bun/package.json +15 -0
- package/templates/bun/tsconfig.json +15 -0
- package/templates/bun/vyft.config.ts +3 -0
- package/dist/build.d.ts +0 -11
- package/dist/build.js +0 -39
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -398
- package/dist/context.d.ts +0 -39
- package/dist/context.js +0 -101
- package/dist/docker.d.ts +0 -62
- package/dist/docker.js +0 -876
- package/dist/exec.d.ts +0 -2
- package/dist/exec.js +0 -28
- package/dist/init.d.ts +0 -1
- package/dist/init.js +0 -117
- package/dist/interpolate.d.ts +0 -13
- package/dist/interpolate.js +0 -19
- package/dist/logger.d.ts +0 -2
- package/dist/logger.js +0 -10
- package/dist/proxy.d.ts +0 -16
- package/dist/proxy.js +0 -0
- package/dist/resource.d.ts +0 -174
- package/dist/resource.js +0 -45
- package/dist/services/index.d.ts +0 -24
- package/dist/services/index.js +0 -20
- package/dist/services/minio.d.ts +0 -36
- package/dist/services/minio.js +0 -53
- package/dist/services/mongo.d.ts +0 -28
- package/dist/services/mongo.js +0 -45
- package/dist/services/mysql.d.ts +0 -28
- package/dist/services/mysql.js +0 -44
- package/dist/services/nats.d.ts +0 -26
- package/dist/services/nats.js +0 -38
- package/dist/services/postgres.d.ts +0 -28
- package/dist/services/postgres.js +0 -45
- package/dist/services/rabbitmq.d.ts +0 -28
- package/dist/services/rabbitmq.js +0 -44
- package/dist/services/redis.d.ts +0 -28
- package/dist/services/redis.js +0 -49
- package/dist/services/storage.d.ts +0 -39
- package/dist/services/storage.js +0 -94
- package/dist/swarm/factories.d.ts +0 -16
- package/dist/swarm/factories.js +0 -63
- package/dist/swarm/index.d.ts +0 -20
- package/dist/swarm/index.js +0 -5
- package/dist/swarm/proxy.d.ts +0 -24
- package/dist/swarm/proxy.js +0 -339
- package/dist/swarm/types.d.ts +0 -26
- package/dist/swarm/types.js +0 -0
- package/dist/symbols.d.ts +0 -13
- package/dist/symbols.js +0 -2
- package/templates/fullstack/apps/api/Dockerfile +0 -22
- package/templates/fullstack/apps/api/package.json +0 -26
- package/templates/fullstack/apps/api/src/auth.ts +0 -21
- package/templates/fullstack/apps/api/src/db.ts +0 -16
- package/templates/fullstack/apps/api/src/index.ts +0 -17
- package/templates/fullstack/apps/api/src/router.ts +0 -11
- package/templates/fullstack/apps/api/src/schema.ts +0 -11
- package/templates/fullstack/apps/api/tsconfig.json +0 -8
- package/templates/fullstack/apps/web/index.html +0 -12
- package/templates/fullstack/apps/web/package.json +0 -21
- package/templates/fullstack/apps/web/src/app.tsx +0 -8
- package/templates/fullstack/apps/web/src/main.tsx +0 -9
- package/templates/fullstack/apps/web/tsconfig.json +0 -7
- package/templates/fullstack/apps/web/vite.config.ts +0 -14
- package/templates/fullstack/compose.yaml +0 -14
- package/templates/fullstack/dockerignore +0 -7
- package/templates/fullstack/gitignore +0 -3
- package/templates/fullstack/package.json +0 -18
- package/templates/fullstack/pnpm-workspace.yaml +0 -2
- package/templates/fullstack/tsconfig.json +0 -11
- package/templates/fullstack/vyft.config.ts +0 -22
package/dist/services/mysql.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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 MySQL instance. */
|
|
5
|
-
export interface MysqlConfig {
|
|
6
|
-
/** Major MySQL version. @defaultValue `9` */
|
|
7
|
-
version?: number;
|
|
8
|
-
/** Volume size hint (e.g. `"10GB"`). */
|
|
9
|
-
size?: string;
|
|
10
|
-
/** Backup configuration. */
|
|
11
|
-
backup?: BackupConfig;
|
|
12
|
-
}
|
|
13
|
-
/** A managed MySQL instance with its associated resources. */
|
|
14
|
-
export interface Mysql {
|
|
15
|
-
/** The underlying service running MySQL. */
|
|
16
|
-
service: Service;
|
|
17
|
-
/** Persistent volume for MySQL data. */
|
|
18
|
-
volume: Volume;
|
|
19
|
-
/** Auto-generated `MYSQL_ROOT_PASSWORD` secret. */
|
|
20
|
-
password: Secret;
|
|
21
|
-
/** Internal hostname reachable by other services. */
|
|
22
|
-
host: string;
|
|
23
|
-
/** Port MySQL listens on (`3306`). */
|
|
24
|
-
port: number;
|
|
25
|
-
/** Connection string with the password injected at deploy time. */
|
|
26
|
-
url: Interpolation;
|
|
27
|
-
}
|
|
28
|
-
export declare function createMysql(p: Primitives): (id: string, config?: MysqlConfig) => Mysql;
|
package/dist/services/mysql.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { interpolate } from "../interpolate.js";
|
|
2
|
-
import { validateId } from "../resource.js";
|
|
3
|
-
import { createBackupSidecar } from "./storage.js";
|
|
4
|
-
export function createMysql(p) {
|
|
5
|
-
return function mysql(id, config = {}) {
|
|
6
|
-
validateId(id);
|
|
7
|
-
const version = config.version ?? 9;
|
|
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: `mysql:${version}`,
|
|
12
|
-
port: 3306,
|
|
13
|
-
volumes: [{ volume: vol, mount: "/var/lib/mysql" }],
|
|
14
|
-
env: {
|
|
15
|
-
MYSQL_ROOT_PASSWORD: password,
|
|
16
|
-
},
|
|
17
|
-
healthCheck: {
|
|
18
|
-
command: ["mysqladmin", "ping", "-h", "localhost"],
|
|
19
|
-
interval: "5s",
|
|
20
|
-
timeout: "5s",
|
|
21
|
-
retries: 5,
|
|
22
|
-
startPeriod: "15s",
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
if (config.backup) {
|
|
26
|
-
createBackupSidecar(p, {
|
|
27
|
-
id,
|
|
28
|
-
image: `mysql:${version}`,
|
|
29
|
-
svc,
|
|
30
|
-
backup: config.backup,
|
|
31
|
-
dumpScript: `TIMESTAMP=$(date +%Y%m%d-%H%M%S) && mysqldump -h ${svc.host} -u root -p$(cat $DB_PASSWORD_FILE) --all-databases | gzip | mc pipe backup/${config.backup.storage.bucket}/${id}-$TIMESTAMP.sql.gz`,
|
|
32
|
-
env: { DB_PASSWORD: password },
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
service: svc,
|
|
37
|
-
volume: vol,
|
|
38
|
-
password,
|
|
39
|
-
host: svc.host,
|
|
40
|
-
port: 3306,
|
|
41
|
-
url: interpolate `mysql://root:${password}@${svc.host}:3306`,
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
}
|
package/dist/services/nats.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Service, Volume } from "../resource.js";
|
|
2
|
-
import type { Primitives } from "./index.js";
|
|
3
|
-
import { type BackupConfig } from "./storage.js";
|
|
4
|
-
/** Configuration for a managed NATS instance. */
|
|
5
|
-
export interface NatsConfig {
|
|
6
|
-
/** Major NATS version. @defaultValue `2` */
|
|
7
|
-
version?: number;
|
|
8
|
-
/** Volume size hint (e.g. `"5GB"`). */
|
|
9
|
-
size?: string;
|
|
10
|
-
/** Backup configuration. */
|
|
11
|
-
backup?: BackupConfig;
|
|
12
|
-
}
|
|
13
|
-
/** A managed NATS instance with JetStream enabled. */
|
|
14
|
-
export interface Nats {
|
|
15
|
-
/** The underlying service running NATS. */
|
|
16
|
-
service: Service;
|
|
17
|
-
/** Persistent volume for JetStream data. */
|
|
18
|
-
volume: Volume;
|
|
19
|
-
/** Internal hostname reachable by other services. */
|
|
20
|
-
host: string;
|
|
21
|
-
/** Port NATS listens on (`4222`). */
|
|
22
|
-
port: number;
|
|
23
|
-
/** Connection URL (e.g. `nats://<host>:4222`). */
|
|
24
|
-
url: string;
|
|
25
|
-
}
|
|
26
|
-
export declare function createNats(p: Primitives): (id: string, config?: NatsConfig) => Nats;
|
package/dist/services/nats.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { validateId } from "../resource.js";
|
|
2
|
-
import { createBackupSidecar } from "./storage.js";
|
|
3
|
-
export function createNats(p) {
|
|
4
|
-
return function nats(id, config = {}) {
|
|
5
|
-
validateId(id);
|
|
6
|
-
const version = config.version ?? 2;
|
|
7
|
-
const vol = p.volume(`${id}-data`, { size: config.size });
|
|
8
|
-
const svc = p.service(id, {
|
|
9
|
-
image: `nats:${version}`,
|
|
10
|
-
port: 4222,
|
|
11
|
-
command: ["--jetstream", "--store_dir", "/data"],
|
|
12
|
-
volumes: [{ volume: vol, mount: "/data" }],
|
|
13
|
-
healthCheck: {
|
|
14
|
-
command: ["sh", "-c", "wget -qO- http://localhost:8222/healthz"],
|
|
15
|
-
interval: "5s",
|
|
16
|
-
timeout: "5s",
|
|
17
|
-
retries: 5,
|
|
18
|
-
startPeriod: "5s",
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
if (config.backup) {
|
|
22
|
-
createBackupSidecar(p, {
|
|
23
|
-
id,
|
|
24
|
-
image: "natsio/nats-box",
|
|
25
|
-
svc,
|
|
26
|
-
backup: config.backup,
|
|
27
|
-
dumpScript: `TIMESTAMP=$(date +%Y%m%d-%H%M%S) && mkdir -p /tmp/backup && for s in $(nats -s nats://${svc.host}:4222 stream ls -n 2>/dev/null); do nats -s nats://${svc.host}:4222 stream backup "$s" "/tmp/backup/$s"; done && tar czf - -C /tmp backup | mc pipe backup/${config.backup.storage.bucket}/${id}-$TIMESTAMP.tar.gz && rm -rf /tmp/backup`,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
service: svc,
|
|
32
|
-
volume: vol,
|
|
33
|
-
host: svc.host,
|
|
34
|
-
port: 4222,
|
|
35
|
-
url: `nats://${svc.host}:4222`,
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
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 Postgres instance. */
|
|
5
|
-
export interface PostgresConfig {
|
|
6
|
-
/** Major Postgres version. @defaultValue `18` */
|
|
7
|
-
version?: number;
|
|
8
|
-
/** Volume size hint (e.g. `"10GB"`). */
|
|
9
|
-
size?: string;
|
|
10
|
-
/** Backup configuration. */
|
|
11
|
-
backup?: BackupConfig;
|
|
12
|
-
}
|
|
13
|
-
/** A managed Postgres instance with its associated resources. */
|
|
14
|
-
export interface Postgres {
|
|
15
|
-
/** The underlying service running Postgres. */
|
|
16
|
-
service: Service;
|
|
17
|
-
/** Persistent volume for Postgres data. */
|
|
18
|
-
volume: Volume;
|
|
19
|
-
/** Auto-generated `POSTGRES_PASSWORD` secret. */
|
|
20
|
-
password: Secret;
|
|
21
|
-
/** Internal hostname reachable by other services. */
|
|
22
|
-
host: string;
|
|
23
|
-
/** Port Postgres listens on (`5432`). */
|
|
24
|
-
port: number;
|
|
25
|
-
/** Connection string with the password injected at deploy time. */
|
|
26
|
-
url: Interpolation;
|
|
27
|
-
}
|
|
28
|
-
export declare function createPostgres(p: Primitives): (id: string, config?: PostgresConfig) => Postgres;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { interpolate } from "../interpolate.js";
|
|
2
|
-
import { validateId } from "../resource.js";
|
|
3
|
-
import { createBackupSidecar } from "./storage.js";
|
|
4
|
-
export function createPostgres(p) {
|
|
5
|
-
return function postgres(id, config = {}) {
|
|
6
|
-
validateId(id);
|
|
7
|
-
const version = config.version ?? 18;
|
|
8
|
-
const mount = version >= 18 ? "/var/lib/postgresql" : "/var/lib/postgresql/data";
|
|
9
|
-
const password = p.secret(`${id}-password`, { length: 32 });
|
|
10
|
-
const vol = p.volume(`${id}-data`, { size: config.size });
|
|
11
|
-
const svc = p.service(id, {
|
|
12
|
-
image: `postgres:${version}`,
|
|
13
|
-
port: 5432,
|
|
14
|
-
volumes: [{ volume: vol, mount }],
|
|
15
|
-
env: {
|
|
16
|
-
POSTGRES_PASSWORD: password,
|
|
17
|
-
},
|
|
18
|
-
healthCheck: {
|
|
19
|
-
command: ["pg_isready", "-U", "postgres"],
|
|
20
|
-
interval: "5s",
|
|
21
|
-
timeout: "5s",
|
|
22
|
-
retries: 5,
|
|
23
|
-
startPeriod: "10s",
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
if (config.backup) {
|
|
27
|
-
createBackupSidecar(p, {
|
|
28
|
-
id,
|
|
29
|
-
image: `postgres:${version}`,
|
|
30
|
-
svc,
|
|
31
|
-
backup: config.backup,
|
|
32
|
-
dumpScript: `TIMESTAMP=$(date +%Y%m%d-%H%M%S) && PGPASSWORD=$(cat $DB_PASSWORD_FILE) pg_dump -h ${svc.host} -U postgres | gzip | mc pipe backup/${config.backup.storage.bucket}/${id}-$TIMESTAMP.sql.gz`,
|
|
33
|
-
env: { DB_PASSWORD: password },
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
service: svc,
|
|
38
|
-
volume: vol,
|
|
39
|
-
password,
|
|
40
|
-
host: svc.host,
|
|
41
|
-
port: 5432,
|
|
42
|
-
url: interpolate `postgres://postgres:${password}@${svc.host}:5432/postgres`,
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
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;
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/services/redis.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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;
|
package/dist/services/redis.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
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;
|
package/dist/services/storage.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
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,16 +0,0 @@
|
|
|
1
|
-
import type { Secret, SecretConfig, Service, Site, SiteConfig, Volume } from "../resource.js";
|
|
2
|
-
import type { StorageDriver, SwarmConfig, SwarmServiceConfig, SwarmVolumeConfig } from "./types.js";
|
|
3
|
-
export declare function createFactories<D extends StorageDriver = "local">(swarmConfig: SwarmConfig<D>): {
|
|
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;
|
|
16
|
-
};
|
package/dist/swarm/factories.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { validateId, validateRoute } from "../resource.js";
|
|
2
|
-
import { createServices } from "../services/index.js";
|
|
3
|
-
import { VYFT_RUNTIME } from "../symbols.js";
|
|
4
|
-
function attachRuntime(obj, config) {
|
|
5
|
-
return Object.assign(obj, {
|
|
6
|
-
[VYFT_RUNTIME]: { name: "swarm", config },
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
export function createFactories(swarmConfig) {
|
|
10
|
-
const project = process.env.VYFT_PROJECT;
|
|
11
|
-
const prefix = project ? `${project}-` : "";
|
|
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) {
|
|
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
|
-
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,
|
|
62
|
-
};
|
|
63
|
-
}
|
package/dist/swarm/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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";
|
|
2
|
-
export { createFactories } from "./factories.js";
|
|
3
|
-
export type { DriverVolumeOptions, StorageDriver, SwarmConfig, SwarmServiceConfig, SwarmVolumeConfig, } from "./types.js";
|
|
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";
|
|
6
|
-
import type { StorageDriver, SwarmConfig, SwarmServiceConfig, SwarmVolumeConfig } from "./types.js";
|
|
7
|
-
export declare function swarm<D extends StorageDriver = "local">(config?: SwarmConfig<D>): {
|
|
8
|
-
volume: (id: string, config?: SwarmVolumeConfig<D>) => Volume;
|
|
9
|
-
service: (id: string, config: SwarmServiceConfig) => Service;
|
|
10
|
-
secret: (id: string, config?: SecretConfig) => Secret;
|
|
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;
|
|
20
|
-
};
|
package/dist/swarm/index.js
DELETED
package/dist/swarm/proxy.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
}
|