diff --git a/infra/photos/0003_immich_playbook.yaml b/infra/photos/0003_immich_playbook.yaml index f3fd4ac..2d15877 100644 --- a/infra/photos/0003_immich_playbook.yaml +++ b/infra/photos/0003_immich_playbook.yaml @@ -7,21 +7,22 @@ - name: Wait for connection ansible.builtin.wait_for_connection: timeout: 300 - - name: Get user - ansible.builtin.user: - name: debian - register: user + - name: Check if project exists + ansible.builtin.stat: + path: "$HOME/{{ app }}" + register: project - name: Docker compose down - ansible.builtin.command: docker compose down - args: - chdir: "{{ user.home }}/{{ app }}" - ignore_errors: true + when: project.stat.exists + community.docker.docker_compose_v2: + project_src: "$HOME/{{ app }}" + state: absent - name: Copy project ansible.builtin.copy: src: "./{{ app }}" - dest: "{{ user.home }}" + dest: "$HOME" mode: "0744" + - name: Replace Typesense secret ansible.builtin.replace: path: "{{ user.home }}/{{ app }}/.env" @@ -36,11 +37,8 @@ replace: "{{ lookup('infisical.vault.read_secrets', project_id=infisical_project, env_slug='prod', path='/photos', secret_name='DB_PASSWORD')['value'] }}" - - name: Docker compose pull - ansible.builtin.command: docker compose pull - args: - chdir: "{{ user.home }}/{{ app }}" - - name: Docker compose up -d - ansible.builtin.command: docker compose up -d - args: - chdir: "{{ user.home }}/{{ app }}" + + - name: Docker compose up + community.docker.docker_compose_v2: + pull: always + project_src: "$HOME/{{ app }}" diff --git a/infra/photos/immich/.env b/infra/photos/immich/.env index e7c8557..08f09de 100644 --- a/infra/photos/immich/.env +++ b/infra/photos/immich/.env @@ -4,7 +4,7 @@ UPLOAD_LOCATION=/mnt/media/immich # The Immich version to use. You can pin this to a specific version like "v1.71.0" -IMMICH_VERSION=release +IMMICH_VERSION=v1.118.2 # Connection secrets for postgres and typesense. You should change these to random passwords TYPESENSE_API_KEY=TYPESENSE_API_KEY_VALUE diff --git a/infra/photos/immich/docker-compose.yml b/infra/photos/immich/docker-compose.yml index f36ad43..b623532 100644 --- a/infra/photos/immich/docker-compose.yml +++ b/infra/photos/immich/docker-compose.yml @@ -3,14 +3,14 @@ version: "3.8" services: immich-server: container_name: immich_server - image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release} + image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION} volumes: - ${UPLOAD_LOCATION}:/usr/src/app/upload - /etc/localtime:/etc/localtime:ro env_file: - .env ports: - - 2283:3001 + - 2283:2283 depends_on: - redis - database @@ -18,7 +18,7 @@ services: immich-machine-learning: container_name: immich_machine_learning - image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release} + image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION} volumes: - model-cache:/cache env_file: @@ -27,7 +27,9 @@ services: redis: container_name: immich_redis - image: redis:6.2-alpine@sha256:70a7a5b641117670beae0d80658430853896b5ef269ccf00d1827427e3263fa3 + image: redis:6.2-alpine@sha256:2ba50e1ac3a0ea17b736ce9db2b0a9f6f8b85d4c27d5f5accc6a416d8f42c6d5 + healthcheck: + test: redis-cli ping || exit 1 restart: always database: @@ -41,6 +43,27 @@ services: POSTGRES_DB: ${DB_DATABASE_NAME} volumes: - pgdata:/var/lib/postgresql/data + healthcheck: + test: pg_isready --dbname='${DB_DATABASE_NAME}' --username='${DB_USERNAME}' || exit 1; Chksum="$$(psql --dbname='${DB_DATABASE_NAME}' --username='${DB_USERNAME}' --tuples-only --no-align --command='SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database')"; echo "checksum failure count is $$Chksum"; [ "$$Chksum" = '0' ] || exit 1 + interval: 5m + start_interval: 30s + start_period: 5m + 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 volumes: