@dmgnr/kuber 1.0.0 → 1.1.0
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 +67 -0
- package/dist/index.js +95 -95
- package/package.json +14 -11
- package/schema/docker.d.ts +2595 -0
- package/types.d.ts +72 -0
package/README.md
CHANGED
|
@@ -37,6 +37,10 @@ Not required locally:
|
|
|
37
37
|
|
|
38
38
|
Docker is not required because builds happen on the remote builder after `kuber` syncs your repo state there. `kubectl` is not required because cluster access is handled through the bundled Kubernetes client.
|
|
39
39
|
|
|
40
|
+
## Next.js Example
|
|
41
|
+
|
|
42
|
+
[`example/`](example/) contains a documented deployment template for adding kuber to an existing Bun-powered Next.js project without initializing or bundling an application in this repository. It includes a standalone-output Dockerfile, `.dockerignore`, `compose.yml`, and the required Next.js configuration.
|
|
43
|
+
|
|
40
44
|
## Running
|
|
41
45
|
|
|
42
46
|
During development:
|
|
@@ -65,6 +69,14 @@ bun run index.ts restart
|
|
|
65
69
|
bun run index.ts db ls
|
|
66
70
|
```
|
|
67
71
|
|
|
72
|
+
All commands accept `--config` to use a configuration file other than
|
|
73
|
+
`.kuberrc.ts`:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
kuber --config deploy/production.kuberrc.ts up
|
|
77
|
+
kuber up --config deploy/production.kuberrc.ts
|
|
78
|
+
```
|
|
79
|
+
|
|
68
80
|
### Shell Completion
|
|
69
81
|
|
|
70
82
|
Generate and load completions for your shell:
|
|
@@ -91,6 +103,61 @@ For a permanent setup, write the generated script to a file and source it from y
|
|
|
91
103
|
- `db ls`: list managed Postgres claims declared in the current Compose file
|
|
92
104
|
- `db creds <service>`: print the generated connection details for a managed Postgres claim
|
|
93
105
|
|
|
106
|
+
## Configuration
|
|
107
|
+
|
|
108
|
+
Kuber optionally loads `.kuberrc.ts` from the working directory. The file must
|
|
109
|
+
default export an object satisfying the published `KuberConfig` type:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import type { KuberConfig } from "@dmgnr/kuber";
|
|
113
|
+
|
|
114
|
+
export default {
|
|
115
|
+
project: "my-app",
|
|
116
|
+
composeFile: "compose.production.yml",
|
|
117
|
+
registry: "registry.example.com",
|
|
118
|
+
builders: {
|
|
119
|
+
amd64: "kuber@amd-builder",
|
|
120
|
+
arm64: "kuber@arm-builder",
|
|
121
|
+
remoteRoot: "kuber-build",
|
|
122
|
+
},
|
|
123
|
+
rolloutTimeoutMs: 10 * 60_000,
|
|
124
|
+
|
|
125
|
+
async compose(compose) {
|
|
126
|
+
const app = compose.services?.app;
|
|
127
|
+
if (app && !Array.isArray(app.environment)) {
|
|
128
|
+
app.environment ??= {};
|
|
129
|
+
app.environment.NEXT_PUBLIC_BUILD_ID =
|
|
130
|
+
await Bun.$`git rev-parse --short HEAD`
|
|
131
|
+
.text()
|
|
132
|
+
.then((value) => value.trim());
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
} satisfies KuberConfig;
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Operational defaults:
|
|
139
|
+
|
|
140
|
+
- `project`: current working directory name
|
|
141
|
+
- `composeFile`: the first recognized Compose filename in the working directory
|
|
142
|
+
- `registry`: `registry.neko-piranha.ts.net`
|
|
143
|
+
- `builders.amd64`: `kuber@astral-th`
|
|
144
|
+
- `builders.arm64`: `kuber@astral`
|
|
145
|
+
- `builders.remoteRoot`: `kuber-build`
|
|
146
|
+
- `rolloutTimeoutMs`: `300000`
|
|
147
|
+
|
|
148
|
+
Configuration hooks can be synchronous or asynchronous and receive mutable
|
|
149
|
+
values:
|
|
150
|
+
|
|
151
|
+
- `compose(compose, context)`: once after parsing and validation; affects every command that reads Compose
|
|
152
|
+
- `preBuild(compose, context)`: before build eligibility is evaluated when builds are enabled
|
|
153
|
+
- `postBuild(result, context)`: after images are built; `result` contains `built` and `changed` service names
|
|
154
|
+
- `postRender(resources, context)`: after rendering and before reconciliation planning; also runs for `export`
|
|
155
|
+
- `postApply(resources, context)`: after desired resources are successfully applied
|
|
156
|
+
|
|
157
|
+
Hook context contains the resolved `cwd`, `project`, `composeFile`, and optional
|
|
158
|
+
`configFile`. A hook error aborts the command and is reported by the normal CLI
|
|
159
|
+
error handler.
|
|
160
|
+
|
|
94
161
|
## Compose Conventions
|
|
95
162
|
|
|
96
163
|
`kuber` supports a few project-specific Compose conventions on top of normal service translation.
|