#!/usr/bin/with-contenv bash
# shellcheck shell=bash

# map disable variables to immich variables
[[ "${DISABLE_MACHINE_LEARNING}" == "true" ]] && export IMMICH_MACHINE_LEARNING_ENABLED=false

export IMMICH_WORKERS_INCLUDE="api"
export IMMICH_HOST="${SERVER_HOST:-"0.0.0.0"}"
export IMMICH_PORT="${SERVER_PORT:-"8080"}"
export LD_PRELOAD="/usr/lib/$(arch)-linux-gnu/libmimalloc.so.3"

exec \
    s6-notifyoncheck -d -n 300 -w 5000 -c "nc -z ${IMMICH_HOST} ${IMMICH_PORT}" \
        cd /app/immich/server s6-setuidgid abc \
            node dist/main
