Skip to content

Commit 90885f1

Browse files
committed
(docs) how to build the lightspeed core image
1 parent 93f1079 commit 90885f1

File tree

5 files changed

+218
-8
lines changed

5 files changed

+218
-8
lines changed

Containerfile

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,45 @@
11
# vim: set filetype=dockerfile
2-
FROM registry.access.redhat.com/ubi9/python-312-minimal AS builder
2+
FROM registry.access.redhat.com/ubi9/ubi-minimal AS builder
33

44
ARG APP_ROOT=/app-root
55
ARG LSC_SOURCE_DIR=.
66

77
# UV_PYTHON_DOWNLOADS=0 : Disable Python interpreter downloads and use the system interpreter.
88
ENV UV_COMPILE_BYTECODE=0 \
99
UV_LINK_MODE=copy \
10-
UV_PYTHON_DOWNLOADS=0
10+
UV_PYTHON_DOWNLOADS=0 \
11+
PATH="$PATH:/root/.local/bin"
1112

1213
WORKDIR /app-root
1314

14-
# Install uv package manager
15-
RUN pip3.12 install uv
15+
RUN microdnf install -y --nodocs --setopt=keepcache=0 --setopt=tsflags=nodocs \
16+
python3.12 python3.12-devel python3.12-pip git tar \
17+
gcc gcc-c++ make
1618

1719
# Add explicit files and directories
1820
# (avoid accidental inclusion of local directories or env files or credentials)
1921
COPY ${LSC_SOURCE_DIR}/src ./src
2022
COPY ${LSC_SOURCE_DIR}/pyproject.toml ${LSC_SOURCE_DIR}/LICENSE ${LSC_SOURCE_DIR}/README.md ${LSC_SOURCE_DIR}/uv.lock ./
2123

22-
RUN uv sync --locked --no-dev
24+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
25+
26+
RUN uv sync --locked --no-dev && \
27+
uv pip install \
28+
opentelemetry-sdk \
29+
opentelemetry-exporter-otlp \
30+
opentelemetry-instrumentation \
31+
aiosqlite \
32+
litellm \
33+
blobfile \
34+
datasets \
35+
sqlalchemy \
36+
faiss-cpu \
37+
mcp \
38+
autoevals \
39+
psutil \
40+
torch \
41+
peft \
42+
trl
2343

2444

2545
# Final image without uv package manager

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,70 @@ Container images are built for the following platforms:
290290
1. `linux/amd64` - main platform for deployment
291291
1. `linux/arm64`- Mac users with M1/M2/M3 CPUs
292292
293+
## Building Container Images
294+
295+
The repository includes production-ready container configurations that support two deployment modes:
296+
297+
1. **Server Mode**: lightspeed-core connects to llama-stack as a separate service
298+
2. **Library Mode**: llama-stack runs as a library within lightspeed-core
299+
300+
### Llama-Stack as Separate Service (Server Mode)
301+
302+
When using llama-stack as a separate service, the existing `docker-compose.yaml` provides the complete setup.
303+
304+
**Configuration** (`lightspeed-stack.yaml`):
305+
```yaml
306+
llama_stack:
307+
use_as_library_client: false
308+
url: http://llama-stack:8321 # container name from docker-compose.yaml
309+
api_key: xyzzy
310+
```
311+
312+
In the root of this project simply run:
313+
314+
```bash
315+
# Set your OpenAI API key
316+
export OPENAI_API_KEY="your-api-key-here"
317+
318+
# Start both services
319+
docker-compose up --build
320+
321+
# Access lightspeed-core at http://localhost:8080
322+
# Access llama-stack at http://localhost:8321
323+
```
324+
325+
### Llama-Stack as Library (Library Mode)
326+
327+
When embedding llama-stack directly in the container, use the existing `test.containerfile`. First modify the `lightspeed-stack.yaml` config to use llama stack in library mode.
328+
329+
**Configuration** (`lightspeed-stack.yaml`):
330+
```yaml
331+
llama_stack:
332+
use_as_library_client: true
333+
library_client_config_path: /app-root/run.yaml
334+
```
335+
336+
**Build and run**:
337+
```bash
338+
# Build lightspeed-core with embedded llama-stack
339+
docker build -f Containerfile -t my-lightspeed-core:latest .
340+
341+
# Run with embedded llama-stack
342+
docker run -d \
343+
-p 8080:8080 \
344+
-v ./lightspeed-stack.yaml:/app-root/lightspeed-stack.yaml:ro \
345+
-v ./run.yaml:/app-root/run.yaml:ro \
346+
-e OPENAI_API_KEY=your-api-key \
347+
my-lightspeed-core:latest
348+
```
349+
350+
### Verify it's running properly
351+
352+
A simple sanity check:
353+
354+
```bash
355+
curl -H "Accept: application/json" http://localhost:8080/v1/models
356+
```
293357

