Skip to content

Commit 82e9e8c

Browse files
authored
Merge pull request #88 from goneri/goneri/Makefile-properly-declare-build-s-dependencies-and-more_8398
Makefile: properly declare build's dependencies and more
2 parents 1c116c7 + 0fda7fc commit 82e9e8c

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

Makefile

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Default values for environment variables
44
QUAY_ORG ?=
5-
ANSIBLE_CHATBOT_VERSION ?=
5+
ANSIBLE_CHATBOT_VERSION ?= latest
66
ANSIBLE_CHATBOT_VLLM_URL ?=
77
ANSIBLE_CHATBOT_VLLM_API_TOKEN ?=
88
ANSIBLE_CHATBOT_INFERENCE_MODEL ?=
@@ -17,6 +17,15 @@ LLAMA_STACK_RUN_CONFIG ?= ansible-chatbot-run.yaml
1717
RED := \033[0;31m
1818
NC := \033[0m # No Color
1919

20+
# Choose between docker and podman based on what is available
21+
ifeq (, $(shell which podman))
22+
CONTAINER_RUNTIME ?= docker
23+
else
24+
CONTAINER_RUNTIME ?= podman
25+
endif
26+
27+
28+
2029
.PHONY: help setup build build-custom run clean all deploy-k8s shell tag-and-push
2130

2231
.EXPORT_ALL_VARIABLES:
@@ -36,7 +45,7 @@ help:
3645
@echo " run - Run the Ansible Chatbot Stack container built with 'build-lsc'"
3746
@echo " run-test - Run some sanity checks for the Ansible Chatbot Stack container built with 'build-lsc'"
3847
@echo " run-local-db - Run the Ansible Chatbot Stack container with local DB mapped to conatiner DB"
39-
@echo " clean - Clean up generated files and Docker images"
48+
@echo " clean - Clean up generated files and container images"
4049
@echo " deploy-k8s - Deploy to Kubernetes cluster"
4150
@echo " shell - Get a shell in the container"
4251
@echo " tag-and-push - Tag and push the container image to quay.io"
@@ -52,21 +61,23 @@ help:
5261
@echo " LLAMA_STACK_PORT - Port to expose (default: $(LLAMA_STACK_PORT))"
5362
@echo " QUAY_ORG - Quay organization name (default: $(QUAY_ORG))"
5463

55-
setup: setup-vector-db
64+
setup: setup-vector-db llama-stack/providers.d/inline/agents/lightspeed_inline_agent.yaml
65+
llama-stack/providers.d/inline/agents/lightspeed_inline_agent.yaml:
5666
@echo "Setting up environment..."
5767
uv sync
5868
mkdir -p llama-stack/providers.d/inline/agents/
5969
curl -o llama-stack/providers.d/inline/agents/lightspeed_inline_agent.yaml https://raw.githubusercontent.com/lightspeed-core/lightspeed-providers/refs/heads/main/resources/external_providers/inline/agents/lightspeed_inline_agent.yaml
6070
@echo "Environment setup complete."
6171

62-
setup-vector-db:
72+
setup-vector-db: vector_db/aap_faiss_store.db
73+
vector_db/aap_faiss_store.db:
6374
@echo "Setting up vector db and embedding image..."
6475
rm -rf ./vector_db ./embeddings_model
6576
mkdir -p ./vector_db
66-
docker run --platform $(PLATFORM) -d --rm --name rag-content $(RAG_CONTENT_IMAGE) sleep infinity
67-
docker cp rag-content:/rag/llama_stack_vector_db/faiss_store.db.gz ./vector_db/aap_faiss_store.db.gz
68-
docker cp rag-content:/rag/embeddings_model .
69-
docker kill rag-content
77+
$(CONTAINER_RUNTIME) run --platform $(PLATFORM) -d --rm --name rag-content $(RAG_CONTENT_IMAGE) sleep infinity
78+
$(CONTAINER_RUNTIME) cp rag-content:/rag/llama_stack_vector_db/faiss_store.db.gz ./vector_db/aap_faiss_store.db.gz
79+
$(CONTAINER_RUNTIME) cp rag-content:/rag/embeddings_model .
80+
$(CONTAINER_RUNTIME) kill rag-content
7081
gzip -d ./vector_db/aap_faiss_store.db.gz
7182
# this permission changes will allow the container user 1001 to read/write the files
7283
# in these directories
@@ -80,12 +91,12 @@ check-env-build:
8091
exit 1; \
8192
fi
8293

83-
requirements:
94+
requirements.txt:
8495
uv export --no-hashes --no-header --no-annotate --no-dev --format requirements.txt > requirements.txt
8596

86-
build: check-env-build requirements
97+
build: check-env-build setup requirements.txt
8798
@echo "Building customized Ansible Chatbot Stack image from lightspeed-core/lightspeed-stack..."
88-
docker build --no-cache --platform $(PLATFORM) -f ./Containerfile \
99+
$(CONTAINER_RUNTIME) build --no-cache --platform $(PLATFORM) -f ./Containerfile \
89100
--build-arg ANSIBLE_CHATBOT_VERSION=$(ANSIBLE_CHATBOT_VERSION) \
90101
--build-arg LLAMA_STACK_RUN_CONFIG=$(LLAMA_STACK_RUN_CONFIG) \
91102
-t ansible-chatbot-stack:$(ANSIBLE_CHATBOT_VERSION) .
@@ -114,7 +125,7 @@ run: check-env-run
114125
@echo "Running Ansible Chatbot Stack container..."
115126
@echo "Using vLLM URL: $(ANSIBLE_CHATBOT_VLLM_URL)"
116127
@echo "Using inference model: $(ANSIBLE_CHATBOT_INFERENCE_MODEL)"
117-
docker run --platform $(PLATFORM) --security-opt label=disable -it -p $(LLAMA_STACK_PORT):8080 \
128+
$(CONTAINER_RUNTIME) run --platform $(PLATFORM) --security-opt label=disable -it -p $(LLAMA_STACK_PORT):8080 \
118129
-v ./embeddings_model:/.llama/data/embeddings_model \
119130
-v ./vector_db/aap_faiss_store.db:$(CONTAINER_DB_PATH)/aap_faiss_store.db \
120131
-v ./$(LIGHTSPEED_STACK_CONFIG):/.llama/distributions/ansible-chatbot/config/lightspeed-stack.yaml \
@@ -152,7 +163,7 @@ run-local-db: check-env-run-local-db
152163
@echo "Using inference model: $(ANSIBLE_CHATBOT_INFERENCE_MODEL)"
153164
@echo "Using inference model for tools filtering : $(ANSIBLE_CHATBOT_INFERENCE_MODEL_FILTER)"
154165
@echo "Mapping local DB from $(LOCAL_DB_PATH) to $(CONTAINER_DB_PATH)"
155-
docker run --platform $(PLATFORM) --security-opt label=disable -it -p $(LLAMA_STACK_PORT):8080 \
166+
$(CONTAINER_RUNTIME) run --platform $(PLATFORM) --security-opt label=disable -it -p $(LLAMA_STACK_PORT):8080 \
156167
-v $(LOCAL_DB_PATH):$(CONTAINER_DB_PATH) \
157168
-v ./embeddings_model:/app/embeddings_model \
158169
-v ./vector_db/aap_faiss_store.db:$(CONTAINER_DB_PATH)/aap_faiss_store.db \
@@ -172,10 +183,11 @@ clean:
172183
rm -rf llama-stack/
173184
rm -rf providers.d/
174185
rm -rf work/
186+
rm -f requirements.txt
175187
@echo "Removing ansible-chatbot-stack images..."
176-
docker rmi -f $$(docker images -a -q --filter reference=ansible-chatbot-stack) || true
188+
$(CONTAINER_RUNTIME) rmi -f $$($(CONTAINER_RUNTIME) images -a -q --filter reference=ansible-chatbot-stack) || true
177189
@echo "Removing ansible-chatbot-stack containers..."
178-
docker rm -f $$(docker ps -a -q --filter ancestor=ansible-chatbot-stack) || true
190+
$(CONTAINER_RUNTIME) rm -f $$($(CONTAINER_RUNTIME) ps -a -q --filter ancestor=ansible-chatbot-stack) || true
179191
@echo "Clean-up complete."
180192

181193
deploy-k8s:
@@ -187,7 +199,7 @@ deploy-k8s:
187199

188200
shell:
189201
@echo "Getting a shell in the container..."
190-
docker run --security-opt label=disable -it --entrypoint /bin/bash ansible-chatbot-stack:$(ANSIBLE_CHATBOT_VERSION)
202+
$(CONTAINER_RUNTIME) run --security-opt label=disable -it --entrypoint /bin/bash ansible-chatbot-stack:$(ANSIBLE_CHATBOT_VERSION)
191203

192204
# Pre-check required environment variables for tag-and-push
193205
check-env-tag-and-push:
@@ -203,11 +215,11 @@ check-env-tag-and-push:
203215
tag-and-push: check-env-tag-and-push
204216
@echo "Logging in to quay.io..."
205217
@echo "Please enter your quay.io credentials when prompted"
206-
docker login quay.io
218+
$(CONTAINER_RUNTIME) login quay.io
207219
@echo "Tagging image ansible-chatbot-stack:$(ANSIBLE_CHATBOT_VERSION)"
208-
docker tag ansible-chatbot-stack:$(ANSIBLE_CHATBOT_VERSION) quay.io/$(QUAY_ORG)/ansible-chatbot-stack:$(ANSIBLE_CHATBOT_VERSION)
220+
$(CONTAINER_RUNTIME) tag ansible-chatbot-stack:$(ANSIBLE_CHATBOT_VERSION) quay.io/$(QUAY_ORG)/ansible-chatbot-stack:$(ANSIBLE_CHATBOT_VERSION)
209221
@echo "Pushing image to quay.io..."
210-
docker push quay.io/$(QUAY_ORG)/ansible-chatbot-stack:$(ANSIBLE_CHATBOT_VERSION)
222+
$(CONTAINER_RUNTIME) push quay.io/$(QUAY_ORG)/ansible-chatbot-stack:$(ANSIBLE_CHATBOT_VERSION)
211223
@echo "Image successfully pushed to quay.io/$(QUAY_ORG)/ansible-chatbot-stack:$(ANSIBLE_CHATBOT_VERSION)"
212224

213225
all: setup build build-custom

0 commit comments

Comments
 (0)