commit 942e7a04f57faf2df4a1113201154cc83c495748 Author: Hamcha Date: Sun Apr 7 17:40:32 2024 +0200 check in! diff --git a/README.md b/README.md new file mode 100644 index 0000000..3850914 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# containerlib + +AWS CDK but for normal people. Don't worry about scaling and AWS bills, just rent a VPS and run my randomly-named services on it! I'm no Jia Tan but a man can dream. + +Also this is only going to be tested with Deno. You deserve better than node. + +## World domination plan + +Current status: v0 - It doesn't work!! + +### v1: docker-compose + +Initially, containerlib will return docker-compose.yml files. This allows quick implementation and moving from existing Portainer setups to staxman. + +### v2: rewrite internally + +Post-MVP, containerlib will return an intermediary state representation (akin to Kubernetes manifests) that serverman can use to control OCI containers via docker API. This is basically integrating the docker-compose functionality directly within serverman. diff --git a/example/immich.ts b/example/immich.ts new file mode 100644 index 0000000..e8a2725 --- /dev/null +++ b/example/immich.ts @@ -0,0 +1,59 @@ +/** + * Using the docker-compose.yml template from Immich repository as base (with some edits): + * https://raw.githubusercontent.com/immich-app/immich/main/docker/docker-compose.yml + */ + +export interface ImmichStackOptions { + immichVersion: string; + + postgres: { + password: string; + username: string; + database: string; + }; +} + +export function immichStack(props: ImmichStackOptions) { + const redis = new Service("redis", { + image: "registry.hub.docker.com/library/redis:6.2-alpine", + restart: "unless-stopped", + }); + + // Create default credentials if not provided + props.postgres.username ??= "postgres"; + props.postgres.password ??= "postgres"; + props.postgres.database ??= "postgres"; + + const database = new Service("database", { + image: "registry.hub.docker.com/tensorchord/pgvecto-rs:pg14-v0.2.0", + restart: "unless-stopped", + environment: { + POSTGRES_USER: props.postgres.username, + POSTGRES_PASSWORD: props.postgres.password, + POSTGRES_DB: props.postgres.database, + }, + // todo volumes + }); + + const immichServer = new Service("immich-server", { + image: `ghcr.io/immich-app/immich-server:${ + props.immichVersion ?? "release" + }`, + restart: "unless-stopped", + command: ["start.sh", "immich"], + dependsOn: [database, redis], + // todo volumes + environment: { + DB_HOSTNAME: database.name, + DB_USERNAME: props.postgres.username, + DB_PASSWORD: props.postgres.password, + DB_DATABASE_NAME: props.postgres.database, + REDIS_HOSTNAME: redis.name, + }, + ports: ["2283:3001"], + }); + + return new Stack("immich", { + services: [redis, database, immichServer], + }); +} diff --git a/mod.ts b/mod.ts new file mode 100644 index 0000000..e69de29