Docker with a login page¶
The admin app and the consumer agent run in Docker behind a login page. Each person picks an environment (a Teradata system), logs in with their own database credentials, and works in an app process of their own. One command starts everything.
browser ──► gateway :8000 ── login page, environments, sessions
│
├── worker (jane @ production) ── own database connection, own settings
├── worker (jane @ laboratory)
└── worker (paul @ production)
│
└── chroma (vector index server, shared)
- Why one process per login. The app holds one database connection and its settings for the whole process. Two people on two systems in one process would overwrite each other, so the gateway starts a separate worker for each person and environment and forwards that person's requests to it.
- Whose rights. A worker connects with the person's own credentials, so the database applies their own rights and their own audit. The profiles of the app (analyst, scientist, engineer, admin) come from their database roles, as with the login gate; see Profiles to give everybody more.
Start in three steps¶
From a notebook or a Python session that already works with tdfs4ds (models, vector store and store set):
It writes a folder with everything inside:
| File | What it is |
|---|---|
docker-compose.yml |
the gateway and the Chroma server, healthchecks, page published on 127.0.0.1 only |
Dockerfile |
the image: tdfs4ds[agent] at your version (from PyPI, or a wheel copied into the folder) |
.env |
your session's settings (models, vector store, MCP, data domain), the gateway settings, a generated TDFS4DS_SERVE_SECRET. No database password |
config/environments.yaml |
the environments offered on the login page; your current connection is the first one |
state/environments.json |
environments added from the login page (empty at first) |
README.md |
the commands, the volumes, how to update |
start.ps1 / start.sh |
build, start, wait until the app answers, open the browser |
Then:
Open http://localhost:8000, choose the environment, log in.
From a terminal, without Python code: python -m tdfs4ds.deployment tdfs4ds-docker.
What create_docker_deployment asks and checks¶
- Questions (skipped with
prompt=False): a label for the current environment, other environments to add, the port, an API key for programs calling/v1, a service account for those calls. - Secrets: model and Vector Store keys go into
.envonly after an explicit yes (include_secrets='ask', the default). Otherwise they are left as placeholders listed under# MISSING:. - Checks before writing (
check=True): the environments are valid; each host answers on port 1025 from this computer (a warning only: the container needs the same network access); the session's configuration;docker compose configwhen Docker is installed. Problems are listed and nothing is written without your confirmation (orforce=True). - Image source:
source='pypi'pins the installed version and checks it is on PyPI;source='wheel'copies a built wheel into the folder (a version not yet published);source='checkout'builds from a source checkout. - Updating a folder:
overwrite=Truerewrites the generated files and patches the existing.env(your comments, your own lines and the secret are kept). Without it, nothing is overwritten.
From the repository instead¶
The repository carries the same files: Dockerfile (builds from the working tree), Dockerfile.pypi
(--build-arg TDFS4DS_VERSION=0.3.8.2), docker-compose.yml, .env.example and
config/environments.example.yaml:
cp .env.example .env
cp config/environments.example.yaml config/environments.yaml # edit the hosts
mkdir -p state
docker compose up -d --build
The environments file¶
config/environments.yaml (or .json; YAML needs PyYAML in the image, which the [agent] extra brings).
It never holds a password.
environments:
- id: prod # unique: letters, digits, - and _
label: Production # shown on the page
host: vantage-prod.example.com
logmechs: [LDAP, TD2] # TD2, LDAP, TDNEGO, JWT (the first is the default)
encrypt: true
database: FS_PROD # the feature store opened after the login
databases_readonly: [FS_LAB] # other stores attached read-only
env: # other TDFS4DS_* settings of this environment, no secrets
DATA_DOMAIN: SALES
- id: lab
label: Laboratory
host: vantage-lab.example.com
logmechs: [LDAP]
- Without the file, the gateway offers one environment built from
TDFS4DS_TD_HOST(and_LOGMECH,_ENCRYPT,_DATABASE), so an existing.envkeeps working. - A file with an error (duplicate id, missing host, unknown setting, a secret under
env:) stops the gateway at start, with every problem listed.
Environments added from the login page¶
The Environment list ends with New environment…: label, host, logon mechanism, encryption and store
database. The entry is saved only after a successful logon, in state/environments.json (the ./state
folder next to docker-compose.yml, so you can see, edit, back up or copy it). It holds the host and
options, who added it and when, never a user name or a password. Environments used most recently come first;
the browser also remembers the last environment and user name it used.
- An administrator (admin profile) can remove a saved environment from the login page. Those of
config/environments.yamlcannot be removed there. - A hand edit of
state/environments.jsonapplies without a restart. A broken file is reported on the login page, set aside asenvironments.json.bad, and the list starts empty. TDFS4DS_SERVE_ALLOW_NEW_ENVIRONMENT=falsekeeps the choice to the listed environments: use it where the server must not connect to any host someone types.TDFS4DS_SERVE_REMEMBER_ENVIRONMENTS=falsekeeps a new environment for that session only.
Remembered credentials¶
The login form has Remember my credentials for this environment, unchecked by default. When ticked and the logon succeeds, the next visit shows credentials remembered: one click logs in.
- Stored in two halves. The password is encrypted (AES-256-GCM) in the
tdfs4ds_secretsvolume; the key is in an HttpOnly cookie of that browser. A copy of the volume cannot be decrypted without the browser, and the cookie is useless without the server's file. - Only for TD2 and LDAP. A JWT token is never stored (it expires in about two hours).
- Lifetime: 30 days from the last use (
TDFS4DS_SERVE_REMEMBER_DAYS). If the database refuses the stored password (changed, account locked), the entry is deleted and the form asks again. Forget my credentials and Log out and forget delete both halves. - Limit: anyone using that browser profile can log in as that person. Do not tick it on a shared computer.
TDFS4DS_SERVE_REMEMBER_CREDENTIALS=falseremoves the option for everyone.
Profiles and the pages you see¶
The pages and actions the app offers depend on a profile: analyst (chat, catalogs, lineage), scientist
(runs, health check), engineer (maintenance, migration, removal, documentation edits) and admin (Parameters,
Assistant settings, evaluation). The profile comes from your database roles: TDFS4DS_ADMIN, TDFS4DS_ENGINEER,
TDFS4DS_SCIENTIST (names settable with TDFS4DS_SERVE_ROLE_*). Without any of these roles you are an analyst,
which is why a fresh deployment shows only the business pages.
On a computer that only you use, give yourself everything:
or edit the environment in config/environments.yaml (then docker compose restart tdfs4ds):
min_profile is a floor: everybody who logs on to that environment gets at least that profile, and a database
role can still grant a higher one. TDFS4DS_SERVE_MIN_PROFILE=admin in .env does the same for every environment
(including the ones added from the login page). The login page tells you when it raised your profile.
A profile is not a permission
The profile only decides which pages and actions the app offers. What you can read or change in the database is
always decided by the database, for the user you logged on with. Give admin to everybody only on a
computer or a team you trust, because the admin pages can switch the feature store, change the models and run
maintenance.
Model API keys in the app¶
The assistant needs a language model and, for search, an embedding model. Their settings and API keys are on Parameters (admin profile): Instruct model and Embedding model.
- A key is never shown. The page says whether one is set and how many characters it has. Leave the key field empty to keep the key in use: changing the model name or the URL no longer erases it. Type a new key to replace it.
- The key is saved for everybody on the server. In Docker, the key goes to the gateway, which stores it encrypted
(AES-256-GCM, in the
tdfs4ds_secretsvolume, with a key derived fromTDFS4DS_SERVE_SECRET), gives it at once to the people logged in, and hands it to every worker started afterwards. It survives a restart of the container. A key saved in the app wins over a key in.env. - Without
TDFS4DS_SERVE_SECRETthe key is applied for the people logged in now but cannot be saved; the page says so. The generated.envalways carries a secret. - Outside Docker (
python -m tdfs4ds.serve) the key is kept in the app's memory until it stops; put it in.envto keep it. - Only the two model keys are saved this way. Database passwords are never stored by the app (except the opt-in remembered credentials above).
Where the data is¶
| Data | Where | Note |
|---|---|---|
| Environments of the administrator | ./config → /config (read only) |
edited on the host |
| Environments saved from the login page | ./state → /state |
visible on the host |
| Remembered credentials and the model keys saved in the app (encrypted) | volume tdfs4ds_secrets |
a Windows folder would lose the file permissions |
| Vector index (Chroma) | volume chroma_data of the chroma service |
shared by every worker |
| Worker files, local Chroma folders | volume tdfs4ds_data |
Vector index with several workers. Chroma's local mode is one folder that only one process may write.
In the container, workers use the Chroma server of the compose file instead (TDFS4DS_CHROMA_MODE=server):
everyone on the same environment and store shares one index, built once. Each environment gets its own
collection prefix (tdfs4ds_<environment id>), so two systems that both have a store named DB_LAB never
mix. With chroma: local on an environment, each person gets their own folder
(/data/chroma/<environment>/<user>), built for them and kept for their next login. The Teradata Enterprise
Vector Store backend keeps its collections in the database and needs none of this.
Programs calling the agent (/v1)¶
- From a logged-in browser session:
/v1/*goes to that person's worker. - From a program:
Authorization: Bearer <key>, where the environment names the variables of.envholding the key and a service account:api_key_var,service_user_var,service_password_var(create_docker_deploymentoffers to generate them). The gateway starts one service worker per environment on the first call. Choose the environment with the headerX-TDFS4DS-Environment: prodor the path/env/prod/v1/chat/completions.
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/env/prod/v1", api_key="<the key>")
client.chat.completions.create(model="tdfs4ds-consumer",
messages=[{"role": "user", "content": "Which features describe a customer?"}])
Sessions and resources¶
| Variable | Default | Meaning |
|---|---|---|
TDFS4DS_SERVE_MAX_WORKERS |
8 | workers at the same time; above it the login page says the server is full |
TDFS4DS_SERVE_SESSION_TTL / _MAX |
30 / 480 | minutes of inactivity / absolute lifetime of a login |
TDFS4DS_SERVE_WORKER_TIMEOUT |
90 | seconds a new worker has to connect |
TDFS4DS_SERVE_SECRET |
generated | signs the cookies; keep it stable so logins and remembered credentials survive a restart |
A worker uses about 300 to 500 MB of memory, plus the Chroma server. Logging out (or the inactivity limit) stops it; a worker that dies is restarted once at the next request. The database password lives only in the worker's process environment: never on disk, in the logs or on a command line.
Docker Desktop on Windows¶
- Docker not on PATH:
start.ps1findsdocker.exein the Docker Desktop folders, and says start Docker Desktop when the engine does not answer. - Corporate proxy: the build and the model calls use Docker Desktop's proxy settings; the
session's
HTTPS_PROXY/NO_PROXYare copied into the folder, withchroma,localhost,127.0.0.1inNO_PROXY. - VPN: containers reach the Teradata systems through the Windows network, like a notebook.
.\start.ps1 -Checktests port 1025 of each environment from inside the container. - Local services: an MCP server running on Windows is written as
http://host.docker.internal:<port>/.... A CA bundle given as a Windows path is copied toconfig/certs/and mounted. - Line endings: the files used inside the image are written with LF, so Git's line-ending conversion cannot break them.
Opening it to other people¶
The page is published on 127.0.0.1 only. To share it:
- Put a reverse proxy with TLS in front (the password crosses the network at login). Set
TDFS4DS_SERVE_COOKIE_SECURE=true, andTDFS4DS_SERVE_TRUST_PROXY=trueonly behind a proxy you control. - Under a path prefix, set
TDFS4DS_SERVE_ROOT_PATH(see Behind a reverse-proxy path prefix). - Change the port line of
docker-compose.ymlto the network address the proxy uses. - Create the profile roles once (see Login gate).
The same login page without Docker¶
python -m tdfs4ds.serve --login starts the gateway on your own computer: the same login page, the same choice of
environment, one app process of its own for each person. Nothing needs Docker.
python -m tdfs4ds.serve --login # opens the page at http://127.0.0.1:8000
python -m tdfs4ds.serve --login --min-profile admin --port 8100 --no-browser
| Option | Meaning |
|---|---|
--login |
the login page and one process per login (TDFS4DS_SERVE_MODE=login does the same) |
--min-profile analyst\|scientist\|engineer\|admin |
everybody logging on gets at least this profile (see Profiles): use admin on your own computer |
--no-browser |
do not open the page |
--port, --host |
the address; the default host is 127.0.0.1, because the login carries a password over HTTP |
--env FILE |
a .env loaded first, as before |
Where things are kept (each used only when you have not set the variable yourself):
| What | Where |
|---|---|
| Environments you manage | the first of ./environments.yaml\|json, ~/.tdfs4ds/environments.yaml\|json. With none, the environment built from TDFS4DS_TD_HOST, and New environment... on the page |
| Environments saved from the login page | ~/.tdfs4ds/serve/environments.json |
| Remembered credentials, saved model keys, each person's local Chroma folder | ~/.tdfs4ds/serve/ |
| The secret that signs the cookies | ~/.tdfs4ds/serve/secret, created once (mode 600 where supported), so logins and remembered credentials survive a restart |
Stopping the server (Ctrl+C, closing the console, even killing it) stops every person's process: on Windows the processes are tied to the server, so none is left behind.
One app without the login¶
TDFS4DS_SERVE_MODE=single in .env runs the image as before 0.3.8.2: one app process, connected with the
TDFS4DS_TD_* credentials, no login page (or the login gate with
TDFS4DS_SERVE_AUTH=database). Outside Docker, python -m tdfs4ds.serve is unchanged and
python -m tdfs4ds.serve.gateway starts the gateway.