294358

295359
# Endpoints

lightspeed-stack.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Lightspeed Core Service (LCS)
22
service:
3-
host: localhost
3+
host: 0.0.0.0
44
port: 8080
55
auth_enabled: false
66
workers: 1
@@ -13,7 +13,7 @@ llama_stack:
1313
# Alternative for "as library use"
1414
# use_as_library_client: true
1515
# library_client_config_path: <path-to-llama-stack-run.yaml-file>
16-
url: http://localhost:8321
16+
url: http://llama-stack:8321
1717
api_key: xyzzy
1818
user_data_collection:
1919
feedback_enabled: true

run.yaml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
version: '2'
2+
image_name: minimal-viable-llama-stack-configuration
3+
4+
apis:
5+
- agents
6+
- datasetio
7+
- eval
8+
- inference
9+
- post_training
10+
- safety
11+
- scoring
12+
- telemetry
13+
- tool_runtime
14+
- vector_io
15+
benchmarks: []
16+
container_image: null
17+
datasets: []
18+
external_providers_dir: null
19+
inference_store:
20+
db_path: .llama/distributions/ollama/inference_store.db
21+
type: sqlite
22+
logging: null
23+
metadata_store:
24+
db_path: .llama/distributions/ollama/registry.db
25+
namespace: null
26+
type: sqlite
27+
providers:
28+
agents:
29+
- config:
30+
persistence_store:
31+
db_path: .llama/distributions/ollama/agents_store.db
32+
namespace: null
33+
type: sqlite
34+
responses_store:
35+
db_path: .llama/distributions/ollama/responses_store.db
36+
type: sqlite
37+
provider_id: meta-reference
38+
provider_type: inline::meta-reference
39+
datasetio:
40+
- config:
41+
kvstore:
42+
db_path: .llama/distributions/ollama/huggingface_datasetio.db
43+
namespace: null
44+
type: sqlite
45+
provider_id: huggingface
46+
provider_type: remote::huggingface
47+
- config:
48+
kvstore:
49+
db_path: .llama/distributions/ollama/localfs_datasetio.db
50+
namespace: null
51+
type: sqlite
52+
provider_id: localfs
53+
provider_type: inline::localfs
54+
eval:
55+
- config:
56+
kvstore:
57+
db_path: .llama/distributions/ollama/meta_reference_eval.db
58+
namespace: null
59+
type: sqlite
60+
provider_id: meta-reference
61+
provider_type: inline::meta-reference
62+
inference:
63+
- provider_id: openai
64+
provider_type: remote::openai
65+
config:
66+
api_key: ${env.OPENAI_API_KEY}
67+
post_training:
68+
- config:
69+
checkpoint_format: huggingface
70+
device: cpu
71+
distributed_backend: null
72+
provider_id: huggingface
73+
provider_type: inline::huggingface
74+
safety:
75+
- config:
76+
excluded_categories: []
77+
provider_id: llama-guard
78+
provider_type: inline::llama-guard
79+
scoring:
80+
- config: {}
81+
provider_id: basic
82+
provider_type: inline::basic
83+
- config: {}
84+
provider_id: llm-as-judge
85+
provider_type: inline::llm-as-judge
86+
- config:
87+
openai_api_key: '********'
88+
provider_id: braintrust
89+
provider_type: inline::braintrust
90+
telemetry:
91+
- config:
92+
service_name: 'lightspeed-stack-telemetry'
93+
sinks: sqlite
94+
sqlite_db_path: .llama/distributions/ollama/trace_store.db
95+
provider_id: meta-reference
96+
provider_type: inline::meta-reference
97+
tool_runtime:
98+
- provider_id: model-context-protocol
99+
provider_type: remote::model-context-protocol
100+
config: {}
101+
vector_io:
102+
- config:
103+
kvstore:
104+
db_path: .llama/distributions/ollama/faiss_store.db
105+
namespace: null
106+
type: sqlite
107+
provider_id: faiss
108+
provider_type: inline::faiss
109+
scoring_fns: []
110+
server:
111+
auth: null
112+
host: null
113+
port: 8321
114+
quota: null
115+
tls_cafile: null
116+
tls_certfile: null
117+
tls_keyfile: null
118+
shields: []
119+
vector_dbs: []
120+
121+
models:
122+
- model_id: gpt-4-turbo
123+
provider_id: openai
124+
model_type: llm
125+
provider_model_id: gpt-4-turbo

test.containerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ COPY README.md ./
1414
COPY src/ ./src/
1515

1616
RUN microdnf install -y --nodocs --setopt=keepcache=0 --setopt=tsflags=nodocs \
17-
python3.12 python3.12-devel python3.12-pip git tar
17+
python3.12 python3.12-devel python3.12-pip git tar \
18+
gcc gcc-c++ make
1819

1920
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
2021

0 commit comments

Comments
 (0)