@crossdelta/infrastructure 0.2.27 → 0.3.0-beta.1
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 +519 -301
- package/bin/generate-env.ts +4 -7
- package/dist/core/compat.d.ts +72 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/runtime-detection.d.ts +15 -0
- package/dist/core/runtime.d.ts +221 -0
- package/dist/core/types.d.ts +419 -0
- package/dist/env.cjs +11 -17
- package/dist/env.d.ts +16 -2
- package/dist/env.js +12 -16
- package/dist/helpers/discover-services.d.ts +62 -5
- package/dist/helpers/docker-hub-image.d.ts +2 -3
- package/dist/helpers/index.d.ts +0 -7
- package/dist/index.cjs +21273 -21029
- package/dist/index.d.ts +28 -1
- package/dist/index.js +21273 -21029
- package/dist/runtimes/doks/types.d.ts +45 -3
- package/dist/runtimes/doks/workloads.d.ts +6 -6
- package/dist/runtimes/local/docker-compose.d.ts +38 -0
- package/dist/runtimes/local/index.d.ts +9 -0
- package/dist/runtimes/local/k3d.d.ts +58 -0
- package/dist/runtimes/local/types.d.ts +118 -0
- package/dist/types/index.d.ts +12 -146
- package/dist/types/service-names.d.ts +1 -1
- package/package.json +3 -2
- package/dist/helpers/config.d.ts +0 -29
- package/dist/helpers/droplet-builder.d.ts +0 -44
- package/dist/helpers/image.d.ts +0 -30
- package/dist/helpers/otel.d.ts +0 -62
- package/dist/helpers/service-builder.d.ts +0 -39
- package/dist/helpers/service-runtime.d.ts +0 -22
- package/dist/helpers/service-urls.d.ts +0 -27
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type * as digitalocean from '@pulumi/digitalocean';
|
|
2
2
|
import type * as pulumi from '@pulumi/pulumi';
|
|
3
|
+
import type { ServicePorts } from '../../core/types';
|
|
3
4
|
/** DigitalOcean Kubernetes Cluster Args (from @pulumi/digitalocean) */
|
|
4
5
|
export type DOKSClusterArgs = digitalocean.KubernetesClusterArgs;
|
|
5
6
|
/** DigitalOcean VPC Args (from @pulumi/digitalocean) */
|
|
@@ -202,8 +203,43 @@ export interface K8sServiceConfig {
|
|
|
202
203
|
* If not specified, auto-generated from pf.registry config + service name.
|
|
203
204
|
*/
|
|
204
205
|
image?: string;
|
|
205
|
-
/**
|
|
206
|
-
|
|
206
|
+
/**
|
|
207
|
+
* Unified port configuration (recommended).
|
|
208
|
+
*
|
|
209
|
+
* Use the fluent ports API for cleaner configuration:
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* import { ports } from '@crossdelta/infrastructure'
|
|
213
|
+
*
|
|
214
|
+
* // Simple HTTP service
|
|
215
|
+
* ports: ports().http(8080).public().build()
|
|
216
|
+
*
|
|
217
|
+
* // Multi-port service (e.g., NATS)
|
|
218
|
+
* ports: ports()
|
|
219
|
+
* .primary(4222, 'client')
|
|
220
|
+
* .add(8222, 'monitoring')
|
|
221
|
+
* .add(6222, 'routing')
|
|
222
|
+
* .build()
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
ports?: ServicePorts;
|
|
226
|
+
/**
|
|
227
|
+
* Port the container listens on (legacy, deprecated).
|
|
228
|
+
*
|
|
229
|
+
* @deprecated Use `ports` instead for better multi-port support.
|
|
230
|
+
* This field is auto-converted to `ports` internally for backward compatibility.
|
|
231
|
+
* Will be removed in v0.4.0.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* // Old way (still works)
|
|
236
|
+
* containerPort: 3000
|
|
237
|
+
*
|
|
238
|
+
* // New way (recommended)
|
|
239
|
+
* ports: ports().http(3000).build()
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
containerPort?: number;
|
|
207
243
|
/** Number of replicas (defaults to 1) */
|
|
208
244
|
replicas?: number;
|
|
209
245
|
/** Environment variables (plain values) */
|
|
@@ -232,7 +268,13 @@ export interface K8sServiceConfig {
|
|
|
232
268
|
skip?: boolean;
|
|
233
269
|
/** Image pull policy (defaults to 'Always' for :latest, 'IfNotPresent' otherwise) */
|
|
234
270
|
imagePullPolicy?: 'Always' | 'Never' | 'IfNotPresent';
|
|
235
|
-
/**
|
|
271
|
+
/**
|
|
272
|
+
* Additional ports to expose (legacy, deprecated).
|
|
273
|
+
*
|
|
274
|
+
* @deprecated Use `ports.additional` instead.
|
|
275
|
+
* This field is auto-converted to `ports.additional` internally for backward compatibility.
|
|
276
|
+
* Will be removed in v0.4.0.
|
|
277
|
+
*/
|
|
236
278
|
additionalPorts?: Array<{
|
|
237
279
|
name: string;
|
|
238
280
|
port: number;
|
|
@@ -13,11 +13,11 @@ import type { DeployK8sServicesOptions, K8sServiceConfig, K8sServiceDeploymentRe
|
|
|
13
13
|
* })
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
export declare
|
|
16
|
+
export declare const createImagePullSecret: (provider: k8s.Provider, namespace: string, name: string, config: {
|
|
17
17
|
registry: string;
|
|
18
18
|
username: pulumi.Input<string>;
|
|
19
19
|
password: pulumi.Input<string>;
|
|
20
|
-
})
|
|
20
|
+
}) => k8s.core.v1.Secret;
|
|
21
21
|
/**
|
|
22
22
|
* Deploys a service to Kubernetes.
|
|
23
23
|
*
|
|
@@ -50,7 +50,7 @@ export declare function createImagePullSecret(provider: k8s.Provider, namespace:
|
|
|
50
50
|
* // http://orders.orderboss.svc.cluster.local:4001
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
|
-
export declare
|
|
53
|
+
export declare const deployK8sService: (provider: k8s.Provider, namespace: string, config: K8sServiceConfig) => K8sServiceDeploymentResult;
|
|
54
54
|
/**
|
|
55
55
|
* Deploys multiple services to Kubernetes.
|
|
56
56
|
*
|
|
@@ -63,7 +63,7 @@ export declare function deployK8sService(provider: k8s.Provider, namespace: stri
|
|
|
63
63
|
* ], { imagePullSecretName: 'ghcr-secret' })
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
|
-
export declare
|
|
66
|
+
export declare const deployK8sServices: (provider: k8s.Provider, namespace: string, configs: K8sServiceConfig[], options?: DeployK8sServicesOptions) => Map<string, K8sServiceDeploymentResult>;
|
|
67
67
|
/**
|
|
68
68
|
* Creates a Kubernetes namespace.
|
|
69
69
|
*
|
|
@@ -72,8 +72,8 @@ export declare function deployK8sServices(provider: k8s.Provider, namespace: str
|
|
|
72
72
|
* const ns = createNamespace(provider, 'orderboss')
|
|
73
73
|
* ```
|
|
74
74
|
*/
|
|
75
|
-
export declare
|
|
75
|
+
export declare const createNamespace: (provider: k8s.Provider, name: string, labels?: Record<string, string>) => k8s.core.v1.Namespace;
|
|
76
76
|
/**
|
|
77
77
|
* Builds an internal service URL for cluster-internal communication.
|
|
78
78
|
*/
|
|
79
|
-
export declare
|
|
79
|
+
export declare const buildInternalUrl: (serviceName: string, namespace: string, port: number) => string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Docker Compose Runtime for Local Development
|
|
3
|
+
*
|
|
4
|
+
* Simplified local development without Kubernetes complexity.
|
|
5
|
+
* Perfect for running simple services quickly.
|
|
6
|
+
*/
|
|
7
|
+
import type { K8sServiceConfig } from '../doks/types';
|
|
8
|
+
import type { ComposeProjectConfig, ComposeServiceConfig } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Convert K8sServiceConfig to Docker Compose service
|
|
11
|
+
*
|
|
12
|
+
* @param config - Kubernetes service configuration
|
|
13
|
+
* @returns Docker Compose service configuration
|
|
14
|
+
*/
|
|
15
|
+
export declare const convertToComposeService: (config: K8sServiceConfig) => ComposeServiceConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Generate Docker Compose YAML from K8sServiceConfigs
|
|
18
|
+
*
|
|
19
|
+
* @param services - Services to include in docker-compose.yml
|
|
20
|
+
* @param projectName - Project name (default: 'orderboss-local')
|
|
21
|
+
* @returns Docker Compose project configuration
|
|
22
|
+
*/
|
|
23
|
+
export declare const generateComposeProject: (services: K8sServiceConfig[], projectName?: string) => ComposeProjectConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Generate docker-compose.yml content
|
|
26
|
+
*
|
|
27
|
+
* @param project - Docker Compose project configuration
|
|
28
|
+
* @returns YAML string for docker-compose.yml
|
|
29
|
+
*/
|
|
30
|
+
export declare const generateComposeYaml: (project: ComposeProjectConfig) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Generate setup script for Docker Compose
|
|
33
|
+
*
|
|
34
|
+
* @param services - Services to deploy
|
|
35
|
+
* @param projectName - Project name
|
|
36
|
+
* @returns Shell script to setup local environment
|
|
37
|
+
*/
|
|
38
|
+
export declare const generateComposeSetupScript: (services: K8sServiceConfig[], projectName?: string) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local Development Provider
|
|
3
|
+
*
|
|
4
|
+
* Enables local Kubernetes development using k3d or simple Docker Compose setups.
|
|
5
|
+
* Perfect for testing infrastructure configs before deploying to production.
|
|
6
|
+
*/
|
|
7
|
+
export * from './docker-compose';
|
|
8
|
+
export * from './k3d';
|
|
9
|
+
export * from './types';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* k3d Runtime for Local Kubernetes Development
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities to create and manage local k3d clusters for testing
|
|
5
|
+
* Kubernetes configurations before deploying to production.
|
|
6
|
+
*
|
|
7
|
+
* @see https://k3d.io/
|
|
8
|
+
*/
|
|
9
|
+
import type { K8sServiceConfig } from '../doks/types';
|
|
10
|
+
import type { K3dClusterConfig, LocalProviderOptions } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Generate k3d cluster creation command
|
|
13
|
+
*
|
|
14
|
+
* @param config - k3d cluster configuration
|
|
15
|
+
* @returns Shell command to create k3d cluster
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const cmd = generateK3dCreateCommand({ name: 'my-cluster' })
|
|
20
|
+
* console.log(cmd)
|
|
21
|
+
* // k3d cluster create my-cluster --servers 1 --agents 1 ...
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const generateK3dCreateCommand: (config?: K3dClusterConfig) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Generate k3d cluster deletion command
|
|
27
|
+
*
|
|
28
|
+
* @param clusterName - Name of cluster to delete
|
|
29
|
+
* @returns Shell command to delete k3d cluster
|
|
30
|
+
*/
|
|
31
|
+
export declare const generateK3dDeleteCommand: (clusterName?: string) => string;
|
|
32
|
+
/**
|
|
33
|
+
* Convert K8sServiceConfig to kubectl apply command
|
|
34
|
+
*
|
|
35
|
+
* Generates a kubectl command that creates:
|
|
36
|
+
* - Deployment
|
|
37
|
+
* - Service (if ports configured)
|
|
38
|
+
* - Ingress (if public ports)
|
|
39
|
+
*
|
|
40
|
+
* @param config - Service configuration
|
|
41
|
+
* @param namespace - Kubernetes namespace
|
|
42
|
+
* @returns Shell command to apply resources
|
|
43
|
+
*/
|
|
44
|
+
export declare const generateKubectlApplyCommand: (config: K8sServiceConfig, namespace?: string) => string;
|
|
45
|
+
/**
|
|
46
|
+
* Setup script for local k3d development
|
|
47
|
+
*
|
|
48
|
+
* Generates a complete shell script that:
|
|
49
|
+
* 1. Creates k3d cluster
|
|
50
|
+
* 2. Waits for cluster to be ready
|
|
51
|
+
* 3. Creates namespace
|
|
52
|
+
* 4. Deploys all services
|
|
53
|
+
*
|
|
54
|
+
* @param services - Services to deploy
|
|
55
|
+
* @param options - Local provider options
|
|
56
|
+
* @returns Complete setup script
|
|
57
|
+
*/
|
|
58
|
+
export declare const generateLocalSetupScript: (services: K8sServiceConfig[], options?: LocalProviderOptions) => string;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local Development Provider Types
|
|
3
|
+
*
|
|
4
|
+
* Enables local Kubernetes development using k3d or simple Docker Compose setups.
|
|
5
|
+
* Perfect for testing infrastructure configs before deploying to production.
|
|
6
|
+
*/
|
|
7
|
+
import type { CoreServiceConfig } from '../../core/types';
|
|
8
|
+
/**
|
|
9
|
+
* Base configuration for local development services
|
|
10
|
+
*/
|
|
11
|
+
export interface LocalServiceConfig extends CoreServiceConfig {
|
|
12
|
+
provider: 'local';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* k3d cluster configuration for local Kubernetes development
|
|
16
|
+
*
|
|
17
|
+
* @see https://k3d.io/
|
|
18
|
+
*/
|
|
19
|
+
export interface K3dClusterConfig {
|
|
20
|
+
/** Cluster name (default: 'orderboss-local') */
|
|
21
|
+
name?: string;
|
|
22
|
+
/** Number of server nodes (default: 1) */
|
|
23
|
+
servers?: number;
|
|
24
|
+
/** Number of agent nodes (default: 1) */
|
|
25
|
+
agents?: number;
|
|
26
|
+
/** Port mappings for ingress (default: [{ host: 8080, container: 80 }]) */
|
|
27
|
+
ports?: Array<{
|
|
28
|
+
host: number;
|
|
29
|
+
container: number;
|
|
30
|
+
protocol?: 'tcp' | 'udp';
|
|
31
|
+
}>;
|
|
32
|
+
/** Registry to use (default: k3d-managed registry on port 5000) */
|
|
33
|
+
registry?: {
|
|
34
|
+
name?: string;
|
|
35
|
+
port?: number;
|
|
36
|
+
host?: string;
|
|
37
|
+
};
|
|
38
|
+
/** K3s version to use (default: latest) */
|
|
39
|
+
k3sVersion?: string;
|
|
40
|
+
/** Additional k3d options */
|
|
41
|
+
options?: {
|
|
42
|
+
/** Wait for cluster to be ready (default: true) */
|
|
43
|
+
wait?: boolean;
|
|
44
|
+
/** Timeout in seconds (default: 60) */
|
|
45
|
+
timeout?: number;
|
|
46
|
+
/** API port on host (default: 6550) */
|
|
47
|
+
apiPort?: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Docker Compose service configuration
|
|
52
|
+
*
|
|
53
|
+
* Simplified local development without Kubernetes complexity.
|
|
54
|
+
*/
|
|
55
|
+
export interface ComposeServiceConfig {
|
|
56
|
+
/** Service name */
|
|
57
|
+
name: string;
|
|
58
|
+
/** Docker image */
|
|
59
|
+
image: string;
|
|
60
|
+
/** Port mappings (host:container) */
|
|
61
|
+
ports?: string[];
|
|
62
|
+
/** Environment variables */
|
|
63
|
+
environment?: Record<string, string>;
|
|
64
|
+
/** Volume mappings */
|
|
65
|
+
volumes?: string[];
|
|
66
|
+
/** Service dependencies */
|
|
67
|
+
dependsOn?: string[];
|
|
68
|
+
/** Command override */
|
|
69
|
+
command?: string | string[];
|
|
70
|
+
/** Health check */
|
|
71
|
+
healthCheck?: {
|
|
72
|
+
test: string | string[];
|
|
73
|
+
interval?: string;
|
|
74
|
+
timeout?: string;
|
|
75
|
+
retries?: number;
|
|
76
|
+
startPeriod?: string;
|
|
77
|
+
};
|
|
78
|
+
/** Restart policy (default: 'unless-stopped') */
|
|
79
|
+
restart?: 'no' | 'always' | 'on-failure' | 'unless-stopped';
|
|
80
|
+
/** Networks to join */
|
|
81
|
+
networks?: string[];
|
|
82
|
+
/** Labels */
|
|
83
|
+
labels?: Record<string, string>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Docker Compose project configuration
|
|
87
|
+
*/
|
|
88
|
+
export interface ComposeProjectConfig {
|
|
89
|
+
/** Project name */
|
|
90
|
+
name: string;
|
|
91
|
+
/** Services */
|
|
92
|
+
services: ComposeServiceConfig[];
|
|
93
|
+
/** Networks */
|
|
94
|
+
networks?: Record<string, {
|
|
95
|
+
driver?: string;
|
|
96
|
+
external?: boolean;
|
|
97
|
+
}>;
|
|
98
|
+
/** Volumes */
|
|
99
|
+
volumes?: Record<string, {
|
|
100
|
+
driver?: string;
|
|
101
|
+
external?: boolean;
|
|
102
|
+
}>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Local provider options
|
|
106
|
+
*/
|
|
107
|
+
export interface LocalProviderOptions {
|
|
108
|
+
/** Runtime to use (default: 'k3d') */
|
|
109
|
+
runtime?: 'k3d' | 'docker-compose';
|
|
110
|
+
/** k3d cluster configuration (for runtime='k3d') */
|
|
111
|
+
k3d?: K3dClusterConfig;
|
|
112
|
+
/** Compose project configuration (for runtime='docker-compose') */
|
|
113
|
+
compose?: Partial<ComposeProjectConfig>;
|
|
114
|
+
/** Namespace for Kubernetes resources (default: 'default') */
|
|
115
|
+
namespace?: string;
|
|
116
|
+
/** Auto-create namespace if it doesn't exist (default: true) */
|
|
117
|
+
autoCreateNamespace?: boolean;
|
|
118
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,153 +1,19 @@
|
|
|
1
|
-
import type { AppSpecService } from '@pulumi/digitalocean/types/input';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
export declare const RegistryType: {
|
|
6
|
-
/** Docker Hub - public or private images */
|
|
7
|
-
readonly DOCKER_HUB: "DOCKER_HUB";
|
|
8
|
-
/** GitHub Container Registry */
|
|
9
|
-
readonly GHCR: "GHCR";
|
|
10
|
-
/** DigitalOcean Container Registry */
|
|
11
|
-
readonly DOCR: "DOCR";
|
|
12
|
-
};
|
|
13
|
-
export type RegistryType = (typeof RegistryType)[keyof typeof RegistryType];
|
|
14
|
-
/**
|
|
15
|
-
* Image configuration for a service.
|
|
16
|
-
*/
|
|
17
|
-
export interface ImageConfig {
|
|
18
|
-
/** Registry type */
|
|
19
|
-
registryType: RegistryType;
|
|
20
|
-
/** Registry name (e.g., 'library' for official Docker Hub images, 'orderboss' for GHCR) */
|
|
21
|
-
registry: string;
|
|
22
|
-
/** Repository name (e.g., 'nats', 'platform/storefront') */
|
|
23
|
-
repository: string;
|
|
24
|
-
/** Image tag (e.g., '2.10-alpine', 'latest') */
|
|
25
|
-
tag: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Platform type for service deployment.
|
|
29
|
-
*/
|
|
30
|
-
export declare const Platform: {
|
|
31
|
-
/** DigitalOcean App Platform (default) */
|
|
32
|
-
readonly APP_PLATFORM: "app-platform";
|
|
33
|
-
/** DigitalOcean Droplet with Docker */
|
|
34
|
-
readonly DROPLET: "droplet";
|
|
35
|
-
};
|
|
36
|
-
export type Platform = (typeof Platform)[keyof typeof Platform];
|
|
37
|
-
/**
|
|
38
|
-
* Volume configuration for persistent storage (Droplet only).
|
|
39
|
-
*/
|
|
40
|
-
export interface VolumeConfig {
|
|
41
|
-
/** Volume name (must be unique) */
|
|
42
|
-
name: string;
|
|
43
|
-
/** Mount path inside the container */
|
|
44
|
-
mountPath: string;
|
|
45
|
-
/** Size in GB */
|
|
46
|
-
sizeGb: number;
|
|
47
|
-
/** Optional description for the volume */
|
|
48
|
-
description?: string;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Droplet-specific configuration options.
|
|
52
|
-
*/
|
|
53
|
-
export interface DropletConfig {
|
|
54
|
-
/** Droplet size slug (e.g., 's-1vcpu-1gb') */
|
|
55
|
-
size: string;
|
|
56
|
-
/** Persistent volumes to attach */
|
|
57
|
-
volumes?: VolumeConfig[];
|
|
58
|
-
/** Firewall rules for VPC access */
|
|
59
|
-
vpcPorts?: number[];
|
|
60
|
-
/** Ports to open for all IPs (use for App Platform access) */
|
|
61
|
-
publicPorts?: number[];
|
|
62
|
-
/** Environment variables to pass to the Docker container */
|
|
63
|
-
envVars?: Record<string, string>;
|
|
64
|
-
/** Additional Docker run arguments */
|
|
65
|
-
dockerArgs?: string;
|
|
66
|
-
/**
|
|
67
|
-
* Config file to mount into the container.
|
|
68
|
-
* The content will be written to the Droplet and mounted into Docker.
|
|
69
|
-
*/
|
|
70
|
-
configFile?: {
|
|
71
|
-
/** Path inside the container (e.g., '/etc/nats/nats.conf') */
|
|
72
|
-
containerPath: string;
|
|
73
|
-
/** File content (will be written to Droplet) */
|
|
74
|
-
content: string;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Configuration for a service that will be deployed to DigitalOcean App Platform.
|
|
79
|
-
* Each service in infra/services/*.ts should export a default object of this type.
|
|
2
|
+
* @crossdelta/infrastructure - Type Definitions
|
|
80
3
|
*
|
|
81
|
-
*
|
|
4
|
+
* This file contains shared type definitions that don't belong to a specific
|
|
5
|
+
* runtime (DOKS, EKS, AKS, etc.).
|
|
82
6
|
*
|
|
83
|
-
*
|
|
7
|
+
* For runtime-specific types, see:
|
|
8
|
+
* - Kubernetes (DOKS/EKS/AKS/GKE): lib/runtimes/doks/types.ts
|
|
9
|
+
* - Local development: lib/runtimes/local/types.ts (coming soon)
|
|
84
10
|
*
|
|
85
|
-
*
|
|
86
|
-
* -
|
|
11
|
+
* @deprecated The following types are DEPRECATED (removed in v0.4.0):
|
|
12
|
+
* - ServiceConfig (use K8sServiceConfig instead)
|
|
13
|
+
* - Platform enum (use Provider enum from core/types.ts)
|
|
14
|
+
* - RegistryType, ImageConfig (use simple string URLs)
|
|
15
|
+
* - VolumeConfig, DropletConfig (moved to DOKS types)
|
|
87
16
|
*
|
|
88
|
-
*
|
|
89
|
-
* - `<SERVICE>_PORT` environment variable
|
|
90
|
-
* - `<SERVICE>_URL` environment variable (unless `internalUrl` is set)
|
|
91
|
-
*
|
|
92
|
-
* ## Platform Selection
|
|
93
|
-
*
|
|
94
|
-
* By default, services run on App Platform. Set `platform: 'droplet'` for services
|
|
95
|
-
* that need persistent storage or special networking (e.g., NATS with JetStream).
|
|
96
|
-
*
|
|
97
|
-
* ## Examples
|
|
98
|
-
*
|
|
99
|
-
* ```ts
|
|
100
|
-
* // Public service on App Platform (API Gateway)
|
|
101
|
-
* { httpPort: 4000, ingressPrefix: '/api' }
|
|
102
|
-
*
|
|
103
|
-
* // Internal-only service on App Platform (Orders)
|
|
104
|
-
* { internalPorts: [4001] }
|
|
105
|
-
*
|
|
106
|
-
* // Service on Droplet with persistent volume (NATS)
|
|
107
|
-
* {
|
|
108
|
-
* platform: 'droplet',
|
|
109
|
-
* internalPorts: [4222, 8222],
|
|
110
|
-
* internalUrl: 'nats://nats:4222',
|
|
111
|
-
* droplet: {
|
|
112
|
-
* size: 's-1vcpu-1gb',
|
|
113
|
-
* volumes: [{ name: 'nats-data', mountPath: '/data', sizeGb: 10 }],
|
|
114
|
-
* },
|
|
115
|
-
* }
|
|
116
|
-
* ```
|
|
117
|
-
*
|
|
118
|
-
* @see https://docs.digitalocean.com/reference/api/digitalocean/#tag/Apps
|
|
119
|
-
*/
|
|
120
|
-
export type ServiceConfig = Partial<Omit<AppSpecService, 'image'>> & {
|
|
121
|
-
/** Unique name of the service (required) */
|
|
122
|
-
name: string;
|
|
123
|
-
/**
|
|
124
|
-
* Deployment platform. Defaults to 'app-platform'.
|
|
125
|
-
* Use 'droplet' for services that need persistent storage or special networking.
|
|
126
|
-
*/
|
|
127
|
-
platform?: Platform;
|
|
128
|
-
/**
|
|
129
|
-
* Ingress path prefix for public routing (e.g., '/api').
|
|
130
|
-
* Only used when `httpPort` is set. Services with only `internalPorts` cannot have ingress.
|
|
131
|
-
*/
|
|
132
|
-
ingressPrefix?: string;
|
|
133
|
-
/** Set to true to exclude this service from deployment */
|
|
134
|
-
skip?: boolean;
|
|
135
|
-
/** Custom image configuration (defaults to GHCR image based on service name) */
|
|
136
|
-
image?: ImageConfig;
|
|
137
|
-
/**
|
|
138
|
-
* Override the internal URL for service-to-service communication.
|
|
139
|
-
* Use this for non-HTTP protocols (e.g., 'nats://nats:4222').
|
|
140
|
-
* If not set, defaults to `http://{name}:{primaryPort}`.
|
|
141
|
-
*/
|
|
142
|
-
internalUrl?: string;
|
|
143
|
-
/**
|
|
144
|
-
* Droplet-specific configuration. Only used when `platform: 'droplet'`.
|
|
145
|
-
*/
|
|
146
|
-
droplet?: DropletConfig;
|
|
147
|
-
};
|
|
148
|
-
/**
|
|
149
|
-
* Full service spec after merging with common config.
|
|
150
|
-
* This is what gets passed to the DigitalOcean App spec.
|
|
17
|
+
* See MIGRATION.md for upgrade guide.
|
|
151
18
|
*/
|
|
152
|
-
export type FullServiceSpec = AppSpecService;
|
|
153
19
|
export * from './service-names';
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* Known service names in the platform.
|
|
7
7
|
* This type is auto-generated from infra/services/*.ts
|
|
8
8
|
*/
|
|
9
|
-
export type ServiceName = '
|
|
9
|
+
export type ServiceName = 'my-hono-service' | 'orders' | 'notifications' | 'storefront' | 'api-gateway';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crossdelta/infrastructure",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@pulumi/pulumi": "^3.208.0",
|
|
41
41
|
"@types/bun": "latest",
|
|
42
42
|
"@types/node": "^24.10.1",
|
|
43
|
+
"bun-types": "^1.3.4",
|
|
43
44
|
"typescript": "^5.9.3"
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|
|
@@ -47,6 +48,6 @@
|
|
|
47
48
|
"prepublishOnly": "bun run build",
|
|
48
49
|
"generate-env": "bun run cli/commands/generate-env.ts",
|
|
49
50
|
"lint": "biome lint --fix",
|
|
50
|
-
"test": "
|
|
51
|
+
"test": "bun test"
|
|
51
52
|
}
|
|
52
53
|
}
|
package/dist/helpers/config.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Input } from '@pulumi/pulumi';
|
|
2
|
-
/**
|
|
3
|
-
* Ensures that a string ends with a dot (useful for DNS CNAME values).
|
|
4
|
-
*/
|
|
5
|
-
export declare const ensureDot: (str: string) => string;
|
|
6
|
-
/**
|
|
7
|
-
* Common alert configuration for services
|
|
8
|
-
*/
|
|
9
|
-
export declare const defaultAlerts: {
|
|
10
|
-
rule: string;
|
|
11
|
-
operator: string;
|
|
12
|
-
value: number;
|
|
13
|
-
window: string;
|
|
14
|
-
}[];
|
|
15
|
-
/**
|
|
16
|
-
* Creates log destinations config with Logtail token
|
|
17
|
-
*/
|
|
18
|
-
export declare const createLogDestinations: (logtailToken: Input<string>) => {
|
|
19
|
-
name: string;
|
|
20
|
-
logtail: {
|
|
21
|
-
token: Input<string>;
|
|
22
|
-
};
|
|
23
|
-
}[];
|
|
24
|
-
/**
|
|
25
|
-
* Default health check configuration
|
|
26
|
-
*/
|
|
27
|
-
export declare const defaultHealthCheck: {
|
|
28
|
-
httpPath: string;
|
|
29
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import * as digitalocean from '@pulumi/digitalocean';
|
|
2
|
-
import * as pulumi from '@pulumi/pulumi';
|
|
3
|
-
import type { ServiceConfig } from '../types';
|
|
4
|
-
export interface DropletServiceResources {
|
|
5
|
-
droplet: digitalocean.Droplet;
|
|
6
|
-
volume?: digitalocean.Volume;
|
|
7
|
-
volumeAttachment?: digitalocean.VolumeAttachment;
|
|
8
|
-
firewall?: digitalocean.Firewall;
|
|
9
|
-
/** Private IP for VPC communication */
|
|
10
|
-
privateIp: pulumi.Output<string>;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Environment variables that can contain Pulumi secrets.
|
|
14
|
-
*/
|
|
15
|
-
export type SecretEnvVars = Record<string, pulumi.Output<string> | string>;
|
|
16
|
-
export interface BuildDropletServicesOptions {
|
|
17
|
-
/** Service configs with platform: 'droplet' */
|
|
18
|
-
serviceConfigs: ServiceConfig[];
|
|
19
|
-
/** DigitalOcean region (e.g., 'fra1') */
|
|
20
|
-
region: string;
|
|
21
|
-
/** VPC UUID for private networking */
|
|
22
|
-
vpcUuid: pulumi.Input<string>;
|
|
23
|
-
/** SSH key IDs for Droplet access (optional) */
|
|
24
|
-
sshKeyIds?: pulumi.Input<pulumi.Input<string>[]>;
|
|
25
|
-
/** Registry credentials for private images (optional) */
|
|
26
|
-
registryCredentials?: pulumi.Output<string>;
|
|
27
|
-
/** Service-specific environment variables (can include secrets) */
|
|
28
|
-
serviceEnvVars?: Record<string, SecretEnvVars>;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Builds Droplet resources for services with platform: 'droplet'.
|
|
32
|
-
*
|
|
33
|
-
* Creates:
|
|
34
|
-
* - Droplet with Docker and cloud-init script
|
|
35
|
-
* - Volume(s) for persistent storage (if configured)
|
|
36
|
-
* - Firewall rules for VPC access
|
|
37
|
-
*
|
|
38
|
-
* @returns Map of service name to created resources
|
|
39
|
-
*/
|
|
40
|
-
export declare function buildDropletServices(options: BuildDropletServicesOptions): Map<string, DropletServiceResources>;
|
|
41
|
-
/**
|
|
42
|
-
* Filters service configs by platform type.
|
|
43
|
-
*/
|
|
44
|
-
export declare function filterByPlatform(configs: ServiceConfig[], platform: 'app-platform' | 'droplet'): ServiceConfig[];
|
package/dist/helpers/image.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Output } from '@pulumi/pulumi';
|
|
2
|
-
/**
|
|
3
|
-
* Gets the full GHCR image URL for a service.
|
|
4
|
-
*
|
|
5
|
-
* @param registry - The GHCR registry/org name (e.g., 'orderboss')
|
|
6
|
-
* @param serviceName - The service name (e.g., 'storefront', 'api-gateway')
|
|
7
|
-
* @returns Full image URL (e.g., 'ghcr.io/orderboss/storefront:abc123')
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const config: K8sServiceConfig = {
|
|
12
|
-
* name: 'storefront',
|
|
13
|
-
* image: ghcrImage('orderboss', 'storefront'),
|
|
14
|
-
* }
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare const ghcrImage: (registry: string, serviceName: string) => string;
|
|
18
|
-
/**
|
|
19
|
-
* Gets the image configuration for a given repository.
|
|
20
|
-
* @param repository - The name of the repository.
|
|
21
|
-
* @returns The image configuration.
|
|
22
|
-
* @deprecated Use ghcrImage instead
|
|
23
|
-
*/
|
|
24
|
-
export declare const getImage: (registry: string, repository: string, registryCredentials: Output<string>) => {
|
|
25
|
-
registryType: any;
|
|
26
|
-
registry: string;
|
|
27
|
-
repository: string;
|
|
28
|
-
registryCredentials: Output<string>;
|
|
29
|
-
tag: string;
|
|
30
|
-
};
|