Chemical Dice Integrator ยท Containerised single-image deployment with an embedded Ollama LLM.
Service Port Description
Ollama 11434 LLM server (runs inside the container) FastAPI 8001 CDI backend --- REST API Streamlit 8501 CDI frontend --- chat + microservice UI
All three services are managed by Supervisor and start automatically
when the container launches.
The LLM model (deepseek-r1:8b by default) is baked into the image at
build time --- no download happens at runtime.
Note: CDI Bot is currently configured to work on
llama3.1:8bmodel.
Instead of building locally, you can directly run the prebuilt image:
docker pull ahujalab/chemicaldice-app:v1
docker run --gpus all --name chemicaldice-app -p 8001:8001 -p 8501:8501 ahujalab/chemicaldice-app:v1
Make sure these four files are in the same directory:
app.py
main.py
Dockerfile
supervisord.conf
docker build -t cdi-bot .
The build will pull
deepseek-r1:8b(~5 GB) from Ollama's registry.
This only happens once --- subsequent builds use Docker's layer cache.
docker run -d \
--name cdi-bot \
-p 8001:8001 \
-p 8501:8501 \
cdi-bot
Navigate to http://localhost:8501โ in your browser.
The backend API is also available at http://localhost:8001โ (see
/docs for the Swagger UI).
After docker run the container goes through this sequence
automatically:
Supervisor starts
โโ Ollama starts (port 11434)
โโ FastAPI starts (waits for Ollama to be healthy, then port 8001)
โโ Streamlit starts (15 s delay, then port 8501)
First response from the chat assistant may be slow (~30--60 s) while the model loads into memory. Subsequent responses are much faster.
# All services combined
docker logs -f cdi-bot
# Individual service logs (inside the container)
docker exec cdi-bot tail -f /var/log/supervisor/ollama.log
docker exec cdi-bot tail -f /var/log/supervisor/fastapi.log
docker exec cdi-bot tail -f /var/log/supervisor/streamlit.log
docker stop cdi-bot
docker rm cdi-bot
The model is set via the LLM_MODEL build argument. Any model available
on ollama.com/libraryโ can be used.
docker build --build-arg LLM_MODEL=mistral:7b -t cdi-bot-mistral .
docker run -d --name cdi-bot-mistral -p 8001:8001 -p 8501:8501 cdi-bot-mistral
Common alternatives:
Model tag Size Notes
deepseek-r1:8b ~5 GB Default --- strong reasoning
mistral:7b ~4 GB Fast, good general performance
llama3.1:8b ~5 GB Meta's Llama 3.1
gemma2:9b ~6 GB Google Gemma 2
phi3:medium ~8 GB Microsoft Phi-3
deepseek-r1:14b ~9 GB Larger DeepSeek variant
If your machine has an NVIDIA GPU, pass it to the container for faster inference:
docker run -d \
--name cdi-bot \
--gpus all \
-p 8001:8001 -p 8501:8501 \
cdi-bot
Requires NVIDIA Container Toolkitโ .
.
โโโ app.py # Streamlit frontend
โโโ main.py # FastAPI backend
โโโ Dockerfile # Single-image build (Ollama + FastAPI + Streamlit)
โโโ supervisord.conf # Process manager config (auto-generated, must be present)
โโโ README.md # This file
Variable Default Description
LLM_MODEL deepseek-r1:8b Ollama model tag used for all LLM
calls
OLLAMA_BASE_URL http://localhost:11434 Ollama API base URL (rarely needs
changing)UI loads but chat returns an error
Ollama or FastAPI may still be initialising. Wait 30--60 seconds and
refresh the page.
docker build fails on the ollama pull step
Your build environment may not have internet access to ollama.com.
Ensure outbound HTTPS is allowed.
Out of memory during inference
Use a smaller model (e.g.ย phi3:mini, gemma2:2b) or add
--memory 12g to docker run.
Port conflict
Change the host port mapping: -p 9501:8501 maps Streamlit to port 9501
on your host.
Content type
Image
Digest
sha256:68b29ff1cโฆ
Size
8.5 GB
Last updated
6 months ago
docker pull ahujalab/chemicaldice-app:v1