Aller au contenu
openplate

Comment faire tourner openplate

Tu peux utiliser openplate sans rien faire tourner du tout, comme tu peux tout héberger toi-même. Quatre échelons séparent ces deux cas. Chaque échelon apporte une fonction de plus et un composant de plus à gérer, vois donc cela comme une échelle où tu as tout intérêt à t'arrêter tôt.

  1. Échelon 0Utiliser une instance gérée par un tiersRien à exécuter
  2. Échelon 1Faire tourner l'application sur ta propre machineConteneurs : 1Volumes de données : 0
  3. Échelon 2Ajouter la synchronisation entre tes appareilsConteneurs : 3Volumes de données : 1
  4. Échelon 3Scanner sur ton propre matérielConteneurs : 2Volumes de données : 1
  5. Échelon 4Tout faire tournerConteneurs : 4Volumes de données : 2

Les quatre échelons

Quatre échelons. Chacun apporte une fonctionnalité et ajoute un élément que tu dois désormais administrer. Commence par le bas et arrête-toi dès que tu as ce qu'il te faut : la plupart des gens s'arrêtent à l'échelon 0 ou 1.

ÉchelonCe que tu obtiensCe que tu gèresFichier Compose
0Suivi des assiettes + analyses IARienaucun
1La même chose, sur ta propre machineUn conteneur sans étatdocker/compose.yml
2Ton journal sur deux appareils, et, sur une instance gérée, une facture IA partagée pour un foyer ou une organisation+ une base de données et un secretdocker/topologies/compose.core.yml
3Les analyses sur ton propre matériel+ un moteur d'exécution de modèlesdocker/topologies/compose.inference.yml
4La totalitéLa totalitédocker/topologies/compose.full.yml

Chaque fichier Compose est annoté ligne par ligne ; docker/topologies/README.md propose la même vue d'ensemble du point de vue de Compose.

À chaque niveau, le serveur de l'application consulte également la base de données alimentaire LowCarbCheck pour trouver les noms d'aliments des personnes qui l'utilisent. Il envoie des noms, jamais une photo ni une entrée du journal. À partir du niveau 1, c'est ton serveur qui s'en charge : si plusieurs personnes scannent, fournis-lui une clé gratuite. Voir architecture.md.

Chaque commande ci-dessous fonctionne aussi sous Podman avec podman compose. Sur Ubuntu, cette sous-commande nécessite d'installer le paquet podman-compose à côté. Voir podman.md.

Comment utiliser un fichier compose

Chaque échelon à partir du niveau 1 correspond à un fichier compose. Ce fichier liste chaque conteneur, port et volume. Docker ou Podman s'en sert pour les démarrer. Le panneau sous chaque échelon montre ce que son fichier démarre.

  1. Crée un dossier permanent, comme ~/openplate, et lance chaque commande depuis cet endroit. Compose lit le fichier .env situé à côté du fichier compose.

  2. Télécharge le fichier compose de ton échelon dans ce dossier.

  3. Écris dans .env les lignes demandées par le fichier. L'échelon 1 n'en a besoin d'aucune.

  4. Démarre avec docker compose -f <file> up -d. Le panneau sous chaque échelon indique l'adresse à ouvrir.

Pour mettre à jour, lance pull puis up -d à nouveau avec le même fichier. down arrête les conteneurs et conserve les volumes, les données restent donc en place.

Utiliser une instance gérée par un tiers

Ouvre une instance existante, par exemple https://openplate.lowcarbcheck.org, et colle ta propre clé de fournisseur dans Paramètres → IA. Il n'y a pas d'inscription. Ton journal réside dans le stockage de ce navigateur et n'atteint jamais le serveur de l'instance, de sorte qu'« utiliser l'instance de quelqu'un d'autre » donne bien moins à cet opérateur que l'expression ne le laisse penser : voir architecture.md. Les noms des aliments que tu scannes ou recherches transitent bien par lui, en route vers la base de données alimentaire.

À cet échelon, tu n'as rien à faire tourner. Le navigateur conserve le journal, le navigateur appelle le fournisseur avec la clé que tu y as collée, et le serveur de l'administrateur se contente d'envoyer la page.

À l'échelon zéro, le navigateur conserve le journal et appelle directement un fournisseur cloud avec ta clé.
Source du schéma
flowchart LR
  host["Someone else's instance"] -->|"HTML and JS"| browser["Your browser"]
  browser --- diary["Diary in this browser"]
  browser -->|"photo and your key"| cloud["Cloud AI provider"]

Tu obtiens : l'ensemble du produit, en une minute, pour le seul coût de ton utilisation de l'IA. Tu gères : rien.

La contrepartie, en toute franchise : une instance de démonstration publique n'offre aucune garantie de disponibilité et rien n'y est sauvegardé pour toi. Ton journal se trouve dans ce navigateur, et vider le navigateur le supprime. Exporte régulièrement le JSON depuis Profil → Tes données, ou passe au niveau 1.

Faire tourner l'application sur ta propre machine

Outil de conteneurs
mkdir -p ~/openplate && cd ~/openplate
curl -O https://raw.githubusercontent.com/LowCarbCheck/openplate/main/docker/compose.yml
docker compose -f compose.yml up -d
Ouvre-le comme http://localhost:3000 sur cette machine, ou via HTTPS. Depuis un autre appareil, http://<its address>:3000 affiche le journal. L'installation de l'application, l'utilisation hors ligne et la connexion OpenRouter en un clic n'y fonctionnent pas. Voir self-hosting.md.

Le niveau 1 modifie une seule machine. La page provient d'un conteneur que tu exécutes, et le chemin de la photo est exactement le même que ci-dessus.

Au niveau un, la page provient de ton propre conteneur sans état, et le trajet de la photo reste inchangé.
Source du schéma
flowchart LR
  app["openplate app, your box"] -->|"HTML and JS"| browser["Your browser"]
  browser --- diary["Diary in this browser"]
  browser -->|"photo and your key"| cloud["Cloud AI provider"]

Tu obtiens : l'application sur du matériel que tu contrôles, que tu peux mettre à jour selon ton propre calendrier, sans dépendre de l'instance de quelqu'un d'autre. Tu gères : un seul conteneur. Pas de base de données, pas d'étape .env, aucun secret à générer, rien à migrer lors d'une mise à jour. S'il s'arrête, rien n'est perdu, car il ne stocke rien. Fichier Compose : docker/compose.yml.

docker/compose.yml

Publié dans la version 0.66.0

Ce qui démarre

  • L'application app

    ghcr.io/lowcarbcheck/openplate:latest

    Port 3000 sur cette machine · Aucun volume

latest suit la version la plus récente. Pour figer une version, remplace latest par son numéro.

Contenu du fichier .env

Il n'a besoin d'aucun fichier .env pour démarrer.

Ces lignes définissent comment le joindre :

  • APP_URLValeur par défaut : http://localhost:3000

    Transmis à : app → APP_URL

  • TRUST_PROXYValeur par défaut : 1

    Transmis à : app → TRUST_PROXY

Derrière un proxy inverse, garde TRUST_PROXY à 1. Sans proxy, passe-le à 0.

Il lit au total 25 paramètres depuis .env. Le fichier indique la valeur par défaut de chaque paramètre facultatif. Explications pour chaque paramètre

Commandes

Démarrer
docker compose -f compose.yml up -d
Mettre à jour
docker compose -f compose.yml pull docker compose -f compose.yml up -d
Suivre les journaux
docker compose -f compose.yml logs -f
Arrêter
docker compose -f compose.yml down

Ouvre http://localhost:3000 sur la machine qui l'exécute.

Les téléphones et les autres appareils ont besoin de HTTPS. Le guide d'Auto-hébergement montre comment le configurer, même sans nom de domaine.

Pour Podman, lance podman compose au lieu de docker compose.

Afficher tout le fichier (144 lignes)
yaml
# openplate, self-hosted: one stateless container and nothing else.
#
#   mkdir -p ~/openplate && cd ~/openplate
#   curl -O https://raw.githubusercontent.com/LowCarbCheck/openplate/main/docker/compose.yml
#   docker compose -f compose.yml up -d
#
# Keep this file in a folder that lasts, like ~/openplate above, and run every
# command from there. Compose treats the compose file's OWN directory as the
# project directory, so a `.env` beside this file is the one it reads, not one
# somewhere further up. A folder under /tmp can be emptied by a reboot.
#
# Only http://localhost:3000 on this machine counts as a secure page. Opened
# from another device at http://<this machine's address>:3000, the diary and
# plate photos work, but installing the app, offline use and the one-click
# OpenRouter connect do not. See the HTTPS section of apps/app/docs/self-hosting.md.
#
# There is no database and no secret to configure. The server stores nothing:
# your diary lives in your browser's own IndexedDB on the device you use it
# from (see apps/app/.adr/0006-the-app-server-holds-no-accounts.md). Back up with the
# in-app JSON export, not with a database dump.
#
# If you also want the optional core server (accounts and diary sync), use
# docker/topologies/compose.core.yml instead. THAT one needs a database,
# because the core server keeps accounts and ciphertext. The other shapes
# (self-hosted AI, or everything at once) sit beside it; docker/topologies/
# README.md is the one-page map.
# Fixes the project name. Without it Compose names the stack after the
# directory the file sits in -- "docker" for anyone running from a checkout --
# and every container and volume inherits that name.
name: openplate

