From c57f6720d2ff76e69e4631e59c0b4cb18fea5e54 Mon Sep 17 00:00:00 2001 From: Anton Shubin <2spy4x@gmail.com> Date: Sun, 28 Jan 2024 14:26:01 +0800 Subject: [PATCH] feat: add Immich - Google Photo self-hosted alternative --- .env.example | 8 ++- Makefile | 23 +++++++- README.md | 5 +- compose.yml | 77 ++++---------------------- deploy.files.txt | 3 +- homepage/src/index.html | 52 +++++++++--------- immich/.env.example | 19 +++++++ immich/compose.yml | 119 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 207 insertions(+), 99 deletions(-) create mode 100644 immich/.env.example create mode 100644 immich/compose.yml diff --git a/.env.example b/.env.example index 96fcf80..84fea4e 100644 --- a/.env.example +++ b/.env.example @@ -1,12 +1,16 @@ CONTACT_EMAIL=your@email.com +TIMEZONE=Europe/Berlin SSH_TO_SERVER=user@server PATH_APPS=~/apps -PATH_MOVIES=~/movies +PATH_MEDIA=~/media +PATH_MOVIES=~/media/movies +PATH_SERIES=~/media/series +PATH_PHOTOS=~/media/photos HOSTNAME_UPTIME_KUMA=uptime.example.com HOSTNAME_TORRENTS=torrents.example.com HOSTNAME_MOVIES=movies.example.com +HOSTNAME_PHOTOS=photos.example.com HOSTNAME_GITEA=git.example.com -HOSTNAME_HOME_ASSISTANT=smart.example.com HOSTNAME_HOMEPAGE=ui.example.com HOSTNAME_SAGE=sage.example.com HOSTNAME_AQS=example.com \ No newline at end of file diff --git a/Makefile b/Makefile index 5873f77..e5fe535 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +.PHONY: * -include .env export $(shell sed 's/=.*//' .env) @@ -6,7 +7,25 @@ build-homepage: mkdir -p ./homepage/dist envsubst < ./homepage/src/index.html > ./homepage/dist/index.html +# Copy files to server +copy-files: + rsync -avhzru -P -e ssh --include-from='deploy.files.txt' --exclude '*' ./ $(SSH_TO_SERVER):$(PATH_APPS) + +# Create proxy network (so reverse proxy can access other containers), if it doesn't exist yet +create-proxy-network: + ssh homelab "docker network create proxy 2>/dev/null || true" + +# Deploy main homelab services +up-homelab: + ssh homelab "cd $(PATH_APPS) && docker compose up -d" + +# Deploy Immich +up-immich: + ssh homelab "cd $(PATH_APPS)/immich && docker compose --env-file=.env --env-file=../.env up -d" + deploy: make build-homepage - rsync -avz -e 'ssh' --include-from='deploy.files.txt' --exclude '*' ./ $(SSH_TO_SERVER):$(PATH_APPS) - ssh homelab "cd $(PATH_APPS) && docker compose up -d" \ No newline at end of file + make copy-files + make create-proxy-network + make up-homelab + make up-immich diff --git a/README.md b/README.md index c87e3a5..23b4e82 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,8 @@ Think of movies, TV shows, home videos, music, and pictures. ### [Gitea](https://github.com/go-gitea/gitea) Gitea is a lightweight self-hosted Git service, similar to GitHub. -### [Home Assistant](https://github.com/home-assistant/home-assistant.io) -Home Assistant is an open-source home automation platform. -For your smart home, it is the software "hub" that allows you to control all your devices. +### [Immich](https://immich.app/) +Google Photos self-hosted alternative. ### [Homepage](./homepage/src/index.html) A simple homepage with links to all the services. diff --git a/compose.yml b/compose.yml index 4ded5cd..a10f681 100644 --- a/compose.yml +++ b/compose.yml @@ -1,4 +1,9 @@ version: '3.8' +# +networks: + proxy: + external: true + services: # Traefik is a reverse proxy and load balancer. @@ -27,10 +32,13 @@ services: ports: - "443:443" - "80:80" -# - "8080:8080" + - "8080:8080" volumes: - "./letsencrypt:/letsencrypt" - "/var/run/docker.sock:/var/run/docker.sock:ro" + networks: + - proxy + - default deploy: resources: limits: @@ -44,12 +52,6 @@ services: volumes: - ./.volumes/uptime-kuma:/app/data restart: unless-stopped - healthcheck: - test: [ "CMD", "curl", "-f", "${HOSTNAME_UPTIME_KUMA}" ] - interval: 1m - timeout: 10s - retries: 3 - start_period: 40s deploy: resources: limits: @@ -73,20 +75,14 @@ services: environment: - PUID=1000 - PGID=1000 - - TZ=Asia/Singapore + - TZ=${TIMEZONE} volumes: - ./.volumes/transmission:/config - - ${PATH_MOVIES}:/downloads + - ${PATH_MEDIA}:/downloads ports: - 51413:51413 # Default port for torrent traffic - 51413:51413/udp # Default port for DHT restart: unless-stopped - healthcheck: - test: [ "CMD", "curl", "-f", "${HOSTNAME_TORRENTS}" ] - interval: 1m - timeout: 10s - retries: 3 - start_period: 40s deploy: resources: limits: @@ -110,14 +106,8 @@ services: volumes: - ./.volumes/jellyfin:/config - ./.volumes/jellyfin/cache:/cache - - ${PATH_MOVIES}:/media + - ${PATH_MEDIA}:/media restart: unless-stopped - healthcheck: - test: [ "CMD", "curl", "-f", "${HOSTNAME_MOVIES}" ] - interval: 1m - timeout: 10s - retries: 3 - start_period: 40s deploy: resources: limits: @@ -147,12 +137,6 @@ services: - USER_UID=1000 - USER_GID=1000 restart: unless-stopped - healthcheck: - test: [ "CMD", "curl", "-f", "${HOSTNAME_GITEA}" ] - interval: 1m - timeout: 10s - retries: 3 - start_period: 40s deploy: resources: limits: @@ -168,37 +152,6 @@ services: - "traefik.http.routers.gitea.tls.certresolver=myresolver" - "traefik.http.services.gitea.loadbalancer.server.port=3000" - # Home Assistant is an open-source home automation platform. - # For your smart home, it is the software "hub" that allows you to control all your devices. - home-assistant: - container_name: home-assistant - image: homeassistant/home-assistant:stable - volumes: - - ./.volumes/home-assistant:/config - environment: - - TZ=Asia/Singapore - restart: unless-stopped - healthcheck: - test: [ "CMD", "curl", "-f", "${HOSTNAME_HOME_ASSISTANT}" ] - interval: 1m - timeout: 10s - retries: 3 - start_period: 40s - deploy: - resources: - limits: - memory: 512M - cpus: '0.25' - security_opt: - - no-new-privileges:true - labels: - - "traefik.enable=true" - - "traefik.http.routers.home-assistant.rule=Host(`${HOSTNAME_HOME_ASSISTANT}`)" - - "traefik.http.routers.home-assistant.entrypoints=websecure" - - "traefik.http.routers.home-assistant.tls=true" - - "traefik.http.routers.home-assistant.tls.certresolver=myresolver" - - "traefik.http.services.home-assistant.loadbalancer.server.port=8123" - # A simple HTML page to display links to all the services. homepage: container_name: homepage @@ -206,12 +159,6 @@ services: volumes: - ./homepage/dist:/usr/share/nginx/html:ro restart: unless-stopped - healthcheck: - test: [ "CMD", "curl", "-f", "${HOSTNAME_HOMEPAGE}" ] - interval: 1m - timeout: 10s - retries: 3 - start_period: 40s deploy: resources: limits: diff --git a/deploy.files.txt b/deploy.files.txt index 0820acc..c2093ce 100644 --- a/deploy.files.txt +++ b/deploy.files.txt @@ -1,3 +1,4 @@ compose.yml -homepage/dist/*** +homepage/*** +immich/*** .env \ No newline at end of file diff --git a/homepage/src/index.html b/homepage/src/index.html index 029cb94..1e1ec6d 100644 --- a/homepage/src/index.html +++ b/homepage/src/index.html @@ -46,7 +46,7 @@ background-color: #2979ff; } -