docs: add docs!

This commit is contained in:
Hamcha 2024-04-07 22:45:51 +02:00
parent df8d5a58c0
commit 494b6b5331
Signed by: hamcha
GPG key ID: 1669C533B8CF6D89
2 changed files with 54 additions and 0 deletions

View file

@ -4,6 +4,36 @@ AWS CDK but for normal people. Don't worry about scaling and AWS bills, just ren
Also this is only going to be tested with Deno. You deserve better than node. Also this is only going to be tested with Deno. You deserve better than node.
## Usage
Use with [staxman](https://git.fromouter.space/staxman) (WIP).
Usage example (v0):
```ts
import { Stack } from "../mod.ts";
interface RedisStackOptions {
stackName?: string;
redisVersion?: string;
}
export class RedisStack extends Stack {
constructor(props: ImmichStackOptions) {
super(props.stackName ?? "immich");
const redis = this.addService("redis", {
image: `registry.hub.docker.com/library/redis:${props.redisVersion ?? "alpine"}`,
restart: "unless-stopped"
});
}
}
const stack = new RedisStack({ redisVersion: "6.2-alpine" });
```
For a more in-depth example, see the example stacks in `example/`.
## World domination plan ## World domination plan
Current status: v0 - Annoyingly, this already kinda works! Current status: v0 - Annoyingly, this already kinda works!

View file

@ -17,6 +17,30 @@ function mapRecordToCompose<T, F extends { toCompose(): T }>(
); );
} }
/**
* Stack is a collection of services, networks, and volumes.
* Every stack gets turned into a compose file at the end of the execution.
* To create a stack, define a new class that extends Stack, then
* instantiate the class with the name of the stack.
*
* Example:
* ```ts
* import { Stack } from "../mod.ts";
*
* class ExampleStack extends Stack {
* constructor(name: string) {
* super(name);
*
* const redis = this.addService("redis", {
* image: "registry.hub.docker.com/library/redis:6.2-alpine",
* restart: "unless-stopped",
* });
* }
* }
*
* const stack = new ExampleStack("example");
* ```
*/
export class Stack { export class Stack {
private services: Record<string, Service> = {}; private services: Record<string, Service> = {};
private networks: Record<string, Network> = {}; private networks: Record<string, Network> = {};