services:
  # Pulls the published multi-arch image from GHCR by default -- no source
  # checkout required for a self-host. To build from source instead (e.g.
  # developing against this repo), comment out `image:` below and uncomment
  # `build:`, then run:
  #   docker compose --project-directory . -f docker/compose.yml build
  #   docker compose --project-directory . -f docker/compose.yml up -d
  # Run those two from the repo root. The build context below is written
  # relative to THIS file, so it points one level up and into the app's folder
  # of the checkout, apps/app, and `--project-directory .` is what makes
  # Compose read the repo root's `.env` instead of the one it would look for
  # in `docker/`.
  app:
    image: ghcr.io/lowcarbcheck/openplate:latest
    # build:
    #   context: ../apps/app
    #   dockerfile: Dockerfile.pnpm
    restart: unless-stopped
    ports:
      # Published on EVERY network interface of this machine, so anyone on your
      # network can open http://<this machine's address>:3000. Behind a reverse
      # proxy on this machine, write '127.0.0.1:3000:3000' instead: then only
      # the proxy can reach the app, and the plain HTTP port is gone.
      - '3000:3000'
    # To serve legal pages, uncomment this and set CONTENT_DIR in `.env`:
    #   CONTENT_DIR=/srv/openplate/content
    # volumes:
    #   - ./content:/srv/openplate/content:ro
    environment:
      NODE_ENV: production
      PORT: 3000
      # Public URL this instance is reachable at. Set APP_URL in .env if you
      # put a reverse proxy in front (see apps/app/docs/self-hosting.md, HTTPS).
      APP_URL: ${APP_URL:-http://localhost:3000}
      # ON by default. Queries the public LowCarbCheck food database for
      # curated nutrition data (food NAMES only, never photos; fails open on
      # outages). An EMPTY string disables it entirely so no food names ever
      # leave your machine.
      FOOD_DB_API_URL: ${FOOD_DB_API_URL-https://lowcarbcheck.org}
      # Optional free key for that database. Empty is the shared anonymous
      # allowance; set one if more than one person scans on this instance.
      FOOD_DB_API_KEY: ${FOOD_DB_API_KEY:-}
      # "true" passes foods people save from an AI answer on to LowCarbCheck as
      # proposals. Needs FOOD_DB_API_KEY. Empty means off.
      FOOD_DB_BACKFILL: ${FOOD_DB_BACKFILL:-}
      # The most LowCarbCheck calls this server makes in one UTC day. Empty means
      # the default, 3200.
      FOOD_DB_DAILY_CALL_LIMIT: ${FOOD_DB_DAILY_CALL_LIMIT:-}
      # Number of reverse proxies in front of this container. Behind one proxy
      # (Caddy, nginx, Traefik) keep 1: React Router's CSRF check compares the
      # browser Origin against the host it thinks it is serving, and without
      # the proxy's X-Forwarded-* headers form posts fail. With NO proxy, set
      # TRUST_PROXY=0 in .env: pages work either way, but 1 lets any visitor
      # fake their address in X-Forwarded-For and dodge the per-address limit
      # on food lookups. 2 = Cloudflare in front of one proxy.
      TRUST_PROXY: ${TRUST_PROXY:-1}
      # The language a first-time visitor sees: en, de, fr, it, es or tr.
      # Empty means en. Anyone can still switch in Settings.
      DEFAULT_UI_LANGUAGE: ${DEFAULT_UI_LANGUAGE:-}
      # "off" disables the six-hourly request to openplate.de for the newest version
      # and the project's daily count of asks. Empty means on.
      UPDATE_CHECK: ${UPDATE_CHECK:-}
      # Closes this instance: an https:// address where its people went.
      # Every page then names it. Empty means open as usual.
      MOVED_TO_URL: ${MOVED_TO_URL:-}
      # Extra origins the browser may call, space separated, for example a
      # remote AI endpoint of your own. Empty adds nothing.
      CSP_CONNECT_EXTRA: ${CSP_CONNECT_EXTRA:-}
      # debug, info, warn or error.
      LOG_LEVEL: ${LOG_LEVEL:-info}
      # The address of openplate-core, one a BROWSER can reach.
      # Empty means no sync. docker/topologies/compose.core.yml runs one.
      CORE_URL: ${CORE_URL:-}
      # The old name of CORE_URL, read for one more release. Set CORE_URL.
      SYNC_SERVER_URL: ${SYNC_SERVER_URL:-}
      # open (the default) or managed, which needs CORE_URL. See
      # apps/app/docs/configuration.md, Managed instances.
      INSTANCE_MODE: ${INSTANCE_MODE:-open}
      # An OpenAI-compatible vision endpoint every browser here may use with
      # one tap, at an address a BROWSER can reach. The key is PUBLIC: every
      # browser that loads the app can read it. Empty means each person brings
      # their own key. The model defaults to openplate-plate-1.
      DEFAULT_INFERENCE_BASE_URL: ${DEFAULT_INFERENCE_BASE_URL:-}
      DEFAULT_INFERENCE_API_KEY: ${DEFAULT_INFERENCE_API_KEY:-}
      DEFAULT_INFERENCE_MODEL: ${DEFAULT_INFERENCE_MODEL:-}
      # Which published reference values the Nutrients screen quotes: dge (the
      # default), efsa or us.
      NUTRIENT_REFERENCE_BASIS: ${NUTRIENT_REFERENCE_BASIS:-dge}
      # Matomo analytics, off unless the first two are set together. The level
      # is pageviews, product (the default when empty) or research, and only
      # with the pair: a level on its own stops the boot.
      MATOMO_URL: ${MATOMO_URL:-}
      MATOMO_SITE_ID: ${MATOMO_SITE_ID:-}
      MATOMO_EVENT_LEVEL: ${MATOMO_EVENT_LEVEL:-}
      # A newsletter form on the landing page, off unless both are set.
      NEWSLETTER_SUBSCRIBE_URL: ${NEWSLETTER_SUBSCRIBE_URL:-}
      NEWSLETTER_TURNSTILE_SITE_KEY: ${NEWSLETTER_TURNSTILE_SITE_KEY:-}
      # The folder of legal pages, mounted read-only. Set it to the container
      # path of the volume line above. Empty means no legal pages.
      CONTENT_DIR: ${CONTENT_DIR:-}
      # The address the server binds to inside the container. Leave it empty:
      # the published port reaches only a server on every interface.
      HOST: ${HOST:-}
    healthcheck:
      # A shell line with no quotes and no brackets, run by the image's busybox
      # wget. Docker Compose, podman-compose and Quadlet all pass it through
      # the same way; the old `node -e "fetch(...)"` form reached podman-compose
      # 1.0.6 as a broken shell line and stayed unhealthy forever.
      test: ['CMD-SHELL', 'wget -q -O /dev/null http://127.0.0.1:3000/healthcheck']
      interval: 30s
      timeout: 5s
      start_period: 30s
      retries: 3

C'est le point d'arrêt recommandé. Tout ce qui suit ajoute un réel travail d'exploitation.

Le guide pas-à-pas complet se trouve dans self-hosting.md. Il couvre HTTPS, dont tu as besoin pour installer la PWA, connecter OpenRouter en un clic et te connecter à partir du niveau 2.

Ajouter la synchronisation entre tes appareils

Tu obtiens : un seul journal sur l'ensemble de tes appareils. Pour le dire honnêtement, cela sert surtout à une personne, deux appareils : un téléphone et un ordinateur portable qui restent synchronisés. L'usage pour les familles est le second cas d'usage, et le moins adapté : la synchronisation fonctionne par compte, donc deux personnes qui partagent un même compte partagent un seul journal au lieu d'en avoir un chacune. Deux personnes qui souhaitent des journaux distincts doivent créer deux comptes, ou tout simplement utiliser deux appareils au niveau 1 sans aucune synchronisation.

Le niveau 2 ajoute un second serveur avec une base de données derrière. Chaque appareil envoie le même bloc chiffré et récupère celui de l'autre appareil, et la photo continue de partir de chaque appareil vers le fournisseur.

Au deuxième échelon, les deux appareils envoient un unique bloc chiffré au serveur central, et la photo part toujours directement vers le fournisseur.
Source du schéma
flowchart LR
  app["openplate app"] -->|"HTML and JS"| phone["Phone"]
  app -->|"HTML and JS"| laptop["Laptop"]
  phone -->|"ciphertext"| sync["openplate-core"]
  laptop -->|"ciphertext"| sync
  sync --> db[("Postgres")]
  phone -->|"photo and your key"| cloud["Cloud AI provider"]
  laptop -->|"photo and your key"| cloud

Tu gères : l'application, un service de comptes et une base Postgres. C'est une vraie étape supplémentaire : un service de comptes implique une base de données qu'il faut sauvegarder, un SERVER_SECRET à conserver, et des utilisateurs qui risquent de bloquer leur accès. Lis README d'openplate-core avant de l'exposer sur l'internet public. Fichier Compose : docker/topologies/compose.core.yml.

docker/topologies/compose.core.yml

Publié dans la version 0.66.0

Ce qui démarre

  • Base de données postgres

    docker.io/library/postgres:18-alpine

    Aucun port sur cette machine · Volume : pg-data-18

  • L'application app

    ghcr.io/lowcarbcheck/openplate:latest

    Port 3000 sur cette machine · Aucun volume

  • Serveur central core

    ghcr.io/lowcarbcheck/openplate-core:latest

    Port 3001 sur cette machine, pour l'API de synchronisation et les commandes d'administration · Aucun volume · Démarre après postgres

latest suit la version la plus récente. Pour figer une version, remplace latest par son numéro.

Les données se trouvent dans ces volumes : pg-data-18. down les conserve, et down -v les supprime.

Contenu du fichier .env

Son en-tête demande ces lignes :

  • SERVER_SECRETrequis

    Transmis à : core → SERVER_SECRET

  • ADMIN_TOKENVide par défaut

    Transmis à : core → ADMIN_TOKEN

  • PUBLIC_APP_URLValeur par défaut : http://localhost:3000

    Transmis à : app → APP_URL, core → CLIENT_BASE_URL

  • PUBLIC_SYNC_URLValeur par défaut : http://localhost:3001

    Transmis à : app → CORE_URL, core → SERVER_PUBLIC_URL

Ces lignes définissent comment le joindre :

  • PUBLIC_INFERENCE_URLVide par défaut

    Transmis à : app → DEFAULT_INFERENCE_BASE_URL

  • TRUST_PROXYValeur par défaut : 1

    Transmis à : app → TRUST_PROXY, core → TRUST_PROXY

  • APP_PORTValeur par défaut : 3000

    Modifie le port publié pour app

  • SYNC_PORTValeur par défaut : 3001

    Modifie le port publié pour core

Derrière un proxy inverse, garde TRUST_PROXY à 1. Sans proxy, passe-le à 0.

Il lit au total 98 paramètres depuis .env. Le fichier indique la valeur par défaut de chaque paramètre facultatif. Explications pour chaque paramètre

Commandes

Démarrer
docker compose -f compose.core.yml up -d
Mettre à jour
docker compose -f compose.core.yml pull docker compose -f compose.core.yml up -d
Suivre les journaux
docker compose -f compose.core.yml logs -f
Arrêter
docker compose -f compose.core.yml down

Ouvre http://localhost:3000 sur la machine qui l'exécute.

Les téléphones et les autres appareils ont besoin de HTTPS. Le guide d'Auto-hébergement montre comment le configurer, même sans nom de domaine.

Pour Podman, lance podman compose au lieu de docker compose.

Afficher tout le fichier (454 lignes)
yaml
# openplate, the full experience, self-hosted end to end.
#
# Three containers: the stateless app, the optional account + E2EE sync
# service (openplate-core), and the Postgres that sync, and only sync, needs.
# The app itself keeps no database at all. Both images are open source under
# the MIT License and are published to GHCR; nothing here builds from source.
#
# If you do not want sync, you do not want this file. Use `docker/compose.yml`
# instead: the app alone needs no secrets and no accounts. The other shapes are
# listed in `README.md` next to this file.
#
#   mkdir -p ~/openplate && cd ~/openplate
#   curl -O https://raw.githubusercontent.com/LowCarbCheck/openplate/main/docker/topologies/compose.core.yml
#
#   # The core server needs exactly one secret. Generate it once and keep it
#   # with your database backups, see the SERVER_SECRET note below.
#   echo "SERVER_SECRET=$(openssl rand -hex 32)" >> .env
#
#   # Your key to the admin API, which is how you create the first account.
#   echo "ADMIN_TOKEN=$(openssl rand -hex 32)" >> .env
#
#   # The two URLs a BROWSER will use to reach each service. Defaults below
#   # work for a trial on this machine; set these for anything else.
#   echo "PUBLIC_APP_URL=https://openplate.example.com"  >> .env
#   echo "PUBLIC_SYNC_URL=https://sync.example.com"      >> .env
#
#   docker compose -f compose.core.yml up -d
#
# Keep this file in a folder that lasts, like ~/openplate above, and run all of
# that from there. Compose treats the compose file's OWN directory as the
# project directory, so the `.env` you just wrote, sitting beside this file, is
# the one it reads. Compose passes on only the variables named below: a line in
# `.env` that no `${...}` here mentions never reaches a container.
#
# Signing in needs a secure page: https://, or http://localhost on the machine
# you are sitting at. Over plain http://<LAN address> the sign-in, the sign-up
# and the invite link all fail. See the HTTPS section of apps/app/docs/self-hosting.md.
#
# Then create the first account with an invitation to yourself, minted on
# THIS machine with ADMIN_TOKEN (apps/app/docs/self-hosting.md has the curl command).
# Open the link it returns, choose a password, and the two devices you sign in
# on converge. The service stores ciphertext; what its operator holds is
# explained in apps/app/docs/sync.md.
#
# Fixes the project name, so containers and the pg-data-18 volume are named after
# the stack rather than after whatever directory the file sits in.
#
# The name keeps its old spelling on purpose. Compose prefixes the volume with
# it (`openplate-with-sync_pg-data-18`), so a new name would start an empty
# database next to the one an earlier install already filled.
name: openplate-with-sync

services:
  # ── Postgres ──────────────────────────────────────────────────────────────
  # Belongs to the core server alone: it holds sync's accounts and the
  # opaque ciphertext blobs. The app never connects to it and has no database
  # of its own (apps/app/.adr/0006-the-app-server-holds-no-accounts.md).
  # Postgres 18. The volume is `pg-data-18` on purpose. The 18 image keeps its
  # cluster in /var/lib/postgresql/18/docker and the volume mounts one level up,
  # at /var/lib/postgresql. It refuses a volume that holds a 17 cluster, so the
  # old `pg-data` volume cannot be reused. It stays untouched as your rollback.
  # An install that ran Postgres 17 follows "Postgres 18 upgrade" in
  # docker/topologies/README.md: dump, start, restore.
  postgres:
    image: docker.io/library/postgres:18-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-openplate}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-openplate}
      POSTGRES_DB: ${SYNC_DB_NAME:-openplate_sync}
    volumes:
      - pg-data-18:/var/lib/postgresql
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER:-openplate} -d ${SYNC_DB_NAME:-openplate_sync}']
      interval: 5s
      timeout: 5s
      retries: 10
    # Deliberately not published to the host: both services reach Postgres
    # over the compose network. Add a `ports:` mapping only if you need psql
    # from outside, and bind it to 127.0.0.1 if you do.
    expose:
      - '5432'

  # ── The app ───────────────────────────────────────────────────────────────
  # Stateless. No accounts, no personal data, no database: your diary lives in
  # the browser. There is no secret to configure here; that is the design,
  # not an omission (see apps/app/.adr/0006-the-app-server-holds-no-accounts.md).
  app:
    image: ghcr.io/lowcarbcheck/openplate:latest
    restart: unless-stopped
    ports:
      # Published on EVERY network interface. Behind a reverse proxy on this
      # machine, write '127.0.0.1:3000:3000' so only the proxy can reach it.
      - '${APP_PORT:-3000}:3000'
    # To serve legal pages, uncomment this and set CONTENT_DIR in `.env`:
    #   CONTENT_DIR=/srv/openplate/content
    # volumes:
    #   - ./content:/srv/openplate/content:ro
    environment:
      NODE_ENV: production
      PORT: 3000

      # The URL a browser uses to reach THIS app. Behind a reverse proxy, that
      # is the public https:// address, not the container port.
      APP_URL: ${PUBLIC_APP_URL:-http://localhost:3000}

      # The URL a BROWSER uses to reach the core server, not `http://core:3000`.
      # The sync client runs in the page, so this address has to resolve from
      # your users' devices. Setting it is what makes the sync interface exist
      # at all; remove this line and the app is a pure local tracker again.
      # The origin is added to the app's Content-Security-Policy automatically.
      CORE_URL: ${PUBLIC_SYNC_URL:-http://localhost:3001}
      SYNC_SERVER_URL: ${SYNC_SERVER_URL:-}

      # `open` (the default): anyone can keep a diary on their own device, and
      # sync is an extra. `managed`: an administrator invites every person,
      # there is no diary without an account, and scans run through the sync
      # service's AI proxy (set UPSTREAM_* and AI_ADVERTISED_MODEL below).
      # See apps/app/docs/configuration.md, Managed instances.
      INSTANCE_MODE: ${INSTANCE_MODE:-open}

      # How many reverse proxies stand in front of the app AND the core server.
      # One value for both, because they sit behind the same proxy or behind
      # none. With one proxy (Caddy, nginx, Traefik) set TRUST_PROXY=1: the
      # app's CSRF check needs the proxy's X-Forwarded-* headers or form posts
      # fail. With NO proxy set TRUST_PROXY=0: 1 would let any visitor fake
      # their address in X-Forwarded-For and dodge the per-address limits.
      # The app's default of 1 assumes a proxy.
      TRUST_PROXY: ${TRUST_PROXY:-1}

      # ON by default. Queries the public LowCarbCheck food database for
      # curated nutrition data (food NAMES only, never photos; fails open on
      # outages). An EMPTY string disables it entirely so no food names ever
      # leave your machine.
      FOOD_DB_API_URL: ${FOOD_DB_API_URL-https://lowcarbcheck.org}
      # Optional free key for that database. Empty is the shared anonymous
      # allowance; set one if more than one person scans on this instance.
      FOOD_DB_API_KEY: ${FOOD_DB_API_KEY:-}
      # "true" passes foods people save from an AI answer on to LowCarbCheck as
      # proposals. Needs FOOD_DB_API_KEY. Empty means off.
      FOOD_DB_BACKFILL: ${FOOD_DB_BACKFILL:-}
      # The most LowCarbCheck calls this server makes in one UTC day. Empty means
      # the default, 3200.
      FOOD_DB_DAILY_CALL_LIMIT: ${FOOD_DB_DAILY_CALL_LIMIT:-}
      # The language a first-time visitor sees: en, de, fr, it, es or tr.
      # Empty means en.
      DEFAULT_UI_LANGUAGE: ${DEFAULT_UI_LANGUAGE:-}
      # "off" disables the six-hourly request to openplate.de for the newest version
      # and the project's daily count of asks. Empty means on.
      UPDATE_CHECK: ${UPDATE_CHECK:-}
      # Closes this instance: an https:// address where its people went.
      # Every page then names it. Empty means open as usual.
      MOVED_TO_URL: ${MOVED_TO_URL:-}
      # Extra origins the browser may call, space separated. Empty adds nothing.
      CSP_CONNECT_EXTRA: ${CSP_CONNECT_EXTRA:-}

      # debug, info, warn or error, for the core server below as well.
      LOG_LEVEL: ${LOG_LEVEL:-info}

      # An OpenAI-compatible vision endpoint of your own that every browser
      # here may use with one tap, at an address a BROWSER can reach (the same
      # names compose.full.yml uses). The key is PUBLIC: every browser that
      # loads the app can read it. Empty means each person brings their own
      # key. The model defaults to openplate-plate-1.
      DEFAULT_INFERENCE_BASE_URL: ${PUBLIC_INFERENCE_URL:-}
      DEFAULT_INFERENCE_API_KEY: ${INFERENCE_API_KEY:-}
      DEFAULT_INFERENCE_MODEL: ${DEFAULT_INFERENCE_MODEL:-}
      # Which published reference values the Nutrients screen quotes: dge (the
      # default), efsa or us.
      NUTRIENT_REFERENCE_BASIS: ${NUTRIENT_REFERENCE_BASIS:-dge}
      # Matomo analytics, off unless the first two are set together. The level
      # is pageviews, product (the default when empty) or research, and only
      # with the pair: a level on its own stops the boot.
      MATOMO_URL: ${MATOMO_URL:-}
      MATOMO_SITE_ID: ${MATOMO_SITE_ID:-}
      MATOMO_EVENT_LEVEL: ${MATOMO_EVENT_LEVEL:-}
      # A newsletter form on the landing page, off unless both are set.
      NEWSLETTER_SUBSCRIBE_URL: ${NEWSLETTER_SUBSCRIBE_URL:-}
      NEWSLETTER_TURNSTILE_SITE_KEY: ${NEWSLETTER_TURNSTILE_SITE_KEY:-}
      # The folder of legal pages, mounted read-only. Set it to the container
      # path of the volume line above. Empty means no legal pages.
      CONTENT_DIR: ${CONTENT_DIR:-}
      # The address the server binds to inside the container. Leave it empty:
      # the published port reaches only a server on every interface.
      HOST: ${HOST:-}
    healthcheck:
      # A shell line with no quotes and no brackets, run by the image's busybox
      # wget, so Docker Compose, podman-compose and Quadlet all run it alike.
      test: ['CMD-SHELL', 'wget -q -O /dev/null http://127.0.0.1:3000/healthcheck']
      interval: 30s
      timeout: 5s
      start_period: 30s
      retries: 3

  # ── The core server ──────────────────────────────────────────────────────
  # An account service that stores an email address and opaque ciphertext,
  # plus each account's recovery code, sealed under SERVER_SECRET, so that a
  # password reset brings the diary back. apps/app/docs/sync.md states what that means
  # for whoever runs this service.
  core:
    image: ghcr.io/lowcarbcheck/openplate-core:latest
    restart: unless-stopped
    healthcheck:
      # The image bakes a check in, but Podman drops a HEALTHCHECK when it
      # pulls an OCI manifest, which is what GHCR serves. Declared here it
      # holds under both engines and Quadlet turns it into Notify=healthy.
      test: ['CMD-SHELL', 'wget -q -O /dev/null http://127.0.0.1:3000/health']
      interval: 30s
      timeout: 5s
      start_period: 20s
      retries: 3
    depends_on:
      postgres:
        condition: service_healthy
    ports:
      # Published on EVERY network interface, like the app. Behind a reverse
      # proxy on this machine, write '127.0.0.1:3001:3000'.
      - '${SYNC_PORT:-3001}:3000'
    # Uncomment what you use, and set the matching variable in `.env`:
    #   CONTENT_DIR=/srv/openplate/content    (mount the same folder on the app)
    #   NODE_EXTRA_CA_CERTS=/etc/openplate/ca.pem
    # volumes:
    #   - ./content:/srv/openplate/content:ro
    #   - ./ca.pem:/etc/openplate/ca.pem:ro
    environment:
      PORT: 3000
      DATABASE_URL: postgres://${POSTGRES_USER:-openplate}:${POSTGRES_PASSWORD:-openplate}@postgres:5432/${SYNC_DB_NAME:-openplate_sync}

      # THE one secret in this file. Three subkeys are derived from it: the
      # pepper mixed into every stored authentication verifier, the key behind
      # the anti-enumeration KDF responses, and the key that seals each
      # account's recovery code.
      #
      # Back it up WITH the database. A restored database with a lost secret
      # is a database nobody can log into, and no password reset works either.
      # Changing it has the same effect as losing it.
      SERVER_SECRET: ${SERVER_SECRET:?generate one with `openssl rand -hex 32` and put it in .env}

      # Your key to the admin API at /v1/admin: minting invitations, handing out
      # password-reset links, listing and removing accounts. Empty turns that
      # API off unless an account with the admin role exists. At least 24
      # characters: generate it with `openssl rand -hex 32`, never choose it.
      ADMIN_TOKEN: ${ADMIN_TOKEN:-}

      # The two halves of every invitation and reset link, taken from the same
      # PUBLIC_* values the app uses, so you set each address once. A link
      # reads PUBLIC_APP_URL/join#server=PUBLIC_SYNC_URL&invite=...
      SERVER_PUBLIC_URL: ${PUBLIC_SYNC_URL:-http://localhost:3001}
      CLIENT_BASE_URL: ${PUBLIC_APP_URL:-http://localhost:3000}

      # Signup is invite-only unless OPEN_SIGNUP is set below: an account is
      # created by redeeming an invitation addressed to one email address.
      # SIGNUP_MODE and the older SIGNUPS_OPEN are both boot failures in
      # openplate-core, so neither is forwarded here.

      # The same TRUST_PROXY as the app above: the number of reverse proxies in
      # front of this service. Left at 0 behind a proxy, every request looks
      # like it comes from the proxy and the per-address throttle becomes one
      # bucket a single attacker can lock for all your users. Set above 0 with
      # nothing in front, anyone can fake X-Forwarded-For and skip the throttle.
      TRUST_PROXY: ${TRUST_PROXY:-0}

      # debug, info, warn or error. Empty is refused, so the default stays.
      LOG_LEVEL: ${LOG_LEVEL:-info}

      # What the instance calls itself on the /health handshake and in its
      # start-up log, and which language its letters are written in when a
      # request names none (en, de, fr, it, es or tr). Empty means openplate, en.
      INSTANCE_NAME: ${INSTANCE_NAME:-}
      INSTANCE_LANGUAGE: ${INSTANCE_LANGUAGE:-}

      # ── Mail (optional): one transport, or none ──
      # When set, this service mails the invitation and the password reset
      # itself. When empty, it sends nothing. The admin API hands the
      # invitation link and the reset link to you, and you pass them on.
      # "Forgot password" in the app reaches nobody. See
      # apps/app/docs/self-hosting.md for what to do instead. With mail on,
      # PUBLIC_APP_URL and PUBLIC_SYNC_URL must be https addresses, or the
      # service refuses to start.
      #
      # Any Resend-compatible HTTP mail API. It takes a POST of JSON with a
      # Bearer token. Set all three:
      MAIL_API_URL: ${MAIL_API_URL:-}
      MAIL_API_KEY: ${MAIL_API_KEY:-}
      MAIL_API_FROM: ${MAIL_API_FROM:-}
      # Or SMTP, never both. SMTP_PORT defaults to 587 when empty. Port 465
      # uses TLS from the start. Every other port must upgrade with STARTTLS.
      # SMTP_USER and SMTP_PASSWORD go together. For Gmail, use an app
      # password on smtp.gmail.com.
      SMTP_HOST: ${SMTP_HOST:-}
      SMTP_PORT: ${SMTP_PORT:-}
      SMTP_USER: ${SMTP_USER:-}
      SMTP_PASSWORD: ${SMTP_PASSWORD:-}
      SMTP_FROM: ${SMTP_FROM:-}
      # Who receives the operator's copy of a cancellation or a withdrawal.
      # Either transport requires it.
      MAIL_OPERATOR_EMAIL: ${MAIL_OPERATOR_EMAIL:-}

      # ── The AI proxy (optional, for INSTANCE_MODE=managed) ──
      # The provider every signed-in scan is forwarded to, and its key. Both or
      # neither. Empty means this instance offers no AI of its own.
      UPSTREAM_BASE_URL: ${UPSTREAM_BASE_URL:-}
      UPSTREAM_API_KEY: ${UPSTREAM_API_KEY:-}
      # OpenRouter only, both optional: zero data retention endpoints, and a pin
      # to named providers with no fallback. Empty is the proxy's old behaviour.
      UPSTREAM_ZDR: ${UPSTREAM_ZDR:-}
      UPSTREAM_PROVIDER_ONLY: ${UPSTREAM_PROVIDER_ONLY:-}
      # Which file decides the model, the zero retention routing and the output
      # cap of each kind of request: empty (the default) keeps AI_ADVERTISED_MODEL
      # and the two settings above as the whole answer, `bundled` is the file in
      # the image, or an absolute path to a file you mount.
      AI_TIERS_FILE: ${AI_TIERS_FILE:-}
      # The model every proxied request is sent to. The app scans with the
      # model this names, so a managed instance with AI needs it set. With a
      # tier file it replaces the default tier's model (an emergency override).
      AI_ADVERTISED_MODEL: ${AI_ADVERTISED_MODEL:-}
      # The whole instance's AI requests per UTC day. Empty means no ceiling.
      AI_INSTANCE_DAILY_LIMIT: ${AI_INSTANCE_DAILY_LIMIT:-}
      # On an OpenRouter key: mail MAIL_OPERATOR_EMAIL once per reset period
      # when less than this share of the key's limit is left. Empty means 0.2.
      AI_BUDGET_ALERT_FRACTION: ${AI_BUDGET_ALERT_FRACTION:-}
      # How long one proxied request may take, the most output tokens it may
      # ask for, the requests per account per minute, and the largest request
      # body, sized for a camera photograph after base64.
      UPSTREAM_TIMEOUT_MS: ${UPSTREAM_TIMEOUT_MS:-120000}
      AI_MAX_OUTPUT_TOKENS: ${AI_MAX_OUTPUT_TOKENS:-8192}
      AI_RATE_LIMIT_PER_MINUTE: ${AI_RATE_LIMIT_PER_MINUTE:-20}
      AI_MAX_REQUEST_BYTES: ${AI_MAX_REQUEST_BYTES:-8000000}
      # What one request may carry in (image parts, text bytes, messages),
      # the input tokens one unit of the daily counters covers, and the
      # tokens one image is counted at.
      AI_MAX_IMAGE_PARTS: ${AI_MAX_IMAGE_PARTS:-1}
      AI_MAX_TEXT_BYTES: ${AI_MAX_TEXT_BYTES:-49152}
      AI_MAX_MESSAGES: ${AI_MAX_MESSAGES:-4}
      AI_UNIT_INPUT_TOKENS: ${AI_UNIT_INPUT_TOKENS:-8192}
      AI_IMAGE_INPUT_TOKENS: ${AI_IMAGE_INPUT_TOKENS:-1500}

      # ── Members inviting people (optional) ──
      # The first two together or neither; the cap only with them. Empty means
      # only an administrator invites. See apps/app/docs/configuration.md, Member invites.
      MEMBER_INVITE_DAILY_AI_LIMIT: ${MEMBER_INVITE_DAILY_AI_LIMIT:-}
      MEMBER_INVITE_ALLOWANCE_DAYS: ${MEMBER_INVITE_ALLOWANCE_DAYS:-}
      MEMBER_INVITE_LIFETIME_CAP: ${MEMBER_INVITE_LIFETIME_CAP:-}

      # "true" lets a person share their diary with a clinician. Off by default.
      SYNC_SHARING: ${SYNC_SHARING:-false}
      # "true" opens the research console at /study, and makes this server
      # hold study data. Read openplate-core's .env.example first. Off by default.
      SYNC_RESEARCH: ${SYNC_RESEARCH:-false}

      # ── The operator notice (optional) ──
      # One short sentence /health publishes and the client shows, for the
      # things this service can no longer tell anyone: a move, a shutdown, a
      # maintenance window. Empty means no notice, and SYNC_NOTICE_URL
      # without SYNC_NOTICE is a boot failure.
      SYNC_NOTICE: ${SYNC_NOTICE:-}
      SYNC_NOTICE_URL: ${SYNC_NOTICE_URL:-}

      # ── Reported estimates (optional) ──
      # On, this service KEEPS the photograph and the figures a person reports,
      # readable, for its retention window. The two limits are per account per
      # UTC day, and per request. Read openplate-core's .env.example first.
      SYNC_FEEDBACK: ${SYNC_FEEDBACK:-false}
      FEEDBACK_DAILY_LIMIT: ${FEEDBACK_DAILY_LIMIT:-5}
      FEEDBACK_MAX_REQUEST_BYTES: ${FEEDBACK_MAX_REQUEST_BYTES:-8000000}

      # ── Open sign-up (optional) ──
      # Empty means invite-only. "true" needs the mail block above. The
      # Turnstile pair is both or neither, and only with OPEN_SIGNUP.
      OPEN_SIGNUP: ${OPEN_SIGNUP:-}
      TURNSTILE_SECRET_KEY: ${TURNSTILE_SECRET_KEY:-}
      TURNSTILE_SITE_KEY: ${TURNSTILE_SITE_KEY:-}

      # ── Free AI scans for new accounts (optional) ──
      # TRIAL_SCANS and TRIAL_DAILY_AI_LIMIT together or neither, and the
      # pepper with them. TRIAL_DAYS also ends the trial at midnight after that
      # many days, in TRIAL_TIME_ZONE (an IANA name, empty means UTC).
      # MEMBER_INVITE_TRIAL=true makes a member invitation grant the trial.
      # Empty means no trial.
      TRIAL_SCANS: ${TRIAL_SCANS:-}
      TRIAL_DAILY_AI_LIMIT: ${TRIAL_DAILY_AI_LIMIT:-}
      TRIAL_DAYS: ${TRIAL_DAYS:-}
      TRIAL_TIME_ZONE: ${TRIAL_TIME_ZONE:-}
      TRIAL_ADDRESS_PEPPER: ${TRIAL_ADDRESS_PEPPER:-}
      TRIAL_HASH_RETENTION_DAYS: ${TRIAL_HASH_RETENTION_DAYS:-}
      MEMBER_INVITE_TRIAL: ${MEMBER_INVITE_TRIAL:-}
      AI_TRIAL_INSTANCE_DAILY_LIMIT: ${AI_TRIAL_INSTANCE_DAILY_LIMIT:-}
      AI_TRIAL_NETWORK_DAILY_LIMIT: ${AI_TRIAL_NETWORK_DAILY_LIMIT:-}

      # ── A standing free daily AI limit (optional) ──
      # Requests per UTC day for every account with no free limit of its own,
      # no end date and no trial. Empty or 0 means off. It cannot stand
      # beside the trial above: the boot stops naming both.
      DEFAULT_FREE_DAILY_AI_LIMIT: ${DEFAULT_FREE_DAILY_AI_LIMIT:-}

      # ── AI feature permissions (optional) ──
      # DEFAULT_CAPABILITIES is what an account with no record of its own may
      # use: comma separated labels, or "none" for nothing. Empty means no
      # check at all. CAPABILITY_SCHEMA_MAP ties a structured-output schema
      # name to the label its use needs, as schemaName:label pairs.
      DEFAULT_CAPABILITIES: ${DEFAULT_CAPABILITIES:-}
      CAPABILITY_SCHEMA_MAP: ${CAPABILITY_SCHEMA_MAP:-}

      # ── Web push (optional) ──
      # All three or none. Empty means no notifications.
      VAPID_PUBLIC_KEY: ${VAPID_PUBLIC_KEY:-}
      VAPID_PRIVATE_KEY: ${VAPID_PRIVATE_KEY:-}
      VAPID_SUBJECT: ${VAPID_SUBJECT:-}
      PUSH_ENDPOINT_HOSTS: ${PUSH_ENDPOINT_HOSTS:-}

      # ── Paid plans (optional) ──
      # The URL and the secret together or neither, and only with a billing
      # service behind this instance. BILLING_TOKEN is that service's own
      # credential. Empty means no plans.
      PLANS_UPSTREAM_URL: ${PLANS_UPSTREAM_URL:-}
      PLANS_UPSTREAM_SECRET: ${PLANS_UPSTREAM_SECRET:-}
      BILLING_TOKEN: ${BILLING_TOKEN:-}
      BILLING_MAX_DAILY_AI_LIMIT: ${BILLING_MAX_DAILY_AI_LIMIT:-}

      # ── Everything else ──
      # Which body's reference values the Nutrients screen quotes (dge, efsa or
      # us), for the app above too. Only the boot default: an administrator
      # changes the live setting, and the stored one wins from then on.
      NUTRIENT_REFERENCE_BASIS: ${NUTRIENT_REFERENCE_BASIS:-dge}
      # The health-data consent every account must agree to, a short string
      # such as 2026-09-28. Empty asks for no consent.
      HEALTH_CONSENT_VERSION: ${HEALTH_CONSENT_VERSION:-}
      # The folder of letter texts, the same one the app above reads its legal
      # pages from. Set it to the container path of the commented volume line
      # above this environment block.
      CONTENT_DIR: ${CONTENT_DIR:-}
      # The daily ceilings on declaration receipts, for the instance and per
      # sender network. Read openplate-core's .env.example first.
      LEGAL_DECLARATION_RECEIPTS_PER_DAY: ${LEGAL_DECLARATION_RECEIPTS_PER_DAY:-200}
      LEGAL_DECLARATION_RECEIPTS_PER_NETWORK_PER_DAY: ${LEGAL_DECLARATION_RECEIPTS_PER_NETWORK_PER_DAY:-10}
      # A PEM file of extra certificate authorities Node trusts, for an SMTP
      # server with a private CA. The container path of the commented volume
      # line above this environment block.
      NODE_EXTRA_CA_CERTS: ${NODE_EXTRA_CA_CERTS:-}
      # The address the listener binds to inside the container. Leave it empty:
      # the published port reaches only a listener on every interface.
      HOST: ${HOST:-}
      # Only for an EXTERNAL database. The bundled Postgres speaks plain TCP on
      # the compose network.
      DATABASE_SSL: ${DATABASE_SSL:-false}

      # Every variable openplate-core reads is forwarded above, so a line in
      # `.env` is all it takes. If you set SIGNUP_MODE, SIGNUPS_OPEN,
      # EMAIL_FROM, SMTP_SECURE, any PIGEON_*, or REQUIRE_EMAIL_VERIFICATION,
      # you get a BOOT FAILURE, so none of them is forwarded.

volumes:
  pg-data-18:
    driver: local
Outil de conteneurs
mkdir -p ~/openplate && cd ~/openplate
curl -O https://raw.githubusercontent.com/LowCarbCheck/openplate/main/docker/topologies/compose.core.yml
echo "SERVER_SECRET=$(openssl rand -hex 32)" >> .env
echo "ADMIN_TOKEN=$(openssl rand -hex 32)" >> .env
echo "PUBLIC_APP_URL=https://openplate.example.com"  >> .env
echo "PUBLIC_SYNC_URL=https://sync.example.com"      >> .env
echo "TRUST_PROXY=1"                                 >> .env  # 1 behind one reverse proxy, 0 with none
docker compose -f compose.core.yml up -d
Les comptes nécessitent une page sécurisée. La connexion, l'inscription et l'ouverture d'une invitation échouent sur du http://<LAN address> simple. Utilise HTTPS, avec un nom de domaine ou sur un réseau local sans domaine, ou localhost via un tunnel ssh pour un test. Personne ne s'inscrit de manière autonome. Tu génères la première invitation sur le serveur avec ADMIN_TOKEN, comme le montre Créer le premier compte. Un réseau local sans nom de domaine obtient HTTPS via Caddy avec un certificat local.

Le service enregistre chaque entrée sous forme de texte chiffré et ne reçoit jamais ton mot de passe. Il conserve le code de récupération de chaque compte, scellé sous son propre secret, afin qu'un mot de passe oublié soit réinitialisé par un lien (envoyé par e-mail, ou distribué par toi sur une instance sans e-mail) et que le journal revienne. Cela signifie aussi que l'opérateur du service peut, en théorie, ouvrir un journal dessus. sync.md détaille ce compromis, tout comme l'application avant de terminer la configuration de la synchronisation.

Le serveur peut aussi prendre en charge une facture d'IA partagée, si tu l'actives. Définis INSTANCE_MODE=managed et l'instance devient une instance gérée par un administrateur pour un foyer ou une organisation : les administrateurs invitent des personnes depuis /admin (ou via l'API d'administration), attribuent un quota quotidien à chaque compte, et chaque analyse effectuée par un membre connecté passe par le propre proxy IA du serveur central : aucun service distinct, aucun lien d'invitation séparé. Le courrier électronique est facultatif : /admin affiche systématiquement l'invitation sous forme de lien qu'un administrateur peut copier et transmettre, qu'un e-mail soit envoyé ou non. Consulte configuration.md#managed-instances et family-setup.md pour savoir quand cette option est préférable à l'usage de sous-clés chez le fournisseur.

Sur une instance gérée, ce même serveur prend aussi en charge l'analyse. Un membre connecté envoie la photo au proxy IA, le serveur la décompte du quota quotidien de ce compte, puis transmet la requête au service désigné par l'administrateur.

Sur une instance gérée, le membre connecté analyse ses repas via le proxy IA du serveur central, qui décompte la requête d'un quota journalier.
Source du schéma
flowchart LR
  browser["Member's browser"] -->|"ciphertext"| sync["openplate-core, managed"]
  browser -->|"photo"| sync
  sync --- quota["Daily allowance per account"]
  sync -->|"photo"| upstream["Cloud provider, or inference"]

Permets aux membres de s'inviter entre eux, tout en limitant le volume. Sur une instance gérée, active MEMBER_INVITE_DAILY_AI_LIMIT et MEMBER_INVITE_ALLOWANCE_DAYS sur le serveur central. Cela permet à un membre ordinaire d'inviter quelqu'un sans te demander l'autorisation au préalable. Si tu paies la clé du fournisseur, configure également MEMBER_INVITE_LIFETIME_CAP=2. La valeur par défaut est 5, ce qui convient à une instance où la facture d'IA est partagée. La régler sur 2 suffit pour un partenaire et un ami, tout en maintenant une croissance assez lente pour être surveillée. Voir configuration.md#member-invites.

Scanner sur ton propre matériel

Le niveau 3 exécute l'analyse sur ton matériel. Le navigateur envoie directement les photos au conteneur d'inférence. Tes navigateurs doivent résoudre l'adresse de ce conteneur. Le modèle identifie chaque aliment et estime son poids en grammes. openplate-inference lit les macros depuis ta source d'aliments configurée.

Au niveau trois, le navigateur envoie la photo à ton propre conteneur d'inférence, qui recherche les macros dans sa source d'aliments configurée.
Source du schéma
flowchart LR
  app["openplate app"] -->|"HTML and JS"| browser["Your browser"]
  browser --- diary["Diary in this browser"]
  browser -->|"photo, browser reachable address"| inf["openplate-inference"]
  inf --- weights["Model runtime and weights"]
  inf --- usda["Configured food data, USDA by default"]

Tu obtiens : analyses locales d'assiettes sans compte d'IA dans le cloud, sans frais par analyse, ni trafic sortant de photos. L'image du conteneur intègre par défaut un extrait de USDA FoodData Central, openplate-inference recherche donc les macros au lieu de les inventer. Tu gères : un environnement d'exécution de modèle et quelques gigaoctets de poids, plus tout ce qui est nécessaire pour rendre le point de terminaison accessible depuis tes navigateurs (la photo va de l'appareil au point de terminaison, un nom d'hôte compose ne fonctionne donc pas ici). Fichier Compose : docker/topologies/compose.inference.yml.

docker/topologies/compose.inference.yml

Publié dans la version 0.66.0

Ce qui démarre

  • Moteur d'inférence inference

    ghcr.io/lowcarbcheck/openplate-inference:latest

    Port 8300 sur cette machine · Volume : inference-models

  • L'application openplate

    ghcr.io/lowcarbcheck/openplate:latest

    Port 3000 sur cette machine · Aucun volume · Démarre après inference

latest suit la version la plus récente. Pour figer une version, remplace latest par son numéro.

Les données se trouvent dans ces volumes : inference-models. down les conserve, et down -v les supprime.

Contenu du fichier .env

Son en-tête demande ces lignes :

  • INFERENCE_API_KEYValeur par défaut : opk_CHANGE_ME

    Transmis à : inference → API_KEYS, openplate → DEFAULT_INFERENCE_API_KEY

  • PUBLIC_APP_URLValeur par défaut : http://openplate.example.lan:3000

    Transmis à : openplate → APP_URL

  • PUBLIC_INFERENCE_URLValeur par défaut : http://openplate.example.lan:8300/v1

    Transmis à : openplate → DEFAULT_INFERENCE_BASE_URL

Ces lignes définissent comment le joindre :

  • PUBLIC_SYNC_URLVide par défaut

    Transmis à : openplate → CORE_URL

  • TRUST_PROXYValeur par défaut : 1

    Transmis à : openplate → TRUST_PROXY

  • INFERENCE_PORTValeur par défaut : 8300

    Modifie le port publié pour inference

Derrière un proxy inverse, garde TRUST_PROXY à 1. Sans proxy, passe-le à 0.

Il lit au total 51 paramètres depuis .env. Le fichier indique la valeur par défaut de chaque paramètre facultatif. Explications pour chaque paramètre

Commandes

Démarrer
docker compose -f compose.inference.yml up -d
Mettre à jour
docker compose -f compose.inference.yml pull docker compose -f compose.inference.yml up -d
Suivre les journaux
docker compose -f compose.inference.yml logs -f
Arrêter
docker compose -f compose.inference.yml down

Ouvre http://localhost:3000 sur la machine qui l'exécute.

Les téléphones et les autres appareils ont besoin de HTTPS. Le guide d'Auto-hébergement montre comment le configurer, même sans nom de domaine.

Pour Podman, lance podman compose au lieu de docker compose.

Afficher tout le fichier (289 lignes)
yaml
# openplate + openplate-inference: your own AI, on your own hardware.
#
#   mkdir -p ~/openplate && cd ~/openplate
#   curl -O https://raw.githubusercontent.com/LowCarbCheck/openplate/main/docker/topologies/compose.inference.yml
#
#   # One key, used twice: the inference service accepts it, and the app
#   # hands it to every browser. Generate it here, on this machine.
#   echo "INFERENCE_API_KEY=opk_$(openssl rand -hex 24)" >> .env
#
#   # The two URLs a BROWSER will use. Replace 192.168.1.20 with this
#   # machine's address, or with the names your reverse proxy serves.
#   echo "PUBLIC_APP_URL=http://192.168.1.20:3000" >> .env
#   echo "PUBLIC_INFERENCE_URL=http://192.168.1.20:8300/v1" >> .env
#
#   docker compose -f compose.inference.yml up -d
#
# Keep this file in a folder that lasts, like ~/openplate above, and run all of
# that from there. Compose treats the compose file's OWN directory as the
# project directory, so a `.env` beside this file is the one it reads.
#
# The first start downloads about 2 GiB of weights before the first scan can
# run. `logs -f inference` shows the progress; http://<this machine>:8300/readyz
# answers 200 once the model is loaded.
#
# Plate photos work over plain http://. Installing the app needs a secure
# page: https://, or http://localhost on this machine. See the HTTPS section
# of apps/app/docs/self-hosting.md. Once the app is on https://, the inference URL must
# be https:// too, or the browser blocks the call from the secure page.
#
#   docker compose -f compose.inference.yml logs -f inference   # weight download + model load + ready
#   docker compose -f compose.inference.yml logs -f openplate
#
# What you get: an openplate instance whose users tap ONE button to use this
# instance's own AI -- no provider account, no API key of their own, no photo
# leaving your network. Both images are published to GHCR; nothing here builds
# from source. There is still no database and no secret on the app side.
#
# "README" below always means openplate-inference's README:
# https://github.com/LowCarbCheck/openplate/tree/main/apps/inference
#
# -- THE ONE THING PEOPLE GET WRONG ----------------------------------------
# `DEFAULT_INFERENCE_BASE_URL` must be a URL a BROWSER on the user's phone or
# laptop can open. The photo goes from the device straight to the inference
# endpoint -- openplate's server is never in the loop, which is what keeps the
# scan private. So `http://inference:8300/v1` (the container hostname) does NOT
# work, even though the two containers can talk to each other that way. Use the
# LAN address of this host, or a hostname on your reverse proxy / tailnet.

# Fixes the project name, so containers and the inference-models volume are
# named after the stack rather than after whatever directory the file sits in.
name: openplate-with-inference

services:
  # -- The inference service -------------------------------------------------
  inference:
    image: ghcr.io/lowcarbcheck/openplate-inference:latest
    restart: unless-stopped
    ports:
      # Published because the browser calls it directly. Bind to 0.0.0.0 (as
      # here) for LAN access; use "127.0.0.1:8300:8300" if a reverse proxy on
      # this host is the only thing that should reach it.
      - '${INFERENCE_PORT:-8300}:8300'
    volumes:
      # Weights land here on first boot (~2.0 GiB for lite, ~5.8 GiB for
      # quality) and are verified by sha256 on every start. Named, so
      # `docker compose down` does not throw the download away.
      - inference-models:/models
    environment:
      # lite | lite-apache | quality, see README "Hardware & measured latency".
      # external runs no model here and uses your runtime, see below.
      MODEL_PROFILE: ${MODEL_PROFILE:-lite}
      # The key callers must present. Set INFERENCE_API_KEY in .env (see the
      # top of this file); the placeholder below only keeps a first trial
      # booting. It must match DEFAULT_INFERENCE_API_KEY on the app.
      API_KEYS: ${INFERENCE_API_KEY:-opk_CHANGE_ME}
      # Self-host has no latency ceiling. 0 = never shed load for being slow.
      LATENCY_CEILING_MS: ${LATENCY_CEILING_MS:-0}
      # Scans in flight at once. It also sets llama.cpp's slot count; it does
      # NOT add CPU threads, the slots share LLAMA_THREADS.
      CONCURRENCY: ${CONCURRENCY:-2}
      # CPU threads for the model. Empty means every core but two (nproc - 2),
      # which leaves room for the service and the OS.
      LLAMA_THREADS: ${LLAMA_THREADS:-}
      # Where macros come from. fdc = the bundled offline USDA-derived dataset.
      # See README "Food data" before switching to `off` (ODbL) or `lcc`.
      FOOD_SOURCE: ${FOOD_SOURCE:-fdc}

      # -- Everything else the service reads. Empty means the default, and
      # openplate-inference's .env.example explains each one.
      #
      # Your own runtime, with MODEL_PROFILE=external (see below). No trailing
      # /v1, and the address must resolve from INSIDE this container.
      MODEL_RUNTIME_URL: ${MODEL_RUNTIME_URL:-}
      MODEL_RUNTIME_API_KEY: ${MODEL_RUNTIME_API_KEY:-}
      # The model id sent to the runtime. Empty means openplate-plate-1. vLLM
      # needs its exact served model name.
      MODEL_ID: ${MODEL_ID:-}
      # The waiting line, the bound on one completion call, the requests per
      # key per minute, the largest decoded image, and the downscale target.
      MAX_QUEUE_DEPTH: ${MAX_QUEUE_DEPTH:-8}
      RUNTIME_COMPLETION_TIMEOUT_MS: ${RUNTIME_COMPLETION_TIMEOUT_MS:-600000}
      RATE_LIMIT_RPM: ${RATE_LIMIT_RPM:-60}
      MAX_IMAGE_BYTES: ${MAX_IMAGE_BYTES:-8388608}
      IMAGE_MAX_LONG_EDGE: ${IMAGE_MAX_LONG_EDGE:-896}
      # debug, info, warn or error.
      LOG_LEVEL: ${LOG_LEVEL:-info}
      # What the service reports as its profile. Empty follows MODEL_PROFILE.
      PROFILE: ${PROFILE:-}
      # Each is read only by its own FOOD_SOURCE. Empty FDC_DATASET_PATH is the
      # bundled extract. Empty URLs are https://lowcarbcheck.org for lcc and
      # https://world.openfoodfacts.org for off.
      FDC_DATASET_PATH: ${FDC_DATASET_PATH:-}
      LCC_API_URL: ${LCC_API_URL:-}
      LCC_API_KEY: ${LCC_API_KEY:-}
      OFF_API_URL: ${OFF_API_URL:-}
      # A second runtime serving /v1/embeddings, for hybrid retrieval. Empty
      # means lexical retrieval only.
      EMBEDDING_RUNTIME_URL: ${EMBEDDING_RUNTIME_URL:-}
      EMBEDDING_RUNTIME_API_KEY: ${EMBEDDING_RUNTIME_API_KEY:-}
      # The bundled llama-server: its loopback port, the context per slot, the
      # layers put on the GPU (empty means detect), and extra flags passed on
      # as written.
      RUNTIME_PORT: ${RUNTIME_PORT:-8080}
      CONTEXT_SIZE: ${CONTEXT_SIZE:-8192}
      GPU_LAYERS: ${GPU_LAYERS:-}
      LLAMA_EXTRA_ARGS: ${LLAMA_EXTRA_ARGS:-}
      # A mirror tried before Hugging Face for the first weight download.
      WEIGHTS_MIRROR_BASE: ${WEIGHTS_MIRROR_BASE:-}
    # -- GPU (the `quality` profile) -- uncomment BOTH of these and switch the
    # image to the -cuda tag. The entrypoint detects the GPU and offloads every
    # layer automatically; there is no flag to set.
    # deploy:
    #   resources:
    #     reservations:
    #       devices:
    #         - driver: nvidia
    #           count: all
    #           capabilities: [gpu]

    # -- ALREADY RUNNING vLLM / llama.cpp / OLLAMA? ------------------------
    # Set these in `.env` and this container downloads no weights and starts
    # no second model; it just turns your runtime into a plate scanner. You can
    # drop the `volumes:` block and the `inference-models` volume entirely.
    #
    # Read README "Bring your own runtime" FIRST: your runtime must enforce
    # grammar-constrained decoding, and there is a one-line curl there that
    # tells you whether yours does. vLLM's CPU build does NOT (it crashes).
    #
    #   MODEL_PROFILE=external
    #   # Must resolve from INSIDE this container, and no trailing /v1.
    #   # `localhost` here means this container, not your host. Use the LAN
    #   # address, or host.docker.internal on Docker Desktop.
    #   MODEL_RUNTIME_URL=http://your-runtime.lan:8000
    #   # vLLM requires an EXACT match with its served model name.
    #   MODEL_ID=your-served-model-name
    #   # Only if your runtime is behind auth (`vllm serve --api-key ...`).
    #   # Separate from INFERENCE_API_KEY, which callers present to THIS service.
    #   MODEL_RUNTIME_API_KEY=sk_your_runtime_key
    #   # Match your runtime's real slot count:
    #   #   llama.cpp --parallel N | vLLM --max-num-seqs N | OLLAMA_NUM_PARALLEL
    #   CONCURRENCY=2
    #
    # REQUIRED with external mode, and the one edit to this file it needs. The
    # image bakes in a 60-minute health start_period, sized for a first-boot
    # weight download. External mode has no download, so without this override
    # a wrong MODEL_RUNTIME_URL stays hidden for an hour instead of surfacing
    # in seconds.
    # healthcheck:
    #   start_period: 30s

  # -- The app ---------------------------------------------------------------
  # Stateless. No accounts, no personal data, no database: your diary lives in
  # the browser. There is no secret to configure here -- that is the design, not
  # an omission (see apps/app/.adr/0006-the-app-server-holds-no-accounts.md).
  openplate:
    image: ghcr.io/lowcarbcheck/openplate:latest
    restart: unless-stopped
    ports:
      # Published on EVERY network interface. Behind a reverse proxy on this
      # machine, write '127.0.0.1:3000:3000' so only the proxy can reach it.
      - '3000:3000'
    depends_on:
      - inference
    # To serve legal pages, uncomment this and set CONTENT_DIR in `.env`:
    #   CONTENT_DIR=/srv/openplate/content
    # volumes:
    #   - ./content:/srv/openplate/content:ro
    environment:
      NODE_ENV: production
      PORT: 3000

      # The URL a browser uses to reach THIS app: PUBLIC_APP_URL in .env.
      # Behind a reverse proxy, that is the public https:// address, not the
      # container port.
      APP_URL: ${PUBLIC_APP_URL:-http://openplate.example.lan:3000}

      # ON by default -- queries the public LowCarbCheck food database for
      # curated nutrition data (food NAMES only, never photos; fails open on
      # outages). An EMPTY string disables it entirely so no food names ever
      # leave your machine.
      FOOD_DB_API_URL: ${FOOD_DB_API_URL-https://lowcarbcheck.org}
      # Optional free key for that database. Empty is the shared anonymous
      # allowance; set one if more than one person scans on this instance.
      FOOD_DB_API_KEY: ${FOOD_DB_API_KEY:-}
      # "true" passes foods people save from an AI answer on to LowCarbCheck as
      # proposals. Needs FOOD_DB_API_KEY. Empty means off.
      FOOD_DB_BACKFILL: ${FOOD_DB_BACKFILL:-}
      # The most LowCarbCheck calls this server makes in one UTC day. Empty means
      # the default, 3200.
      FOOD_DB_DAILY_CALL_LIMIT: ${FOOD_DB_DAILY_CALL_LIMIT:-}

      # Number of reverse proxies in front of this container. Behind one proxy
      # keep 1: React Router compares the browser Origin against the host it
      # thinks it serves, and without the proxy's X-Forwarded-* headers form
      # posts fail. With NO proxy set TRUST_PROXY=0 in .env: 1 would let any
      # visitor fake their address in X-Forwarded-For and dodge the
      # per-address limit on food lookups. 2 = Cloudflare in front of one.
      TRUST_PROXY: ${TRUST_PROXY:-1}

      # -- The instance preset: this is what turns into openplate's one-tap
      #    "This openplate provides its own AI" card, on the AI settings page
      #    and on the scan screen. Leave these unset and nothing renders --
      #    bring-your-own-key stays the only path.
      #
      # PUBLIC_INFERENCE_URL in .env: a BROWSER-reachable address for the
      # inference container. NOT http://inference:8300. Note the /v1 suffix.
      DEFAULT_INFERENCE_BASE_URL: ${PUBLIC_INFERENCE_URL:-http://openplate.example.lan:8300/v1}
      # The same INFERENCE_API_KEY as API_KEYS above.
      #
      # ! THIS KEY IS PUBLIC. It is embedded in the HTML every browser loads, so
      #   anyone who can open your openplate can read it with view-source. That
      #   is fine for a household or a tailnet. It is NOT fine on an instance
      #   open to the internet without a VPN or auth proxy in front of it -- in
      #   that case leave this unset and let people paste the key themselves.
      DEFAULT_INFERENCE_API_KEY: ${INFERENCE_API_KEY:-opk_CHANGE_ME}
      DEFAULT_INFERENCE_MODEL: ${DEFAULT_INFERENCE_MODEL:-openplate-plate-1}

      # -- Everything else the app reads. Empty means the default.
      #
      # The address of openplate-core, one a BROWSER can reach
      # (the same name compose.core.yml uses). Empty means no sync.
      CORE_URL: ${PUBLIC_SYNC_URL:-}
      SYNC_SERVER_URL: ${SYNC_SERVER_URL:-}
      # open (the default) or managed, which needs a core server. See
      # apps/app/docs/configuration.md, Managed instances.
      INSTANCE_MODE: ${INSTANCE_MODE:-open}
      # The language a first-time visitor sees: en, de, fr, it, es or tr.
      # Empty means en.
      DEFAULT_UI_LANGUAGE: ${DEFAULT_UI_LANGUAGE:-}
      # "off" disables the six-hourly request to openplate.de for the newest version
      # and the project's daily count of asks. Empty means on.
      UPDATE_CHECK: ${UPDATE_CHECK:-}
      # Closes this instance: an https:// address where its people went.
      # Every page then names it. Empty means open as usual.
      MOVED_TO_URL: ${MOVED_TO_URL:-}
      # Extra origins the browser may call, space separated. Empty adds nothing.
      CSP_CONNECT_EXTRA: ${CSP_CONNECT_EXTRA:-}
      # debug, info, warn or error, for the inference service as well.
      LOG_LEVEL: ${LOG_LEVEL:-info}
      # Which published reference values the Nutrients screen quotes: dge (the
      # default), efsa or us.
      NUTRIENT_REFERENCE_BASIS: ${NUTRIENT_REFERENCE_BASIS:-dge}
      # Matomo analytics, off unless the first two are set together. The level
      # is pageviews, product (the default when empty) or research, and only
      # with the pair: a level on its own stops the boot.
      MATOMO_URL: ${MATOMO_URL:-}
      MATOMO_SITE_ID: ${MATOMO_SITE_ID:-}
      MATOMO_EVENT_LEVEL: ${MATOMO_EVENT_LEVEL:-}
      # A newsletter form on the landing page, off unless both are set.
      NEWSLETTER_SUBSCRIBE_URL: ${NEWSLETTER_SUBSCRIBE_URL:-}
      NEWSLETTER_TURNSTILE_SITE_KEY: ${NEWSLETTER_TURNSTILE_SITE_KEY:-}
      # The folder of legal pages, mounted read-only. Set it to the container
      # path of the volume line above. Empty means no legal pages.
      CONTENT_DIR: ${CONTENT_DIR:-}
      # The address the server binds to inside the container. Leave it empty:
      # the published port reaches only a server on every interface.
      HOST: ${HOST:-}
    healthcheck:
      # A shell line with no quotes and no brackets, run by the image's busybox
      # wget, so Docker Compose, podman-compose and Quadlet all run it alike.
      test: ['CMD-SHELL', 'wget -q -O /dev/null http://127.0.0.1:3000/healthcheck']
      interval: 30s
      timeout: 5s
      start_period: 30s
      retries: 3

volumes:
  inference-models:
    driver: local
Outil de conteneurs
mkdir -p ~/openplate && cd ~/openplate
curl -O https://raw.githubusercontent.com/LowCarbCheck/openplate/main/docker/topologies/compose.inference.yml
echo "INFERENCE_API_KEY=opk_$(openssl rand -hex 24)" >> .env
echo "PUBLIC_APP_URL=http://192.168.1.20:3000" >> .env
echo "PUBLIC_INFERENCE_URL=http://192.168.1.20:8300/v1" >> .env
echo "TRUST_PROXY=0" >> .env  # 0 with no reverse proxy, 1 behind one
docker compose -f compose.inference.yml up -d

Remplace 192.168.1.20 par l'adresse de ton serveur. Dès que l'application est en HTTPS derrière un proxy inverse, l'adresse d'inférence doit aussi utiliser https://, et TRUST_PROXY doit être défini sur 1. self-hosting.md détaille la procédure.

Ce niveau s'adresse à deux types de profils :

  • Tu possèdes le matériel. Une machine avec GPU, ou une machine avec CPU raisonnablement puissant.
  • Tu fais déjà tourner un moteur d'exécution de modèles. Si tu fais déjà tourner llama.cpp, Ollama ou vLLM sur GPU, définis MODEL_PROFILE=external et MODEL_RUNTIME_URL : openplate-inference ne télécharge alors rien, ne démarre pas de second modèle et se contente d'encapsuler ce que tu as déjà. Vérifie d'abord la matrice de compatibilité ; la version CPU de vLLM ne peut pas faire tourner cela.

Rigueur matérielle. Le petit profil lite représente 2,0 Gio de poids et nécessite 8 cœurs modernes ou plus avec AVX2 et 4 Go de RAM disponible sur une machine sans GPU ; le profil quality, plus lourd, représente 5,8 Gio de poids et un plancher de 5,8 Gio de VRAM. Les analyses sur CPU prennent de quelques secondes à quelques minutes, et le débit n'augmente pas avec la concurrence : dimensionne tes ressources comme si les requêtes étaient traitées en série. Les mesures réelles, profil par profil, sont dans docs/hardware.md de openplate-inference. Lis ce document avant d'acheter quoi que ce soit.

Une fois en service, tu peux soit donner une clé à chaque personne (Paramètres → IA → Compatible OpenAI), soit configurer DEFAULT_INFERENCE_BASE_URL et les variables associées pour que chaque visiteur se connecte en un clic, à la réserve près que DEFAULT_INFERENCE_API_KEY est intégré dans la page et lisible par quiconque peut ouvrir l'application. Voir configuration.md.

Le serveur central et l'inférence sont des couches distinctes

On les confond facilement et elles se combinent.

  • openplate-inference constitue la couche de calcul. Il répond à la question qu'y a-t-il dans cette assiette. Il embarque un moteur d'exécution de modèles ainsi que les poids, et il a besoin de matériel.
  • openplate-core, sur une instance gérée, forme la couche de gestion des accès. Il répond qui a le droit de dépenser, combien, et comment révoquer cet accès. Il n'embarque aucun modèle et relaie tout.

En faisant pointer le proxy IA d'une instance gérée vers ta machine d'inférence (UPSTREAM_BASE_URL de openplate-core, avec l'une des API_KEYS du service d'inférence comme UPSTREAM_API_KEY), tu obtiens les deux : des analyses sur ton propre matériel, précédées de quotas par compte. En le dirigeant plutôt vers un fournisseur cloud, tu obtiens des dépenses partagées sans matériel supplémentaire. Dans les deux cas, ce même serveur central achemine aussi le journal : la synchronisation et le proxy IA forment désormais un seul service, et non plus deux (architecture.md).

Tout faire tourner

Le niveau 4 réunit les deux niveaux précédents. Rien de nouveau n'y apparaît.

Le niveau quatre combine les niveaux deux et trois : un seul journal sur chaque appareil et des analyses sur ton propre matériel.
Source du schéma
flowchart LR
  app["openplate app"] -->|"HTML and JS"| phone["Phone"]
  app -->|"HTML and JS"| laptop["Laptop"]
  phone -->|"ciphertext"| sync["openplate-core"]
  laptop -->|"ciphertext"| sync
  sync --> db[("Postgres")]
  phone -->|"photo"| inf["openplate-inference"]
  laptop -->|"photo"| inf

Tu obtiens : les échelons 2 et 3 réunis (ton journal sur chaque appareil, analysé sur ton propre matériel, sans rien envoyer à aucun tiers). Tu gères : la totalité. L'application, le serveur central, Postgres, le moteur d'inférence, et des adresses accessibles par navigateur pour deux d'entre eux. Fichier Compose : docker/topologies/compose.full.yml. Son en-tête liste les lignes .env : celles des échelons 2 et 3 combinés.

docker/topologies/compose.full.yml

Publié dans la version 0.66.0

Ce qui démarre

  • Base de données postgres

    docker.io/library/postgres:18-alpine

    Aucun port sur cette machine · Volume : pg-data-18

  • Moteur d'inférence inference

    ghcr.io/lowcarbcheck/openplate-inference:latest

    Port 8300 sur cette machine · Volume : inference-models

  • L'application app

    ghcr.io/lowcarbcheck/openplate:latest

    Port 3000 sur cette machine · Aucun volume · Démarre après inference

  • Serveur central core

    ghcr.io/lowcarbcheck/openplate-core:latest

    Port 3001 sur cette machine, pour l'API de synchronisation et les commandes d'administration · Aucun volume · Démarre après postgres

latest suit la version la plus récente. Pour figer une version, remplace latest par son numéro.

Les données se trouvent dans ces volumes : pg-data-18, inference-models. down les conserve, et down -v les supprime.

Contenu du fichier .env

Son en-tête demande ces lignes :

  • SERVER_SECRETrequis

    Transmis à : core → SERVER_SECRET

  • ADMIN_TOKENVide par défaut

    Transmis à : core → ADMIN_TOKEN

  • INFERENCE_API_KEYValeur par défaut : opk_CHANGE_ME

    Transmis à : inference → API_KEYS, app → DEFAULT_INFERENCE_API_KEY

  • PUBLIC_APP_URLValeur par défaut : http://localhost:3000

    Transmis à : app → APP_URL, core → CLIENT_BASE_URL

  • PUBLIC_SYNC_URLValeur par défaut : http://localhost:3001

    Transmis à : app → CORE_URL, core → SERVER_PUBLIC_URL

  • PUBLIC_INFERENCE_URLValeur par défaut : http://openplate.example.lan:8300/v1

    Transmis à : app → DEFAULT_INFERENCE_BASE_URL

  • TRUST_PROXYValeur par défaut : 1

    Transmis à : app → TRUST_PROXY, core → TRUST_PROXY

Ces lignes définissent comment le joindre :

  • INFERENCE_PORTValeur par défaut : 8300

    Modifie le port publié pour inference

  • APP_PORTValeur par défaut : 3000

    Modifie le port publié pour app

  • SYNC_PORTValeur par défaut : 3001

    Modifie le port publié pour core

Derrière un proxy inverse, garde TRUST_PROXY à 1. Sans proxy, passe-le à 0.

Il lit au total 124 paramètres depuis .env. Le fichier indique la valeur par défaut de chaque paramètre facultatif. Explications pour chaque paramètre

Commandes

Démarrer
docker compose -f compose.full.yml up -d
Mettre à jour
docker compose -f compose.full.yml pull docker compose -f compose.full.yml up -d
Suivre les journaux
docker compose -f compose.full.yml logs -f
Arrêter
docker compose -f compose.full.yml down

Ouvre http://localhost:3000 sur la machine qui l'exécute.

Les téléphones et les autres appareils ont besoin de HTTPS. Le guide d'Auto-hébergement montre comment le configurer, même sans nom de domaine.

Pour Podman, lance podman compose au lieu de docker compose.

Afficher tout le fichier (600 lignes)
yaml
# openplate, everything at once: app + sync + Postgres + your own AI.
#
# Four containers: the stateless app, the optional core server (openplate-core,
# accounts and diary sync), the Postgres that sync, and only sync, needs, and a
# self-hosted plate-identification endpoint (openplate-inference). The app
# itself still keeps no database at all. Every image is open source under the
# MIT License and is published to GHCR; nothing here builds from source.
#
# This is the largest shape, and you now operate all four. If you only want one
# of the two extras, take the smaller file instead: `compose.core.yml` for sync,
# `compose.inference.yml` for the AI. `../compose.yml` is the app alone.
#
#   mkdir -p ~/openplate && cd ~/openplate
#   curl -O https://raw.githubusercontent.com/LowCarbCheck/openplate/main/docker/topologies/compose.full.yml
#
#   # The core server needs exactly one secret. Generate it once and keep it
#   # with your database backups, see the SERVER_SECRET note below.
#   echo "SERVER_SECRET=$(openssl rand -hex 32)" >> .env
#
#   # Your key to the admin API, which is how you create the first account.
#   echo "ADMIN_TOKEN=$(openssl rand -hex 32)" >> .env
#
#   # One key for the inference service, which the app hands to browsers.
#   echo "INFERENCE_API_KEY=opk_$(openssl rand -hex 24)" >> .env
#
#   # The three URLs a BROWSER will use to reach each service. PUBLIC_APP_URL
#   # and PUBLIC_SYNC_URL default to localhost, so skip both for a trial on
#   # this machine. PUBLIC_INFERENCE_URL has no such default: set it even for
#   # a local trial, for example to http://localhost:8300/v1.
#   echo "PUBLIC_APP_URL=https://openplate.example.com"      >> .env
#   echo "PUBLIC_SYNC_URL=https://sync.example.com"          >> .env
#   echo "PUBLIC_INFERENCE_URL=https://ai.example.com/v1"    >> .env
#
#   # 1 behind one reverse proxy, 0 with none.
#   echo "TRUST_PROXY=1" >> .env
#
#   docker compose -f compose.full.yml up -d
#
# Keep this file in a folder that lasts, like ~/openplate above, and run all of
# that from there. Compose treats the compose file's OWN directory as the
# project directory, so the `.env` you just wrote, sitting beside this file, is
# the one it reads. Compose passes on only the variables named below.
#
# Signing in needs a secure page: https://, or http://localhost on the machine
# you are sitting at. Over plain http://<LAN address> the sign-in, the sign-up
# and the invite link all fail. See the HTTPS section of apps/app/docs/self-hosting.md.
#
# Then create the first account with an invitation to yourself, minted on
# THIS machine with ADMIN_TOKEN (apps/app/docs/self-hosting.md has the curl command).
# Open the link it returns, choose a password, and the devices you sign in on
# converge. What the sync operator holds is explained in apps/app/docs/sync.md.
#
# "README" in the inference block below always means openplate-inference's
# README: https://github.com/LowCarbCheck/openplate/tree/main/apps/inference
#
# ── THE ONE THING PEOPLE GET WRONG ─────────────────────────────────────────
# `DEFAULT_INFERENCE_BASE_URL` must be a URL a BROWSER on the user's phone or
# laptop can open. The photo goes from the device straight to the inference
# endpoint; openplate's server is never in the loop, which is what keeps the
# scan private. So `http://inference:8300/v1` (the container hostname) does NOT
# work, even though the two containers can talk to each other that way. Use the
# LAN address of this host, or a hostname on your reverse proxy / tailnet.
#
# Fixes the project name, so containers and the two volumes are named after the
# stack rather than after whatever directory the file sits in. Distinct from the
# smaller topologies' names, so two stacks never collide on one host.
name: openplate-full

services:
  # ── Postgres ──────────────────────────────────────────────────────────────
  # Belongs to the core server alone: it holds sync's accounts and the
  # opaque ciphertext blobs. Neither the app nor the inference service connects
  # to it, and the app has no database of its own
  # (apps/app/.adr/0006-the-app-server-holds-no-accounts.md).
  # Postgres 18. The volume is `pg-data-18` on purpose. The 18 image keeps its
  # cluster in /var/lib/postgresql/18/docker and the volume mounts one level up,
  # at /var/lib/postgresql. It refuses a volume that holds a 17 cluster, so the
  # old `pg-data` volume cannot be reused. It stays untouched as your rollback.
  # An install that ran Postgres 17 follows "Postgres 18 upgrade" in
  # docker/topologies/README.md: dump, start, restore.
  postgres:
    image: docker.io/library/postgres:18-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-openplate}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-openplate}
      POSTGRES_DB: ${SYNC_DB_NAME:-openplate_sync}
    volumes:
      - pg-data-18:/var/lib/postgresql
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER:-openplate} -d ${SYNC_DB_NAME:-openplate_sync}']
      interval: 5s
      timeout: 5s
      retries: 10
    # Deliberately not published to the host: the core server reaches Postgres
    # over the compose network. Add a `ports:` mapping only if you need psql
    # from outside, and bind it to 127.0.0.1 if you do.
    expose:
      - '5432'

  # ── The inference service ─────────────────────────────────────────────────
  # A self-hosted, OpenAI-compatible plate-photo endpoint. Users of this
  # instance tap ONE button to use it: no provider account, no API key of
  # their own, no photo leaving your network.
  inference:
    image: ghcr.io/lowcarbcheck/openplate-inference:latest
    restart: unless-stopped
    ports:
      # Published because the browser calls it directly. Bind to 0.0.0.0 (as
      # here) for LAN access; use "127.0.0.1:8300:8300" if a reverse proxy on
      # this host is the only thing that should reach it.
      - '${INFERENCE_PORT:-8300}:8300'
    volumes:
      # Weights land here on first boot (~2.0 GiB for lite, ~5.8 GiB for
      # quality) and are verified by sha256 on every start. Named, so
      # `docker compose down` does not throw the download away.
      - inference-models:/models
    environment:
      # lite | lite-apache | quality, see README "Hardware & measured latency".
      # external runs no model here and uses your runtime, see below.
      MODEL_PROFILE: ${MODEL_PROFILE:-lite}
      # The key callers must present. Set INFERENCE_API_KEY in .env (see the
      # top of this file); the placeholder below only keeps a first trial
      # booting. It must match DEFAULT_INFERENCE_API_KEY on the app.
      API_KEYS: ${INFERENCE_API_KEY:-opk_CHANGE_ME}
      # Self-host has no latency ceiling. 0 = never shed load for being slow.
      LATENCY_CEILING_MS: ${LATENCY_CEILING_MS:-0}
      # Scans in flight at once. It also sets llama.cpp's slot count; it does
      # NOT add CPU threads, the slots share LLAMA_THREADS.
      CONCURRENCY: ${CONCURRENCY:-2}
      # CPU threads for the model. Empty means every core but two (nproc - 2),
      # which leaves room for the service and the OS.
      LLAMA_THREADS: ${LLAMA_THREADS:-}
      # Where macros come from. fdc = the bundled offline USDA-derived dataset.
      # See README "Food data" before switching to `off` (ODbL) or `lcc`.
      FOOD_SOURCE: ${FOOD_SOURCE:-fdc}

      # ── Everything else the service reads. Empty means the default, and
      # openplate-inference's .env.example explains each one.
      #
      # Your own runtime, with MODEL_PROFILE=external (see below). No trailing
      # /v1, and the address must resolve from INSIDE this container.
      MODEL_RUNTIME_URL: ${MODEL_RUNTIME_URL:-}
      MODEL_RUNTIME_API_KEY: ${MODEL_RUNTIME_API_KEY:-}
      # The model id sent to the runtime. Empty means openplate-plate-1. vLLM
      # needs its exact served model name.
      MODEL_ID: ${MODEL_ID:-}
      # The waiting line, the bound on one completion call, the requests per
      # key per minute, the largest decoded image, and the downscale target.
      MAX_QUEUE_DEPTH: ${MAX_QUEUE_DEPTH:-8}
      RUNTIME_COMPLETION_TIMEOUT_MS: ${RUNTIME_COMPLETION_TIMEOUT_MS:-600000}
      RATE_LIMIT_RPM: ${RATE_LIMIT_RPM:-60}
      MAX_IMAGE_BYTES: ${MAX_IMAGE_BYTES:-8388608}
      IMAGE_MAX_LONG_EDGE: ${IMAGE_MAX_LONG_EDGE:-896}
      # debug, info, warn or error.
      LOG_LEVEL: ${LOG_LEVEL:-info}
      # What the service reports as its profile. Empty follows MODEL_PROFILE.
      PROFILE: ${PROFILE:-}
      # Each is read only by its own FOOD_SOURCE. Empty FDC_DATASET_PATH is the
      # bundled extract. Empty URLs are https://lowcarbcheck.org for lcc and
      # https://world.openfoodfacts.org for off.
      FDC_DATASET_PATH: ${FDC_DATASET_PATH:-}
      LCC_API_URL: ${LCC_API_URL:-}
      LCC_API_KEY: ${LCC_API_KEY:-}
      OFF_API_URL: ${OFF_API_URL:-}
      # A second runtime serving /v1/embeddings, for hybrid retrieval. Empty
      # means lexical retrieval only.
      EMBEDDING_RUNTIME_URL: ${EMBEDDING_RUNTIME_URL:-}
      EMBEDDING_RUNTIME_API_KEY: ${EMBEDDING_RUNTIME_API_KEY:-}
      # The bundled llama-server: its loopback port, the context per slot, the
      # layers put on the GPU (empty means detect), and extra flags passed on
      # as written.
      RUNTIME_PORT: ${RUNTIME_PORT:-8080}
      CONTEXT_SIZE: ${CONTEXT_SIZE:-8192}
      GPU_LAYERS: ${GPU_LAYERS:-}
      LLAMA_EXTRA_ARGS: ${LLAMA_EXTRA_ARGS:-}
      # A mirror tried before Hugging Face for the first weight download.
      WEIGHTS_MIRROR_BASE: ${WEIGHTS_MIRROR_BASE:-}
    # ── GPU (the `quality` profile): uncomment BOTH of these and switch the
    # image to the -cuda tag. The entrypoint detects the GPU and offloads every
    # layer automatically; there is no flag to set.
    # deploy:
    #   resources:
    #     reservations:
    #       devices:
    #         - driver: nvidia
    #           count: all
    #           capabilities: [gpu]
    #
    # ── ALREADY RUNNING vLLM / llama.cpp / OLLAMA? ────────────────────────
    # Set these in `.env` and this container downloads no weights and starts
    # no second model; it just turns your runtime into a plate scanner. You can
    # drop the `volumes:` block and the `inference-models` volume entirely.
    #
    # Read README "Bring your own runtime" FIRST: your runtime must enforce
    # grammar-constrained decoding, and there is a one-line curl there that
    # tells you whether yours does. vLLM's CPU build does NOT (it crashes).
    #
    #   MODEL_PROFILE=external
    #   # Must resolve from INSIDE this container, and no trailing /v1.
    #   # `localhost` here means this container, not your host. Use the LAN
    #   # address, or host.docker.internal on Docker Desktop.
    #   MODEL_RUNTIME_URL=http://your-runtime.lan:8000
    #   # vLLM requires an EXACT match with its served model name.
    #   MODEL_ID=your-served-model-name
    #   # Only if your runtime is behind auth (`vllm serve --api-key ...`).
    #   # Separate from INFERENCE_API_KEY, which callers present to THIS service.
    #   MODEL_RUNTIME_API_KEY=sk_your_runtime_key
    #   # Match your runtime's real slot count:
    #   #   llama.cpp --parallel N | vLLM --max-num-seqs N | OLLAMA_NUM_PARALLEL
    #   CONCURRENCY=2
    #
    # REQUIRED with external mode, and the one edit to this file it needs. The
    # image bakes in a 60-minute health start_period, sized for a first-boot
    # weight download. External mode has no download, so without this override
    # a wrong MODEL_RUNTIME_URL stays hidden for an hour instead of surfacing
    # in seconds.
    # healthcheck:
    #   start_period: 30s

  # ── The app ───────────────────────────────────────────────────────────────
  # Stateless. No accounts, no personal data, no database: your diary lives in
  # the browser. There is no secret to configure here; that is the design,
  # not an omission (see apps/app/.adr/0006-the-app-server-holds-no-accounts.md).
  app:
    image: ghcr.io/lowcarbcheck/openplate:latest
    restart: unless-stopped
    depends_on:
      - inference
    ports:
      # Published on EVERY network interface. Behind a reverse proxy on this
      # machine, write '127.0.0.1:3000:3000' so only the proxy can reach it.
      - '${APP_PORT:-3000}:3000'
    # To serve legal pages, uncomment this and set CONTENT_DIR in `.env`:
    #   CONTENT_DIR=/srv/openplate/content
    # volumes:
    #   - ./content:/srv/openplate/content:ro
    environment:
      NODE_ENV: production
      PORT: 3000

      # The URL a browser uses to reach THIS app: PUBLIC_APP_URL in .env.
      # Behind a reverse proxy, that is the public https:// address, not the
      # container port.
      APP_URL: ${PUBLIC_APP_URL:-http://localhost:3000}

      # The URL a BROWSER uses to reach the core server, not `http://core:3000`.
      # The sync client runs in the page, so this address has to resolve from
      # your users' devices. Setting it is what makes the sync interface exist
      # at all; remove this line and the app is a pure local tracker again.
      # The origin is added to the app's Content-Security-Policy automatically.
      CORE_URL: ${PUBLIC_SYNC_URL:-http://localhost:3001}
      SYNC_SERVER_URL: ${SYNC_SERVER_URL:-}

      # PUBLIC_INFERENCE_URL in .env: a BROWSER-reachable address for the
      # inference container. NOT http://inference:8300. Note the /v1 suffix.
      # This is what turns into openplate's one-tap "This openplate provides
      # its own AI" card. Behind HTTPS it must be https:// too, or the browser
      # blocks the call from the secure page.
      DEFAULT_INFERENCE_BASE_URL: ${PUBLIC_INFERENCE_URL:-http://openplate.example.lan:8300/v1}
      # The same INFERENCE_API_KEY as API_KEYS above.
      #
      # ! THIS KEY IS PUBLIC. It is embedded in the HTML every browser loads, so
      #   anyone who can open your openplate can read it with view-source. That
      #   is fine for a household or a tailnet. It is NOT fine on an instance
      #   open to the internet without a VPN or auth proxy in front of it; in
      #   that case leave this unset and let people paste the key themselves.
      DEFAULT_INFERENCE_API_KEY: ${INFERENCE_API_KEY:-opk_CHANGE_ME}
      DEFAULT_INFERENCE_MODEL: ${DEFAULT_INFERENCE_MODEL:-openplate-plate-1}

      # `open` (the default) or `managed`. See apps/app/docs/configuration.md, Managed
      # instances, and the AI proxy block on the core server below.
      INSTANCE_MODE: ${INSTANCE_MODE:-open}

      # How many reverse proxies stand in front of the app AND the core server.
      # One value for both. With one proxy set TRUST_PROXY=1: the app's CSRF
      # check needs the proxy's X-Forwarded-* headers or form posts fail. With
      # NO proxy set TRUST_PROXY=0: 1 would let any visitor fake their address
      # in X-Forwarded-For and dodge the per-address limits. The app's default
      # of 1 assumes a proxy.
      TRUST_PROXY: ${TRUST_PROXY:-1}

      # ON by default. Queries the public LowCarbCheck food database for
      # curated nutrition data (food NAMES only, never photos; fails open on
      # outages). An EMPTY string disables it entirely so no food names ever
      # leave your machine.
      FOOD_DB_API_URL: ${FOOD_DB_API_URL-https://lowcarbcheck.org}
      # Optional free key for that database. Empty is the shared anonymous
      # allowance; set one if more than one person scans on this instance.
      FOOD_DB_API_KEY: ${FOOD_DB_API_KEY:-}
      # "true" passes foods people save from an AI answer on to LowCarbCheck as
      # proposals. Needs FOOD_DB_API_KEY. Empty means off.
      FOOD_DB_BACKFILL: ${FOOD_DB_BACKFILL:-}
      # The most LowCarbCheck calls this server makes in one UTC day. Empty means
      # the default, 3200.
      FOOD_DB_DAILY_CALL_LIMIT: ${FOOD_DB_DAILY_CALL_LIMIT:-}
      # The language a first-time visitor sees: en, de, fr, it, es or tr.
      # Empty means en.
      DEFAULT_UI_LANGUAGE: ${DEFAULT_UI_LANGUAGE:-}
      # "off" disables the six-hourly request to openplate.de for the newest version
      # and the project's daily count of asks. Empty means on.
      UPDATE_CHECK: ${UPDATE_CHECK:-}
      # Closes this instance: an https:// address where its people went.
      # Every page then names it. Empty means open as usual.
      MOVED_TO_URL: ${MOVED_TO_URL:-}
      # Extra origins the browser may call, space separated. Empty adds nothing.
      CSP_CONNECT_EXTRA: ${CSP_CONNECT_EXTRA:-}

      # debug, info, warn or error, for the sync and inference services too.
      LOG_LEVEL: ${LOG_LEVEL:-info}

      # Which published reference values the Nutrients screen quotes: dge (the
      # default), efsa or us.
      NUTRIENT_REFERENCE_BASIS: ${NUTRIENT_REFERENCE_BASIS:-dge}
      # Matomo analytics, off unless the first two are set together. The level
      # is pageviews, product (the default when empty) or research, and only
      # with the pair: a level on its own stops the boot.
      MATOMO_URL: ${MATOMO_URL:-}
      MATOMO_SITE_ID: ${MATOMO_SITE_ID:-}
      MATOMO_EVENT_LEVEL: ${MATOMO_EVENT_LEVEL:-}
      # A newsletter form on the landing page, off unless both are set.
      NEWSLETTER_SUBSCRIBE_URL: ${NEWSLETTER_SUBSCRIBE_URL:-}
      NEWSLETTER_TURNSTILE_SITE_KEY: ${NEWSLETTER_TURNSTILE_SITE_KEY:-}
      # The folder of legal pages, mounted read-only. Set it to the container
      # path of the volume line above. Empty means no legal pages.
      CONTENT_DIR: ${CONTENT_DIR:-}
      # The address the server binds to inside the container. Leave it empty:
      # the published port reaches only a server on every interface.
      HOST: ${HOST:-}
    healthcheck:
      # A shell line with no quotes and no brackets, run by the image's busybox
      # wget, so Docker Compose, podman-compose and Quadlet all run it alike.
      test: ['CMD-SHELL', 'wget -q -O /dev/null http://127.0.0.1:3000/healthcheck']
      interval: 30s
      timeout: 5s
      start_period: 30s
      retries: 3

  # ── The core server ──────────────────────────────────────────────────────
  # An account service that stores an email address and opaque ciphertext,
  # plus each account's recovery code, sealed under SERVER_SECRET, so that a
  # password reset brings the diary back. apps/app/docs/sync.md states what that means
  # for whoever runs this service.
  core:
    image: ghcr.io/lowcarbcheck/openplate-core:latest
    restart: unless-stopped
    healthcheck:
      # The image bakes a check in, but Podman drops a HEALTHCHECK when it
      # pulls an OCI manifest, which is what GHCR serves. Declared here it
      # holds under both engines and Quadlet turns it into Notify=healthy.
      test: ['CMD-SHELL', 'wget -q -O /dev/null http://127.0.0.1:3000/health']
      interval: 30s
      timeout: 5s
      start_period: 20s
      retries: 3
    depends_on:
      postgres:
        condition: service_healthy
    ports:
      # Published on EVERY network interface, like the app. Behind a reverse
      # proxy on this machine, write '127.0.0.1:3001:3000'.
      - '${SYNC_PORT:-3001}:3000'
    # Uncomment what you use, and set the matching variable in `.env`:
    #   CONTENT_DIR=/srv/openplate/content    (mount the same folder on the app)
    #   NODE_EXTRA_CA_CERTS=/etc/openplate/ca.pem
    # volumes:
    #   - ./content:/srv/openplate/content:ro
    #   - ./ca.pem:/etc/openplate/ca.pem:ro
    environment:
      PORT: 3000
      DATABASE_URL: postgres://${POSTGRES_USER:-openplate}:${POSTGRES_PASSWORD:-openplate}@postgres:5432/${SYNC_DB_NAME:-openplate_sync}

      # THE one secret in this file. Three subkeys are derived from it: the
      # pepper mixed into every stored authentication verifier, the key behind
      # the anti-enumeration KDF responses, and the key that seals each
      # account's recovery code.
      #
      # Back it up WITH the database. A restored database with a lost secret
      # is a database nobody can log into, and no password reset works either.
      # Changing it has the same effect as losing it.
      SERVER_SECRET: ${SERVER_SECRET:?generate one with `openssl rand -hex 32` and put it in .env}

      # Your key to the admin API at /v1/admin: minting invitations, handing out
      # password-reset links, listing and removing accounts. Empty turns that
      # API off unless an account with the admin role exists. At least 24
      # characters: generate it with `openssl rand -hex 32`, never choose it.
      ADMIN_TOKEN: ${ADMIN_TOKEN:-}

      # The two halves of every invitation and reset link, taken from the same
      # PUBLIC_* values the app uses, so you set each address once. A link
      # reads PUBLIC_APP_URL/join#server=PUBLIC_SYNC_URL&invite=...
      SERVER_PUBLIC_URL: ${PUBLIC_SYNC_URL:-http://localhost:3001}
      CLIENT_BASE_URL: ${PUBLIC_APP_URL:-http://localhost:3000}

      # Signup is invite-only unless OPEN_SIGNUP is set below: an account is
      # created by redeeming an invitation addressed to one email address.
      # SIGNUP_MODE and the older SIGNUPS_OPEN are both boot failures in
      # openplate-core, so neither is forwarded here.

      # The same TRUST_PROXY as the app above: the number of reverse proxies in
      # front of this service. Left at 0 behind a proxy, every request looks
      # like it comes from the proxy and the per-address throttle becomes one
      # bucket a single attacker can lock for all your users. Set above 0 with
      # nothing in front, anyone can fake X-Forwarded-For and skip the throttle.
      TRUST_PROXY: ${TRUST_PROXY:-0}

      # debug, info, warn or error. Empty is refused, so the default stays.
      LOG_LEVEL: ${LOG_LEVEL:-info}

      # What the instance calls itself on the /health handshake and in its
      # start-up log, and which language its letters are written in when a
      # request names none (en, de, fr, it, es or tr). Empty means openplate, en.
      INSTANCE_NAME: ${INSTANCE_NAME:-}
      INSTANCE_LANGUAGE: ${INSTANCE_LANGUAGE:-}

      # ── Mail (optional): one transport, or none ──
      # When set, this service mails the invitation and the password reset
      # itself. When empty, it sends nothing. The admin API hands the
      # invitation link and the reset link to you, and you pass them on.
      # "Forgot password" in the app reaches nobody. See
      # apps/app/docs/self-hosting.md for what to do instead. With mail on,
      # PUBLIC_APP_URL and PUBLIC_SYNC_URL must be https addresses, or the
      # service refuses to start.
      #
      # Any Resend-compatible HTTP mail API. It takes a POST of JSON with a
      # Bearer token. Set all three:
      MAIL_API_URL: ${MAIL_API_URL:-}
      MAIL_API_KEY: ${MAIL_API_KEY:-}
      MAIL_API_FROM: ${MAIL_API_FROM:-}
      # Or SMTP, never both. SMTP_PORT defaults to 587 when empty. Port 465
      # uses TLS from the start. Every other port must upgrade with STARTTLS.
      # SMTP_USER and SMTP_PASSWORD go together. For Gmail, use an app
      # password on smtp.gmail.com.
      SMTP_HOST: ${SMTP_HOST:-}
      SMTP_PORT: ${SMTP_PORT:-}
      SMTP_USER: ${SMTP_USER:-}
      SMTP_PASSWORD: ${SMTP_PASSWORD:-}
      SMTP_FROM: ${SMTP_FROM:-}
      # Who receives the operator's copy of a cancellation or a withdrawal.
      # Either transport requires it.
      MAIL_OPERATOR_EMAIL: ${MAIL_OPERATOR_EMAIL:-}

      # ── The AI proxy (optional, for INSTANCE_MODE=managed) ──
      # The provider every signed-in scan is forwarded to, and its key. Both or
      # neither. Empty means this instance offers no AI of its own.
      UPSTREAM_BASE_URL: ${UPSTREAM_BASE_URL:-}
      UPSTREAM_API_KEY: ${UPSTREAM_API_KEY:-}
      # OpenRouter only, both optional: zero data retention endpoints, and a pin
      # to named providers with no fallback. Empty is the proxy's old behaviour.
      UPSTREAM_ZDR: ${UPSTREAM_ZDR:-}
      UPSTREAM_PROVIDER_ONLY: ${UPSTREAM_PROVIDER_ONLY:-}
      # Which file decides the model, the zero retention routing and the output
      # cap of each kind of request: empty (the default) keeps AI_ADVERTISED_MODEL
      # and the two settings above as the whole answer, `bundled` is the file in
      # the image, or an absolute path to a file you mount.
      AI_TIERS_FILE: ${AI_TIERS_FILE:-}
      # The model every proxied request is sent to. The app scans with the
      # model this names, so a managed instance with AI needs it set. With a
      # tier file it replaces the default tier's model (an emergency override).
      AI_ADVERTISED_MODEL: ${AI_ADVERTISED_MODEL:-}
      # The whole instance's AI requests per UTC day. Empty means no ceiling.
      AI_INSTANCE_DAILY_LIMIT: ${AI_INSTANCE_DAILY_LIMIT:-}
      # On an OpenRouter key: mail MAIL_OPERATOR_EMAIL once per reset period
      # when less than this share of the key's limit is left. Empty means 0.2.
      AI_BUDGET_ALERT_FRACTION: ${AI_BUDGET_ALERT_FRACTION:-}
      # How long one proxied request may take, the most output tokens it may
      # ask for, the requests per account per minute, and the largest request
      # body, sized for a camera photograph after base64.
      UPSTREAM_TIMEOUT_MS: ${UPSTREAM_TIMEOUT_MS:-120000}
      AI_MAX_OUTPUT_TOKENS: ${AI_MAX_OUTPUT_TOKENS:-8192}
      AI_RATE_LIMIT_PER_MINUTE: ${AI_RATE_LIMIT_PER_MINUTE:-20}
      AI_MAX_REQUEST_BYTES: ${AI_MAX_REQUEST_BYTES:-8000000}
      # What one request may carry in (image parts, text bytes, messages),
      # the input tokens one unit of the daily counters covers, and the
      # tokens one image is counted at.
      AI_MAX_IMAGE_PARTS: ${AI_MAX_IMAGE_PARTS:-1}
      AI_MAX_TEXT_BYTES: ${AI_MAX_TEXT_BYTES:-49152}
      AI_MAX_MESSAGES: ${AI_MAX_MESSAGES:-4}
      AI_UNIT_INPUT_TOKENS: ${AI_UNIT_INPUT_TOKENS:-8192}
      AI_IMAGE_INPUT_TOKENS: ${AI_IMAGE_INPUT_TOKENS:-1500}

      # ── Members inviting people (optional) ──
      # The first two together or neither; the cap only with them. Empty means
      # only an administrator invites. See apps/app/docs/configuration.md, Member invites.
      MEMBER_INVITE_DAILY_AI_LIMIT: ${MEMBER_INVITE_DAILY_AI_LIMIT:-}
      MEMBER_INVITE_ALLOWANCE_DAYS: ${MEMBER_INVITE_ALLOWANCE_DAYS:-}
      MEMBER_INVITE_LIFETIME_CAP: ${MEMBER_INVITE_LIFETIME_CAP:-}

      # "true" lets a person share their diary with a clinician. Off by default.
      SYNC_SHARING: ${SYNC_SHARING:-false}
      # "true" opens the research console at /study, and makes this server
      # hold study data. Read openplate-core's .env.example first. Off by default.
      SYNC_RESEARCH: ${SYNC_RESEARCH:-false}

      # ── The operator notice (optional) ──
      # One short sentence /health publishes and the client shows, for the
      # things this service can no longer tell anyone: a move, a shutdown, a
      # maintenance window. Empty means no notice, and SYNC_NOTICE_URL
      # without SYNC_NOTICE is a boot failure.
      SYNC_NOTICE: ${SYNC_NOTICE:-}
      SYNC_NOTICE_URL: ${SYNC_NOTICE_URL:-}

      # ── Reported estimates (optional) ──
      # On, this service KEEPS the photograph and the figures a person reports,
      # readable, for its retention window. The two limits are per account per
      # UTC day, and per request. Read openplate-core's .env.example first.
      SYNC_FEEDBACK: ${SYNC_FEEDBACK:-false}
      FEEDBACK_DAILY_LIMIT: ${FEEDBACK_DAILY_LIMIT:-5}
      FEEDBACK_MAX_REQUEST_BYTES: ${FEEDBACK_MAX_REQUEST_BYTES:-8000000}

      # ── Open sign-up (optional) ──
      # Empty means invite-only. "true" needs the mail block above. The
      # Turnstile pair is both or neither, and only with OPEN_SIGNUP.
      OPEN_SIGNUP: ${OPEN_SIGNUP:-}
      TURNSTILE_SECRET_KEY: ${TURNSTILE_SECRET_KEY:-}
      TURNSTILE_SITE_KEY: ${TURNSTILE_SITE_KEY:-}

      # ── Free AI scans for new accounts (optional) ──
      # TRIAL_SCANS and TRIAL_DAILY_AI_LIMIT together or neither, and the
      # pepper with them. TRIAL_DAYS also ends the trial at midnight after that
      # many days, in TRIAL_TIME_ZONE (an IANA name, empty means UTC).
      # MEMBER_INVITE_TRIAL=true makes a member invitation grant the trial.
      # Empty means no trial.
      TRIAL_SCANS: ${TRIAL_SCANS:-}
      TRIAL_DAILY_AI_LIMIT: ${TRIAL_DAILY_AI_LIMIT:-}
      TRIAL_DAYS: ${TRIAL_DAYS:-}
      TRIAL_TIME_ZONE: ${TRIAL_TIME_ZONE:-}
      TRIAL_ADDRESS_PEPPER: ${TRIAL_ADDRESS_PEPPER:-}
      TRIAL_HASH_RETENTION_DAYS: ${TRIAL_HASH_RETENTION_DAYS:-}
      MEMBER_INVITE_TRIAL: ${MEMBER_INVITE_TRIAL:-}
      AI_TRIAL_INSTANCE_DAILY_LIMIT: ${AI_TRIAL_INSTANCE_DAILY_LIMIT:-}
      AI_TRIAL_NETWORK_DAILY_LIMIT: ${AI_TRIAL_NETWORK_DAILY_LIMIT:-}

      # ── A standing free daily AI limit (optional) ──
      # Requests per UTC day for every account with no free limit of its own,
      # no end date and no trial. Empty or 0 means off. It cannot stand
      # beside the trial above: the boot stops naming both.
      DEFAULT_FREE_DAILY_AI_LIMIT: ${DEFAULT_FREE_DAILY_AI_LIMIT:-}

      # ── AI feature permissions (optional) ──
      # DEFAULT_CAPABILITIES is what an account with no record of its own may
      # use: comma separated labels, or "none" for nothing. Empty means no
      # check at all. CAPABILITY_SCHEMA_MAP ties a structured-output schema
      # name to the label its use needs, as schemaName:label pairs.
      DEFAULT_CAPABILITIES: ${DEFAULT_CAPABILITIES:-}
      CAPABILITY_SCHEMA_MAP: ${CAPABILITY_SCHEMA_MAP:-}

      # ── Web push (optional) ──
      # All three or none. Empty means no notifications.
      VAPID_PUBLIC_KEY: ${VAPID_PUBLIC_KEY:-}
      VAPID_PRIVATE_KEY: ${VAPID_PRIVATE_KEY:-}
      VAPID_SUBJECT: ${VAPID_SUBJECT:-}
      PUSH_ENDPOINT_HOSTS: ${PUSH_ENDPOINT_HOSTS:-}

      # ── Paid plans (optional) ──
      # The URL and the secret together or neither, and only with a billing
      # service behind this instance. BILLING_TOKEN is that service's own
      # credential. Empty means no plans.
      PLANS_UPSTREAM_URL: ${PLANS_UPSTREAM_URL:-}
      PLANS_UPSTREAM_SECRET: ${PLANS_UPSTREAM_SECRET:-}
      BILLING_TOKEN: ${BILLING_TOKEN:-}
      BILLING_MAX_DAILY_AI_LIMIT: ${BILLING_MAX_DAILY_AI_LIMIT:-}

      # ── Everything else ──
      # Which body's reference values the Nutrients screen quotes (dge, efsa or
      # us), for the app above too. Only the boot default: an administrator
      # changes the live setting, and the stored one wins from then on.
      NUTRIENT_REFERENCE_BASIS: ${NUTRIENT_REFERENCE_BASIS:-dge}
      # The health-data consent every account must agree to, a short string
      # such as 2026-09-28. Empty asks for no consent.
      HEALTH_CONSENT_VERSION: ${HEALTH_CONSENT_VERSION:-}
      # The folder of letter texts, the same one the app above reads its legal
      # pages from. Set it to the container path of the commented volume line
      # above this environment block.
      CONTENT_DIR: ${CONTENT_DIR:-}
      # The daily ceilings on declaration receipts, for the instance and per
      # sender network. Read openplate-core's .env.example first.
      LEGAL_DECLARATION_RECEIPTS_PER_DAY: ${LEGAL_DECLARATION_RECEIPTS_PER_DAY:-200}
      LEGAL_DECLARATION_RECEIPTS_PER_NETWORK_PER_DAY: ${LEGAL_DECLARATION_RECEIPTS_PER_NETWORK_PER_DAY:-10}
      # A PEM file of extra certificate authorities Node trusts, for an SMTP
      # server with a private CA. The container path of the commented volume
      # line above this environment block.
      NODE_EXTRA_CA_CERTS: ${NODE_EXTRA_CA_CERTS:-}
      # The address the listener binds to inside the container. Leave it empty:
      # the published port reaches only a listener on every interface.
      HOST: ${HOST:-}
      # Only for an EXTERNAL database. The bundled Postgres speaks plain TCP on
      # the compose network.
      DATABASE_SSL: ${DATABASE_SSL:-false}

      # Every variable openplate-core reads is forwarded above, so a line in
      # `.env` is all it takes. If you set SIGNUP_MODE, SIGNUPS_OPEN,
      # EMAIL_FROM, SMTP_SECURE, any PIGEON_*, or REQUIRE_EMAIL_VERIFICATION,
      # you get a BOOT FAILURE, so none of them is forwarded.

volumes:
  pg-data-18:
    driver: local
  inference-models:
    driver: local

Podman lance ceci de la même manière : podman compose -f compose.full.yml up -d.

Il n'y a rien de nouveau à apprendre à ce niveau. C'est l'union des deux précédents, avec le même SERVER_SECRET, la même obligation de sauvegarde et le même plancher matériel.

Exécuter un seul serveur de manière autonome

Deux autres fichiers compose exécutent un seul serveur sans l'application : le serveur central avec sa base de données, et le moteur d'inférence. Utilise l'un d'eux lorsque cette partie tourne sur sa propre machine.

Le serveur central seul

apps/core/docker/compose.yml

Publié dans la version 0.36.0

Ce fichier compile core depuis un clone du dépôt. Clone le dépôt au lieu de télécharger ce fichier. L'en-tête indique comment le lancer.

Ce qui démarre

  • Base de données postgres

    docker.io/library/postgres:18-alpine

    Aucun port sur cette machine · Volume : postgres-data-18

  • Serveur central core

    Compilé depuis les sources, contexte .

    Port 3000 sur cette machine, pour l'API de synchronisation et les commandes d'administration · Aucun volume · Démarre après postgres

Les données se trouvent dans ces volumes : postgres-data-18. down les conserve, et down -v les supprime.

Contenu du fichier .env

Compose ne le démarrera pas sans ces lignes :

  • SERVER_SECRETrequis

    Transmis à : core → SERVER_SECRET

Ces lignes définissent comment le joindre :

  • TRUST_PROXYValeur par défaut : 0

    Transmis à : core → TRUST_PROXY

  • SYNC_PORTValeur par défaut : 3000

    Modifie le port publié pour core

Derrière un proxy inverse, garde TRUST_PROXY à 1. Sans proxy, passe-le à 0.

Il lit au total 79 paramètres depuis .env. Le fichier indique la valeur par défaut de chaque paramètre facultatif. Explications pour chaque paramètre

Afficher tout le fichier (264 lignes)
yaml
# Self-hoster quickstart: Postgres + the core server, nothing else.
#
# If you pulled the published image you can copy this one file anywhere and
# run `docker compose up -d` beside it. From a checkout, the file lives in
# `docker/`, so run it from the repository root like this:
#
#   cp .env.example .env
#   # edit .env, SERVER_SECRET is the only mandatory value
#   docker compose --project-directory . -f docker/compose.yml up -d
#
# `--project-directory .` is not decoration. Without it, Compose treats
# `docker/` as the project directory: it looks for `.env` there instead of at
# the repository root, and resolves `build: .` to `docker/` instead of to the
# checkout. With it, both point at the repository root, which is what the
# quickstart above assumes. (The project name is pinned below, so that part
# does not depend on where you run from.)
#
# An account is an EMAIL ADDRESS plus a passphrase, and it is created by
# redeeming an invite you addressed to somebody. Signup is invite-only,
# always. Mail is optional. If none is configured, an invite comes back as a
# link for you to paste instead of an email. SMTP_SECURE and the old
# PIGEON_* names cause a BOOT FAILURE, not a no-op. See .env.example.
#
#   docker compose --project-directory . -f docker/compose.yml logs -f core
#
# NOTE FOR CONTRIBUTORS: this file is for SELF-HOSTERS. Local development and
# the integration suite use the shared workspace Postgres (see
# `tests/integration/db-harness.ts`), never this database. If you are an
# outside contributor with no shared Postgres to point at, bring up
# `docker/compose.dev.yml` instead. It is a test database only, and it is the
# one thing in `docker/` a self-hoster can ignore entirely.

# Pin the Compose project name. Without it Compose names the project after
# this file's parent directory, "docker", and every container and volume
# inherits that.
name: openplate-core

services:
  # Postgres 18. The volume is `postgres-data-18` on purpose. The 18 image keeps
  # its cluster in /var/lib/postgresql/18/docker and the volume mounts one level
  # up, at /var/lib/postgresql. It refuses a volume that holds a 17 cluster, so
  # the old `postgres-data` volume cannot be reused. It stays untouched as your
  # rollback. An install that ran Postgres 17 follows "Postgres 18 upgrade" in
  # docker/topologies/README.md: dump, start, restore.
  postgres:
    image: docker.io/library/postgres:18-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-openplate}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-openplate}
      POSTGRES_DB: ${POSTGRES_DB:-openplate_sync}
    volumes:
      - postgres-data-18:/var/lib/postgresql
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER:-openplate} -d ${POSTGRES_DB:-openplate_sync}']
      interval: 5s
      timeout: 5s
      retries: 10
    # Not published by default: nothing outside this compose network has any
    # business reaching the database.
    expose:
      - '5432'

  core:
    build: .
    # Or pull the published image instead of building:
    # image: ghcr.io/lowcarbcheck/openplate-core:latest
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      # Fixed: the published mapping below targets container port 3000, so a
      # PORT set in .env would only move the listener away from it. Change the
      # host side with SYNC_PORT instead.
      PORT: 3000
      DATABASE_URL: postgres://${POSTGRES_USER:-openplate}:${POSTGRES_PASSWORD:-openplate}@postgres:5432/${POSTGRES_DB:-openplate_sync}
      SERVER_SECRET: ${SERVER_SECRET:?set SERVER_SECRET in .env, see .env.example}
      # Signup is invite-only unless OPEN_SIGNUP is set below. SIGNUP_MODE and
      # the older SIGNUPS_OPEN are both boot failures, so neither is forwarded
      # here. Mint an invite with `pnpm core-api invites create --email …`.
      #
      # What the instance calls itself on the /health handshake and in its
      # start-up log, and which language its letters are written in when a
      # request names none: en, de, fr, it, es or tr.
      INSTANCE_NAME: ${INSTANCE_NAME:-openplate}
      INSTANCE_LANGUAGE: ${INSTANCE_LANGUAGE:-en}
      # Which body's micronutrient reference values it shows: dge | efsa | us.
      # Only the BOOT default: an administrator changes the live setting with
      # `pnpm core-api settings set nutrient-reference-basis efsa`, and the
      # stored row wins from then on.
      NUTRIENT_REFERENCE_BASIS: ${NUTRIENT_REFERENCE_BASIS:-dge}
      # The version of the health-data consent every account must agree to, a
      # short string such as 2026-09-28. Empty, the self-hosted default, asks
      # for no consent. Changing it asks every account again.
      HEALTH_CONSENT_VERSION: ${HEALTH_CONSENT_VERSION:-}
      # Both or neither: they build the link in an invitation and in a
      # password-reset mail. With neither, the admin API returns the raw token.
      SERVER_PUBLIC_URL: ${SERVER_PUBLIC_URL:-}
      CLIENT_BASE_URL: ${CLIENT_BASE_URL:-}
      # Set to the number of reverse proxies in front of this service, or the
      # per-IP throttle collapses into one bucket anyone can lock for everyone.
      TRUST_PROXY: ${TRUST_PROXY:-0}
      # debug, info, warn or error. Empty is refused, so the default stays.
      LOG_LEVEL: ${LOG_LEVEL:-info}
      # The address the listener binds to inside the container. Leave it empty:
      # the published port reaches only a listener on every interface.
      HOST: ${HOST:-}
      # The folder of letter texts, mounted read-only, see .env.example. Set it
      # to the container path of the volume line under `volumes:` below.
      CONTENT_DIR: ${CONTENT_DIR:-}
      # The daily ceilings on declaration receipts, for the instance and per
      # sender network. See .env.example.
      LEGAL_DECLARATION_RECEIPTS_PER_DAY: ${LEGAL_DECLARATION_RECEIPTS_PER_DAY:-200}
      LEGAL_DECLARATION_RECEIPTS_PER_NETWORK_PER_DAY: ${LEGAL_DECLARATION_RECEIPTS_PER_NETWORK_PER_DAY:-10}
      # A PEM file of extra certificate authorities Node trusts, for an SMTP
      # server with a private CA. The container path of the volume line below.
      NODE_EXTRA_CA_CERTS: ${NODE_EXTRA_CA_CERTS:-}
      # Every variable this service reads is forwarded here, so a line in
      # `.env` is all it takes. Empty means the default.
      ADMIN_TOKEN: ${ADMIN_TOKEN:-}
      SYNC_SHARING: ${SYNC_SHARING:-false}
      SYNC_RESEARCH: ${SYNC_RESEARCH:-false}
      # Reported estimates. On, this service KEEPS the photograph and the
      # figures a person reports, readable, for its retention window. The two
      # limits are per account per UTC day, and per request.
      SYNC_FEEDBACK: ${SYNC_FEEDBACK:-false}
      FEEDBACK_DAILY_LIMIT: ${FEEDBACK_DAILY_LIMIT:-5}
      FEEDBACK_MAX_REQUEST_BYTES: ${FEEDBACK_MAX_REQUEST_BYTES:-8000000}
      # The operator notice: one short sentence /health publishes and the
      # client shows. Empty means no notice. SYNC_NOTICE_URL without
      # SYNC_NOTICE is a boot failure. See .env.example for the length cap.
      SYNC_NOTICE: ${SYNC_NOTICE:-}
      SYNC_NOTICE_URL: ${SYNC_NOTICE_URL:-}
      # Mail: one transport or none, see .env.example. Unset means invitations
      # and resets come back to you as links instead of being sent. A
      # cancellation or a withdrawal is recorded but mailed to nobody. The
      # HTTP mail API uses the three MAIL_API_* values. SMTP uses the five
      # SMTP_* values. Both at once is a boot failure. MAIL_OPERATOR_EMAIL
      # belongs to both.
      MAIL_API_URL: ${MAIL_API_URL:-}
      MAIL_API_KEY: ${MAIL_API_KEY:-}
      MAIL_API_FROM: ${MAIL_API_FROM:-}
      SMTP_HOST: ${SMTP_HOST:-}
      SMTP_PORT: ${SMTP_PORT:-}
      SMTP_USER: ${SMTP_USER:-}
      SMTP_PASSWORD: ${SMTP_PASSWORD:-}
      SMTP_FROM: ${SMTP_FROM:-}
      MAIL_OPERATOR_EMAIL: ${MAIL_OPERATOR_EMAIL:-}
      # The AI proxy: both or neither. Unset means POST /v1/chat/completions
      # answers the ordinary unknown-path 404 and /health reports no AI at all.
      # The per-account daily allowance is in the database, not here.
      UPSTREAM_BASE_URL: ${UPSTREAM_BASE_URL:-}
      UPSTREAM_API_KEY: ${UPSTREAM_API_KEY:-}
      # OpenRouter only, both optional: zero data retention endpoints, and a pin
      # to named providers with no fallback. Empty is the proxy's old behaviour.
      UPSTREAM_ZDR: ${UPSTREAM_ZDR:-}
      UPSTREAM_PROVIDER_ONLY: ${UPSTREAM_PROVIDER_ONLY:-}
      UPSTREAM_TIMEOUT_MS: ${UPSTREAM_TIMEOUT_MS:-120000}
      # Which file decides the model, the zero retention routing and the output
      # cap of each kind of request: empty (the default) keeps AI_ADVERTISED_MODEL
      # and the two settings above as the whole answer, `bundled` is the file in
      # the image, or an absolute path to a file you mount.
      AI_TIERS_FILE: ${AI_TIERS_FILE:-}
      # The model the proxy sends every request to. Empty passes the caller's.
      # With a tier file it replaces the default tier's model (an emergency override).
      AI_ADVERTISED_MODEL: ${AI_ADVERTISED_MODEL:-}
      # The most output tokens one request may ask for, with or without a model.
      AI_MAX_OUTPUT_TOKENS: ${AI_MAX_OUTPUT_TOKENS:-8192}
      AI_RATE_LIMIT_PER_MINUTE: ${AI_RATE_LIMIT_PER_MINUTE:-20}
      # Sized for a camera photograph after base64, NOT for a stored blob.
      AI_MAX_REQUEST_BYTES: ${AI_MAX_REQUEST_BYTES:-8000000}
      # What one request may carry in (image parts, text bytes, messages),
      # the input tokens one unit of the daily counters covers, and the
      # tokens one image is counted at.
      AI_MAX_IMAGE_PARTS: ${AI_MAX_IMAGE_PARTS:-1}
      AI_MAX_TEXT_BYTES: ${AI_MAX_TEXT_BYTES:-49152}
      AI_MAX_MESSAGES: ${AI_MAX_MESSAGES:-4}
      AI_UNIT_INPUT_TOKENS: ${AI_UNIT_INPUT_TOKENS:-8192}
      AI_IMAGE_INPUT_TOKENS: ${AI_IMAGE_INPUT_TOKENS:-1500}
      # The whole instance's AI requests per UTC day. Empty means no ceiling.
      AI_INSTANCE_DAILY_LIMIT: ${AI_INSTANCE_DAILY_LIMIT:-}
      # On an OpenRouter key: mail MAIL_OPERATOR_EMAIL once per reset period
      # when less than this share of the key's limit is left. Empty means 0.2.
      AI_BUDGET_ALERT_FRACTION: ${AI_BUDGET_ALERT_FRACTION:-}
      # Members inviting people: the first two together or neither, and the
      # cap only with the pair. Empty means only an administrator invites.
      MEMBER_INVITE_DAILY_AI_LIMIT: ${MEMBER_INVITE_DAILY_AI_LIMIT:-}
      MEMBER_INVITE_ALLOWANCE_DAYS: ${MEMBER_INVITE_ALLOWANCE_DAYS:-}
      MEMBER_INVITE_LIFETIME_CAP: ${MEMBER_INVITE_LIFETIME_CAP:-}
      # Open sign-up: empty means invite-only. "true" needs the mail block
      # above. The Turnstile pair is both or neither, and only with it.
      OPEN_SIGNUP: ${OPEN_SIGNUP:-}
      TURNSTILE_SECRET_KEY: ${TURNSTILE_SECRET_KEY:-}
      TURNSTILE_SITE_KEY: ${TURNSTILE_SITE_KEY:-}
      # Free AI scans for new accounts: the pair together or neither, and the
      # pepper with them. MEMBER_INVITE_TRIAL=true makes a member invitation
      # grant the scans instead of the day pair above. Empty means no trial.
      # TRIAL_DAYS, only beside the pair, also ends the trial at midnight after
      # that many days, whichever comes first. Empty means no end date.
      # TRIAL_TIME_ZONE, only beside TRIAL_DAYS, is the zone of that midnight
      # (an IANA name such as Europe/Berlin). Empty means UTC.
      TRIAL_SCANS: ${TRIAL_SCANS:-}
      TRIAL_DAILY_AI_LIMIT: ${TRIAL_DAILY_AI_LIMIT:-}
      TRIAL_DAYS: ${TRIAL_DAYS:-}
      TRIAL_TIME_ZONE: ${TRIAL_TIME_ZONE:-}
      TRIAL_ADDRESS_PEPPER: ${TRIAL_ADDRESS_PEPPER:-}
      TRIAL_HASH_RETENTION_DAYS: ${TRIAL_HASH_RETENTION_DAYS:-}
      MEMBER_INVITE_TRIAL: ${MEMBER_INVITE_TRIAL:-}
      AI_TRIAL_INSTANCE_DAILY_LIMIT: ${AI_TRIAL_INSTANCE_DAILY_LIMIT:-}
      AI_TRIAL_NETWORK_DAILY_LIMIT: ${AI_TRIAL_NETWORK_DAILY_LIMIT:-}
      # A standing free daily AI limit for every account with no free limit of its
      # own, no end date and no trial. Empty or 0 means off. It cannot stand
      # beside the trial above: the boot stops naming both.
      DEFAULT_FREE_DAILY_AI_LIMIT: ${DEFAULT_FREE_DAILY_AI_LIMIT:-}
      # AI feature permissions. DEFAULT_CAPABILITIES is what an account with no
      # record of its own may use: comma separated labels, or "none" for nothing.
      # Empty means no check at all. CAPABILITY_SCHEMA_MAP ties a structured
      # output schema name to the label its use needs, as schemaName:label pairs.
      DEFAULT_CAPABILITIES: ${DEFAULT_CAPABILITIES:-}
      CAPABILITY_SCHEMA_MAP: ${CAPABILITY_SCHEMA_MAP:-}
      # Web push: all three or none. Empty means no notifications.
      VAPID_PUBLIC_KEY: ${VAPID_PUBLIC_KEY:-}
      VAPID_PRIVATE_KEY: ${VAPID_PRIVATE_KEY:-}
      VAPID_SUBJECT: ${VAPID_SUBJECT:-}
      PUSH_ENDPOINT_HOSTS: ${PUSH_ENDPOINT_HOSTS:-}
      # Paid plans: the URL and the secret together or neither, and only with
      # a billing service behind this instance. BILLING_TOKEN is that service's
      # own scoped credential. Empty means no plans.
      PLANS_UPSTREAM_URL: ${PLANS_UPSTREAM_URL:-}
      PLANS_UPSTREAM_SECRET: ${PLANS_UPSTREAM_SECRET:-}
      BILLING_TOKEN: ${BILLING_TOKEN:-}
      BILLING_MAX_DAILY_AI_LIMIT: ${BILLING_MAX_DAILY_AI_LIMIT:-}
      # Only for an EXTERNAL database. The bundled Postgres above speaks plain
      # TCP on the compose network.
      DATABASE_SSL: ${DATABASE_SSL:-false}
    healthcheck:
      # The image bakes a similar check in, but Podman drops a HEALTHCHECK
      # when it pulls an OCI manifest, which is what GHCR serves. Declared
      # here it holds under both engines and Quadlet turns it into
      # Notify=healthy.
      #
      # A shell line with no quotes and no brackets, run by the image's
      # busybox wget. Docker Compose, podman-compose and Quadlet all pass it
      # through the same way; the old `node -e "fetch(...)"` array form
      # reached podman-compose 1.0.6 as a broken shell line and stayed
      # unhealthy forever (the same fix as openplate's compose files).
      test: ['CMD-SHELL', 'wget -q -O /dev/null http://127.0.0.1:3000/health']
      interval: 30s
      timeout: 5s
      start_period: 20s
      retries: 3
    ports:
      - '${SYNC_PORT:-3000}:3000'
    # Uncomment what you use, and set the matching variable in `.env`:
    #   CONTENT_DIR=/srv/openplate/content
    #   NODE_EXTRA_CA_CERTS=/etc/openplate/ca.pem
    # volumes:
    #   - ./content:/srv/openplate/content:ro
    #   - ./ca.pem:/etc/openplate/ca.pem:ro

volumes:
  postgres-data-18:
    driver: local

Le moteur d'inférence seul

apps/inference/docker/compose.yml

Publié dans la version 0.3.0

Ce qui démarre

  • Moteur d'inférence inference

    ghcr.io/lowcarbcheck/openplate-inference:latest

    Port 8300 sur cette machine · Volume : inference-models

latest suit la version la plus récente. Pour figer une version, remplace latest par son numéro.

Les données se trouvent dans ces volumes : inference-models. down les conserve, et down -v les supprime.

Contenu du fichier .env

Il n'a besoin d'aucun fichier .env pour démarrer.

Il lit au total 27 paramètres depuis .env. Le fichier indique la valeur par défaut de chaque paramètre facultatif. Explications pour chaque paramètre

Commandes

Démarrer
docker compose -f compose.yml up -d
Mettre à jour
docker compose -f compose.yml pull docker compose -f compose.yml up -d
Suivre les journaux
docker compose -f compose.yml logs -f
Arrêter
docker compose -f compose.yml down

Pour Podman, lance podman compose au lieu de docker compose.

Afficher tout le fichier (145 lignes)
yaml
# openplate-inference, on its own.
#
# A single-service compose file for running the inference endpoint by itself:
# a plate scanner any OpenAI-compatible client can call. Copy it into a folder
# of its own, put a `.env` beside it with at least API_KEYS, and run
# `docker compose up -d` there. Every variable the service reads is forwarded
# below, so any line of `.env.example` works in that `.env`.
#
# From a checkout, run it from the openplate-inference folder, so the `.env`
# there is the one Compose reads:
#
#   docker compose --project-directory . -f docker/compose.yml up -d
#   docker compose --project-directory . -f docker/compose.yml logs -f inference   # weight download + model load + ready
#
# Want to run this TOGETHER with the openplate app? That two-service topology
# lives in the openplate repo, not here:
#   https://github.com/LowCarbCheck/openplate/blob/main/docker/topologies/compose.inference.yml

# Pins the Compose project name. Without it, `-f docker/compose.yml` makes
# Compose derive the project from the containing directory, so the stack and
# the multi-GB models volume both get named "docker".
name: openplate-inference

services:
  inference:
    image: ghcr.io/lowcarbcheck/openplate-inference:latest
    # Or build it yourself:
    #   build: { context: ., args: { BASE_IMAGE: ghcr.io/ggml-org/llama.cpp:server } }
    restart: unless-stopped
    ports:
      # Published because the browser calls it directly. Bind to 0.0.0.0 (as
      # here) for LAN access; use "127.0.0.1:8300:8300" if a reverse proxy on
      # this host is the only thing that should reach it.
      - "8300:8300"
    volumes:
      # Weights land here on first boot (~2.0 GiB for lite, ~5.8 GiB for
      # quality) and are verified by sha256 on every start. Named, so
      # `docker compose down` does not throw the download away.
      - inference-models:/models
    environment:
      # lite | lite-apache | quality, see README "Hardware & measured latency".
      # external runs no model here and uses your runtime, see below.
      MODEL_PROFILE: ${MODEL_PROFILE:-lite}
      # SET THIS in `.env`: a stable key callers must present. The placeholder
      # only keeps a first trial booting. Any random string:
      #   echo "API_KEYS=opk_$(openssl rand -hex 24)" >> .env
      API_KEYS: ${API_KEYS:-opk_CHANGE_ME}
      # Self-host has no latency ceiling. 0 = never shed load for being slow.
      LATENCY_CEILING_MS: ${LATENCY_CEILING_MS:-0}
      # Scans in flight at once. It also sets llama.cpp's slot count; it does
      # NOT add CPU threads, the slots share LLAMA_THREADS.
      CONCURRENCY: ${CONCURRENCY:-2}
      # CPU threads for the model. Empty means every core but two (nproc - 2),
      # which leaves room for the service and the OS.
      LLAMA_THREADS: ${LLAMA_THREADS:-}
      # Where macros come from. fdc = the bundled offline USDA-derived dataset.
      # See README "Food data" before switching to `off` (ODbL) or `lcc`.
      FOOD_SOURCE: ${FOOD_SOURCE:-fdc}

      # ── Everything else the service reads. Empty means the default, and
      # openplate-inference's .env.example explains each one.
      #
      # Your own runtime, with MODEL_PROFILE=external (see below). No trailing
      # /v1, and the address must resolve from INSIDE this container.
      MODEL_RUNTIME_URL: ${MODEL_RUNTIME_URL:-}
      MODEL_RUNTIME_API_KEY: ${MODEL_RUNTIME_API_KEY:-}
      # The model id sent to the runtime. Empty means openplate-plate-1. vLLM
      # needs its exact served model name.
      MODEL_ID: ${MODEL_ID:-}
      # The waiting line, the bound on one completion call, the requests per
      # key per minute, the largest decoded image, and the downscale target.
      MAX_QUEUE_DEPTH: ${MAX_QUEUE_DEPTH:-8}
      RUNTIME_COMPLETION_TIMEOUT_MS: ${RUNTIME_COMPLETION_TIMEOUT_MS:-600000}
      RATE_LIMIT_RPM: ${RATE_LIMIT_RPM:-60}
      MAX_IMAGE_BYTES: ${MAX_IMAGE_BYTES:-8388608}
      IMAGE_MAX_LONG_EDGE: ${IMAGE_MAX_LONG_EDGE:-896}
      # debug, info, warn or error.
      LOG_LEVEL: ${LOG_LEVEL:-info}
      # What the service reports as its profile. Empty follows MODEL_PROFILE.
      PROFILE: ${PROFILE:-}
      # Each is read only by its own FOOD_SOURCE. Empty FDC_DATASET_PATH is the
      # bundled extract. Empty URLs are https://lowcarbcheck.org for lcc and
      # https://world.openfoodfacts.org for off.
      FDC_DATASET_PATH: ${FDC_DATASET_PATH:-}
      LCC_API_URL: ${LCC_API_URL:-}
      LCC_API_KEY: ${LCC_API_KEY:-}
      OFF_API_URL: ${OFF_API_URL:-}
      # A second runtime serving /v1/embeddings, for hybrid retrieval. Empty
      # means lexical retrieval only.
      EMBEDDING_RUNTIME_URL: ${EMBEDDING_RUNTIME_URL:-}
      EMBEDDING_RUNTIME_API_KEY: ${EMBEDDING_RUNTIME_API_KEY:-}
      # The bundled llama-server: its loopback port, the context per slot, the
      # layers put on the GPU (empty means detect), and extra flags passed on
      # as written.
      RUNTIME_PORT: ${RUNTIME_PORT:-8080}
      CONTEXT_SIZE: ${CONTEXT_SIZE:-8192}
      GPU_LAYERS: ${GPU_LAYERS:-}
      LLAMA_EXTRA_ARGS: ${LLAMA_EXTRA_ARGS:-}
      # A mirror tried before Hugging Face for the first weight download.
      WEIGHTS_MIRROR_BASE: ${WEIGHTS_MIRROR_BASE:-}
    # ── GPU (the `quality` profile) ── uncomment BOTH of these and switch the
    # image/build to the -cuda base. The entrypoint detects the GPU and offloads
    # every layer automatically; there is no flag to set.
    # deploy:
    #   resources:
    #     reservations:
    #       devices:
    #         - driver: nvidia
    #           count: all
    #           capabilities: [gpu]

    # ── ALREADY RUNNING vLLM / llama.cpp / OLLAMA? ────────────────────────
    # Set these in `.env` and this container downloads no weights and starts
    # no second model; it just turns your runtime into a plate scanner. You can
    # drop the `volumes:` block and the `inference-models` volume entirely.
    #
    # Read README "Bring your own runtime" FIRST: your runtime must enforce
    # grammar-constrained decoding, and there is a one-line curl there that
    # tells you whether yours does. vLLM's CPU build does NOT (it crashes).
    #
    #   MODEL_PROFILE=external
    #   # Must resolve from INSIDE this container, and no trailing /v1.
    #   # `localhost` here means this container, not your host. Use the LAN
    #   # address, or host.docker.internal on Docker Desktop.
    #   MODEL_RUNTIME_URL=http://your-runtime.lan:8000
    #   # vLLM requires an EXACT match with its served model name.
    #   MODEL_ID=your-served-model-name
    #   # Only if your runtime is behind auth (`vllm serve --api-key ...`).
    #   # Separate from API_KEYS, which callers present to THIS service.
    #   MODEL_RUNTIME_API_KEY=sk_your_runtime_key
    #   # Match your runtime's real slot count:
    #   #   llama.cpp --parallel N | vLLM --max-num-seqs N | OLLAMA_NUM_PARALLEL
    #   CONCURRENCY=2
    #
    # REQUIRED with external mode, and the one edit to this file it needs. The
    # image bakes in a 60-minute health start_period, sized for a first-boot
    # weight download. External mode has no download, so without this override
    # a wrong MODEL_RUNTIME_URL stays hidden for an hour instead of surfacing
    # in seconds.
    # healthcheck:
    #   start_period: 30s

volumes:
  inference-models:
    driver: local