60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
|
/**
|
||
|
* 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],
|
||
|
});
|
||
|
}
|