From ea8cae78151357bb4dd944fb0034c614621acf24 Mon Sep 17 00:00:00 2001 From: DrMxrcy Date: Wed, 20 Nov 2024 22:20:58 -0500 Subject: [PATCH 1/2] feat(add): Immich --- apps/dokploy/public/templates/immich.svg | 9 ++ .../templates/immich/docker-compose.yml | 107 ++++++++++++++++++ apps/dokploy/templates/immich/index.ts | 46 ++++++++ apps/dokploy/templates/templates.ts | 15 +++ 4 files changed, 177 insertions(+) create mode 100644 apps/dokploy/public/templates/immich.svg create mode 100644 apps/dokploy/templates/immich/docker-compose.yml create mode 100644 apps/dokploy/templates/immich/index.ts diff --git a/apps/dokploy/public/templates/immich.svg b/apps/dokploy/public/templates/immich.svg new file mode 100644 index 00000000..497fbdcf --- /dev/null +++ b/apps/dokploy/public/templates/immich.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/apps/dokploy/templates/immich/docker-compose.yml b/apps/dokploy/templates/immich/docker-compose.yml new file mode 100644 index 00000000..0c03e96f --- /dev/null +++ b/apps/dokploy/templates/immich/docker-compose.yml @@ -0,0 +1,107 @@ +version: "3.9" + +services: + immich-server: + image: ghcr.io/immich-app/immich-server:v1.121.0 + networks: + - dokploy-network + volumes: + - immich-library:/usr/src/app/upload + - /etc/localtime:/etc/localtime:ro + depends_on: + immich-redis: + condition: service_healthy + immich-database: + condition: service_healthy + environment: + PORT: 2283 + DB_HOSTNAME: immich-database + DB_PORT: 5432 + DB_USERNAME: ${POSTGRES_USER} + DB_PASSWORD: ${POSTGRES_PASSWORD} + DB_DATABASE_NAME: immich + REDIS_HOSTNAME: immich-redis + REDIS_PORT: 6379 + REDIS_DBINDEX: 0 + SERVER_URL: https://${IMMICH_HOST} + FRONT_BASE_URL: https://${IMMICH_HOST} + restart: always + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:2283/server-info/ping"] + interval: 30s + timeout: 10s + retries: 3 + + immich-machine-learning: + image: ghcr.io/immich-app/immich-machine-learning:v1.121.0 + networks: + - dokploy-network + volumes: + - immich-model-cache:/cache + environment: + REDIS_HOSTNAME: immich-redis + REDIS_PORT: 6379 + REDIS_DBINDEX: 0 + restart: always + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:3003/ping"] + interval: 30s + timeout: 10s + retries: 3 + + immich-redis: + image: redis:6.2-alpine + networks: + - dokploy-network + volumes: + - immich-redis-data:/data + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 5s + retries: 5 + restart: always + + immich-database: + image: tensorchord/pgvecto-rs:pg14-v0.2.0 + networks: + - dokploy-network + volumes: + - immich-postgres:/var/lib/postgresql/data + environment: + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_DB: immich + POSTGRES_INITDB_ARGS: '--data-checksums' + healthcheck: + test: pg_isready -U ${POSTGRES_USER} -d immich || exit 1 + interval: 10s + timeout: 5s + retries: 5 + command: + [ + 'postgres', + '-c', + 'shared_preload_libraries=vectors.so', + '-c', + 'search_path="$$user", public, vectors', + '-c', + 'logging_collector=on', + '-c', + 'max_wal_size=2GB', + '-c', + 'shared_buffers=512MB', + '-c', + 'wal_compression=on', + ] + restart: always + +networks: + dokploy-network: + external: true + +volumes: + immich-model-cache: + immich-postgres: + immich-library: + immich-redis-data: \ No newline at end of file diff --git a/apps/dokploy/templates/immich/index.ts b/apps/dokploy/templates/immich/index.ts new file mode 100644 index 00000000..b1b11afb --- /dev/null +++ b/apps/dokploy/templates/immich/index.ts @@ -0,0 +1,46 @@ +import { + type DomainSchema, + type Schema, + type Template, + generateBase64, + generatePassword, + generateRandomDomain, +} from "../utils"; + +export function generate(schema: Schema): Template { + const mainDomain = generateRandomDomain(schema); + const dbPassword = generatePassword(); + const dbUser = "immich"; + const appSecret = generateBase64(32); + + const domains: DomainSchema[] = [ + { + host: mainDomain, + port: 2283, + serviceName: "immich-server", + }, + ]; + + const envs = [ + `IMMICH_HOST=${mainDomain}`, + `SERVER_URL=https://${mainDomain}`, + `FRONT_BASE_URL=https://${mainDomain}`, + "# Database Configuration", + "DB_HOSTNAME=immich-database", + "DB_PORT=5432", + `DB_USERNAME=${dbUser}`, + `DB_PASSWORD=${dbPassword}`, + "DB_DATABASE_NAME=immich", + "# Redis Configuration", + "REDIS_HOSTNAME=immich-redis", + "REDIS_PORT=6379", + "REDIS_DBINDEX=0", + "# Server Configuration", + "TZ=UTC", + ]; + + return { + domains, + envs, + }; +} diff --git a/apps/dokploy/templates/templates.ts b/apps/dokploy/templates/templates.ts index 46806a8a..d9e37a4d 100644 --- a/apps/dokploy/templates/templates.ts +++ b/apps/dokploy/templates/templates.ts @@ -867,4 +867,19 @@ export const templates: TemplateData[] = [ tags: ["support", "chat", "customer-service"], load: () => import("./chatwoot/index").then((m) => m.generate), }, + { + id: "immich", + name: "Immich", + version: "v1.121.0", + description: + "High performance self-hosted photo and video backup solution directly from your mobile phone.", + logo: "immich.svg", + links: { + github: "https://github.com/immich-app/immich", + website: "https://immich.app/", + docs: "https://immich.app/docs/overview/introduction", + }, + tags: ["photos", "videos", "backup", "media"], + load: () => import("./immich/index").then((m) => m.generate), + }, ]; From fd59beaff1cfb7c74fe661a28910430b85ebb6a2 Mon Sep 17 00:00:00 2001 From: DrMxrcy Date: Thu, 21 Nov 2024 01:48:49 -0500 Subject: [PATCH 2/2] fix(add): ENV --- .../templates/immich/docker-compose.yml | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/apps/dokploy/templates/immich/docker-compose.yml b/apps/dokploy/templates/immich/docker-compose.yml index 0c03e96f..2a9fb00b 100644 --- a/apps/dokploy/templates/immich/docker-compose.yml +++ b/apps/dokploy/templates/immich/docker-compose.yml @@ -15,16 +15,20 @@ services: condition: service_healthy environment: PORT: 2283 - DB_HOSTNAME: immich-database - DB_PORT: 5432 - DB_USERNAME: ${POSTGRES_USER} - DB_PASSWORD: ${POSTGRES_PASSWORD} - DB_DATABASE_NAME: immich - REDIS_HOSTNAME: immich-redis - REDIS_PORT: 6379 - REDIS_DBINDEX: 0 - SERVER_URL: https://${IMMICH_HOST} - FRONT_BASE_URL: https://${IMMICH_HOST} + SERVER_URL: ${SERVER_URL} + FRONT_BASE_URL: ${FRONT_BASE_URL} + # Database Configuration + DB_HOSTNAME: ${DB_HOSTNAME} + DB_PORT: ${DB_PORT} + DB_USERNAME: ${DB_USERNAME} + DB_PASSWORD: ${DB_PASSWORD} + DB_DATABASE_NAME: ${DB_DATABASE_NAME} + # Redis Configuration + REDIS_HOSTNAME: ${REDIS_HOSTNAME} + REDIS_PORT: ${REDIS_PORT} + REDIS_DBINDEX: ${REDIS_DBINDEX} + # Server Configuration + TZ: ${TZ} restart: always healthcheck: test: ["CMD", "curl", "-f", "http://localhost:2283/server-info/ping"] @@ -39,9 +43,9 @@ services: volumes: - immich-model-cache:/cache environment: - REDIS_HOSTNAME: immich-redis - REDIS_PORT: 6379 - REDIS_DBINDEX: 0 + REDIS_HOSTNAME: ${REDIS_HOSTNAME} + REDIS_PORT: ${REDIS_PORT} + REDIS_DBINDEX: ${REDIS_DBINDEX} restart: always healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3003/ping"] @@ -69,12 +73,12 @@ services: volumes: - immich-postgres:/var/lib/postgresql/data environment: - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} - POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${DB_PASSWORD} + POSTGRES_USER: ${DB_USERNAME} POSTGRES_DB: immich POSTGRES_INITDB_ARGS: '--data-checksums' healthcheck: - test: pg_isready -U ${POSTGRES_USER} -d immich || exit 1 + test: pg_isready -U ${DB_USERNAME} -d immich || exit 1 interval: 10s timeout: 5s retries: 5