Compare commits
4 commits
f66e46850f
...
b1fe38da5a
Author | SHA1 | Date | |
---|---|---|---|
b1fe38da5a | |||
f8fe23cecd | |||
494b6b5331 | |||
df8d5a58c0 |
8 changed files with 104 additions and 4 deletions
23
.forgejo/workflows/publish.yaml
Normal file
23
.forgejo/workflows/publish.yaml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
name: Build and push Docker image
|
||||||
|
|
||||||
|
# Only on new tags
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "*.*.*"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Update jsr.json
|
||||||
|
run: sed -i "s/x.x.x/${{ github.ref_name }}/g" jsr.json
|
||||||
|
- uses: denoland/setup-deno@v1
|
||||||
|
with:
|
||||||
|
deno-version: v1.x
|
||||||
|
- run: deno publish
|
7
LICENSE.txt
Normal file
7
LICENSE.txt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
ISC License
|
||||||
|
|
||||||
|
Copyright 2024 staxman authors
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
30
README.md
30
README.md
|
@ -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!
|
||||||
|
|
9
jsr.json
Normal file
9
jsr.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://jsr.io/schema/config-file.v1.json",
|
||||||
|
"name": "@staxman/containerlib",
|
||||||
|
"version": "x.x.x",
|
||||||
|
"exports": "./mod.ts",
|
||||||
|
"publish": {
|
||||||
|
"exclude": [".forgejo"]
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
import { DefinitionsNetwork } from "../compose-schema";
|
import { DefinitionsNetwork } from "../compose-schema.ts";
|
||||||
|
|
||||||
export class Network {
|
export class Network {
|
||||||
constructor(
|
constructor(
|
||||||
|
|
|
@ -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> = {};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { DefinitionsVolume } from "../compose-schema";
|
import { DefinitionsVolume } from "../compose-schema.ts";
|
||||||
|
|
||||||
export class Volume {
|
export class Volume {
|
||||||
constructor(
|
constructor(
|
||||||
|
|
|
@ -7,10 +7,17 @@ export function registerDeployment(stack: Stack) {
|
||||||
deployments.push(stack);
|
deployments.push(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
globalThis.addEventListener("unload", () => {
|
export function getStacks(): Record<string, ComposeSpecification> {
|
||||||
const stacks: Record<string, ComposeSpecification> = {};
|
const stacks: Record<string, ComposeSpecification> = {};
|
||||||
for (const stack of deployments) {
|
for (const stack of deployments) {
|
||||||
stacks[stack.name] = stack.toComposeFile();
|
stacks[stack.name] = stack.toComposeFile();
|
||||||
}
|
}
|
||||||
console.log(JSON.stringify(stacks, null, 2));
|
return stacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
globalThis.addEventListener("unload", () => {
|
||||||
|
if (deployments.length > 0) {
|
||||||
|
// Print stacks
|
||||||
|
console.log(JSON.stringify(getStacks(), null, 2));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue