Skip to content

Commit

Permalink
Merge pull request #181 from anarion80/add_immich_tools
Browse files Browse the repository at this point in the history
✨ Add Immich Power Tools option
  • Loading branch information
anarion80 authored Aug 26, 2024
2 parents 8e1cf87 + 12cddc8 commit 8e4417b
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 16 deletions.
8 changes: 8 additions & 0 deletions roles/immich/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
---
immich_enabled: false
immich_available_externally: false
immich_install_power_tools: false

# directories
immich_data_directory: "{{ docker_home }}/immich"
immich_upload_directory: "{{ docker_home }}/immich/upload"

# network
immich_port: "2283"
immich_power_tools_port: "3035"
immich_hostname: "immich"
immich_power_tools_hostname: "immich-power-tools"
immich_network_name: "immich"

# specs
Expand All @@ -20,13 +23,15 @@ immich_microservices_memory: 1g
immich_machinelearning_memory: 1g
immich_web_memory: 1g
immich_proxy_memory: 1g
immich_power_tools_memory: 1g

# docker
immich_postgres_container_name: "immich_postgres"
immich_redis_container_name: "immich_redis"
immich_server_container_name: "immich_server"
immich_microservices_container_name: "immich_microservices"
immich_machinelearning_container_name: "immich_machine_learning"
immich_power_tools_container_name: "immich_power_tools"

immich_postgres_image: "tensorchord/pgvecto-rs"
immich_postgres_tag: "pg14-v0.2.0"
Expand All @@ -38,6 +43,8 @@ immich_microservices_image: "ghcr.io/immich-app/immich-server"
immich_microservices_tag: "{{ immich_version }}"
immich_machinelearning_image: "ghcr.io/immich-app/immich-machine-learning"
immich_machinelearning_tag: "{{ immich_version }}"
immich_power_tools_image: "ghcr.io/varun-raj/immich-power-tools"
immich_power_tools_tag: "latest"
immich_user_id: "1000"
immich_group_id: "1000"

Expand All @@ -54,3 +61,4 @@ immich_enable_mapbox: "false"
immich_mapbox_key: ""
immich_upload_location: "./library"
immich_public_login_page_message: "Welcome to Immich!"
immich_api_key: ""
15 changes: 0 additions & 15 deletions roles/immich/docs/immich.md

This file was deleted.

1 change: 1 addition & 0 deletions roles/immich/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ provisioner:
group_vars:
all:
immich_enabled: true
immich_install_power_tools: true
1 change: 1 addition & 0 deletions roles/immich/molecule/default/side_effect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars:
immich_enabled: false
immich_install_power_tools: false
7 changes: 7 additions & 0 deletions roles/immich/molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
name: "{{ immich_machinelearning_container_name }}"
register: result_machinelearning

- name: Get Immich Power Tools container state
community.docker.docker_container_info:
name: "{{ immich_power_tools_container_name }}"
register: result_powertools

- name: Check if Immich docker containers are running
ansible.builtin.assert:
that:
Expand All @@ -45,3 +50,5 @@
- result_microservices.container['State']['Restarting'] == false
- result_machinelearning.container['State']['Status'] == "running"
- result_machinelearning.container['State']['Restarting'] == false
- result_powertools.container['State']['Status'] == "running"
- result_powertools.container['State']['Restarting'] == false
7 changes: 7 additions & 0 deletions roles/immich/molecule/default/verify_stopped.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
state: absent
register: result_machinelearning

- name: Try and stop and remove Immich Power Tools
community.docker.docker_container:
name: "{{ immich_power_tools_container_name }}"
state: absent
register: result_powertools

- name: Check if immich containers are stopped
ansible.builtin.assert:
that:
Expand All @@ -45,3 +51,4 @@
- not result_server.changed
- not result_microservices.changed
- not result_machinelearning.changed
- not result_powertools.changed
40 changes: 40 additions & 0 deletions roles/immich/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,38 @@
traefik.enable: "false"
restart_policy: unless-stopped
memory: "{{ immich_machinelearning_memory }}"

- name: Install Immich Power Tools
block:
- name: Immich Power Tools
community.docker.docker_container:
name: "{{ immich_power_tools_container_name }}"
image: "{{ immich_power_tools_image }}:{{ immich_power_tools_tag }}"
pull: true
networks:
- name: "{{ immich_network_name }}"
network_mode: "{{ immich_network_name }}"
container_default_behavior: no_defaults
restart_policy: always
memory: "{{ immich_power_tools_memory }}"
ports:
- "{{ immich_power_tools_port }}:3000"
env:
IMMICH_URL: "https://{{ immich_hostname }}.{{ ansible_nas_domain }}"
IMMICH_API_KEY: "{{ immich_api_key }}"
DB_USERNAME: "{{ immich_db_username }}"
DB_PASSWORD: "{{ immich_db_password }}"
DB_HOST: "{{ immich_postgres_container_name }}"
DB_PORT: "{{ immich_db_port }}"
DB_DATABASE_NAME: "{{ immich_db_name }}"
labels:
traefik.enable: "{{ immich_available_externally | string }}"
traefik.http.routers.immich_power_tools.rule: "Host(`{{ immich_power_tools_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.immich_power_tools.tls.certresolver: "letsencrypt"
traefik.http.routers.immich_power_tools.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.immich_power_tools.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.immich_power_tools.loadbalancer.server.port: "3000"
when: immich_install_power_tools is true
when: immich_enabled is true

- name: Stop Immich
Expand Down Expand Up @@ -201,4 +233,12 @@
community.docker.docker_network:
name: "{{ immich_network_name }}"
state: absent

- name: Stop Immich Power Tools
block:
- name: Stop Immich Power Tools
community.docker.docker_container:
name: "{{ immich_power_tools_container_name }}"
state: absent
when: immich_install_power_tools is false
when: immich_enabled is false
8 changes: 7 additions & 1 deletion website/docs/applications/other/immich.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ Set `immich_enabled: true` in your `inventories/<your_inventory>/group_vars/nas.

Set all `immich_*` variables in `inventories/<your_inventory>/group_vars/all.yml`.

The immich web interface can be found at [http://ansible_nas_host_or_ip:2283](http://ansible_nas_host_or_ip:2283).
The Immich web interface can be found at [http://ansible_nas_host_or_ip:2283](http://ansible_nas_host_or_ip:2283).

Refer to [https://immich.app/docs/install/post-install](https://immich.app/docs/install/post-install) for post-install steps (Registering Admin User, adding users, etc.).

Optionally, you can install[Immich Power Tools](https://github.com/varun-raj/immich-power-tools).

Set `immich_install_power_tools: true` and `immich_api_key` in your `inventories/<your_inventory>/group_vars/nas.yml` file and run the playbook again.

The Immich Power Tools web interface can then be found at [http://ansible_nas_host_or_ip:3035](http://ansible_nas_host_or_ip:3035).

## Specific Configuration

Please note the need for a CPU with AVX and AVX2 instruction set to run the Machine Learning container. Check [here](https://github.com/immich-app/immich/tree/c436c57cc9a2a23ae1fbd3ea52eeb947f32261cd#tensorflow-build-issue) for details.

0 comments on commit 8e4417b

Please sign in to comment.