87 lines
2.3 KiB
TypeScript
87 lines
2.3 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 immichEnv = {
|
|
DB_HOSTNAME: database.name,
|
|
DB_USERNAME: props.postgres.username,
|
|
DB_PASSWORD: props.postgres.password,
|
|
DB_DATABASE_NAME: props.postgres.database,
|
|
REDIS_HOSTNAME: redis.name,
|
|
};
|
|
|
|
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: immichEnv,
|
|
ports: ["2283:3001"],
|
|
});
|
|
|
|
const immichMicroservices = new Service("immich-microservices", {
|
|
image: `ghcr.io/immich-app/immich-server:${
|
|
props.immichVersion ?? "release"
|
|
}`,
|
|
restart: "unless-stopped",
|
|
command: ["start.sh", "microservices"],
|
|
dependsOn: [database, redis],
|
|
// todo volumes
|
|
environment: immichEnv,
|
|
});
|
|
|
|
const immichMachineLearning = new Service("immich-machine-learning", {
|
|
image: `ghcr.io/immich-app/immich-machine-learning:${
|
|
props.immichVersion ?? "release"
|
|
}`,
|
|
// todo volumes
|
|
environment: immichEnv,
|
|
});
|
|
|
|
return new Stack("immich", {
|
|
services: [
|
|
redis,
|
|
database,
|
|
immichServer,
|
|
immichMicroservices,
|
|
immichMachineLearning,
|
|
],
|
|
});
|
|
}
|