Skip to content

feat(ml): Offer environment variables to set the listener host and port#24304

Closed
dionysius wants to merge 1 commit intoimmich-app:mainfrom
dionysius:machinelearningbindenvvariables
Closed

feat(ml): Offer environment variables to set the listener host and port#24304
dionysius wants to merge 1 commit intoimmich-app:mainfrom
dionysius:machinelearningbindenvvariables

Conversation

@dionysius
Copy link
Copy Markdown
Contributor

@dionysius dionysius commented Nov 30, 2025

Description

The machine-learning server listens hard coded on 0.0.0.0 and port 3003. There are currently no options to define listener host or port. I propose to introduce environment variables MACHINE_LEARNING_HOST and MACHINE_LEARNING_PORT to offer such configuration. If those variables are not set, the previously existing default apply.

The environment variable names were chosen for consistency. All/Most ML specific environment variable start with MACHINE_LEARNING_, all/most main server specifics start with IMMICH_

This is useful for packaged builds and especially for installations on the same machine, where the machine-learning server can be set to localhost.

Any server should have a configuration to set the listener address.

No documentation has been modified as there is no mention needed for the official docker compose build (defaults stay the same). There are also other environment variables not documented which are also not relevant for the docker compose build.

There could be a documentation section for a complete list of available environment variables focused per service, but this is out of the scope for this PR.

I'm currently using this exact change as a patch in my downstream packaging.

Fixes no reported issue

How Has This Been Tested?

  • manually by setting and not setting the environment variables

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • I have confirmed that any new dependencies are strictly necessary.
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code
  • All code in src/services/ uses repositories implementations for database calls, filesystem operations, etc.
  • All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services/)

Please describe to which degree, if any, an LLM was used in creating this pull request.

I've used an LLM to suggest me the change as a shortcut since I'm not familiar with python. I've verified the changes manually.

@dionysius dionysius requested a review from mertalev as a code owner November 30, 2025 21:45
@immich-push-o-matic
Copy link
Copy Markdown

immich-push-o-matic bot commented Nov 30, 2025

Label error. Requires exactly 1 of: changelog:.*. Found: 🧠machine-learning. A maintainer will add the required label.

@mertalev
Copy link
Copy Markdown
Member

It is configurable, but the variable names are not prefixed with MACHINE_LEARNING_ like the others. You change them with IMMICH_HOST and IMMICH_PORT.

@mmomjian
Copy link
Copy Markdown
Collaborator

We already support this: https://docs.immich.app/install/environment-variables#ports

a PR to add a column to the documentation for “server, machine learning” would probably be good.

dionysius added a commit to dionysius/immich-deb that referenced this pull request Nov 30, 2025
@dionysius
Copy link
Copy Markdown
Contributor Author

I could look for a doc update and another column would make it quick and consistent.

But this leads to following questions:

What to do with the other undocumented environment variables? To name a few, but it's hard for me to compile them all since there's magic conversion...

  • IMMICH_BUILD_DATA
  • MACHINE_LEARNING_MAX_BATCH_SIZE__TEXT_RECOGNITION
  • IMMICH_PLUGINS_ENABLED (alpha)
  • IMMICH_PLUGINS_INSTALL_FOLDER (alpha)
  • IMMICH_MACHINE_LEARNING_ENABLED (which also get obsolete once settings in the UI are saved)
  • IMMICH_MACHINE_LEARNING_URL (dito)
  • MACHINE_LEARNING_PRELOAD__OCR__RECOGNITION (can't say)
  • MACHINE_LEARNING_PRELOAD__OCR__DETECTION (dito)
  • all those IMMICH_BUILD_, IMMICH_REPOSITORY_, IMMICH_SOURCE_* and IMMICH_THIRD_PARTY_* (some are shown in the about page in the web ui)

The IMMICH_BUILD_DATA and IMMICH_MACHINE_LEARNING_* were actually the most important in my case.

so basically the question is whether https://docs.immich.app/install/environment-variables should list all (I assume non-test and "production-ready") environment variables? Above list could be a baseline for a new issue (I can make if I get a quick agree or something)

@mmomjian
Copy link
Copy Markdown
Collaborator

mmomjian commented Dec 1, 2025

I dont think all of those need to be added. Host and port is fine. We don’t usually open issues for docs clarifications, you can just PR it if you’d like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants