@@ -16,24 +16,26 @@ PYTHON_VERSION ?= 3.11
1616PROJECT_VERSION ?= v$(shell poetry version -s)
1717
1818# Tools
19- DOCKER_COMPOSE := docker -compose
19+ DOCKER_COMPOSE := podman -compose
2020
2121# Set a default value for VECTOR_DB if not already set
2222VECTOR_DB ?= milvus
2323
2424.DEFAULT_GOAL := help
2525
26- .PHONY : init-env init check-toml format lint audit test run-services build-app run-app clean all info help
26+ .PHONY : init-env init check-toml format lint audit test run-services build-app run-app clean all info help api-test install-deps newman-test run-backend run-frontend
2727
2828init-env :
2929 @touch .env
3030 @echo " PROJECT_NAME=${PROJECT_NAME} " >> .env
3131 @echo " PYTHON_VERSION=${PYTHON_VERSION} " >> .env
3232 @echo " VECTOR_DB=${VECTOR_DB} " >> .env
3333
34- init : init-env
34+ install-deps :
3535 pip install -r requirements.txt
3636
37+ init : init-env install-deps
38+
3739check-toml :
3840 # No equivalent for pip, so this can be left empty or removed
3941
@@ -53,6 +55,18 @@ test: run-services
5355 echo " Waiting for Docker containers to stop..."
5456 @while docker ps | grep -q " milvus-standalone" ; do sleep 1; done
5557
58+ api-test : run-services
59+ pytest $(TEST_DIR ) /api -v -m api || { echo " API Tests failed" ; exit 1; }
60+ @trap ' $(DOCKER_COMPOSE) down' EXIT; \
61+ echo " Waiting for Docker containers to stop..."
62+ @while docker ps | grep -q " milvus-standalone" ; do sleep 1; done
63+
64+ newman-test : run-services
65+ newman run postman/rag_modulo_api_collection.json
66+ @trap ' $(DOCKER_COMPOSE) down' EXIT; \
67+ echo " Waiting for Docker containers to stop..."
68+ @while docker ps | grep -q " milvus-standalone" ; do sleep 1; done
69+
5670create-volumes :
5771 @echo " Creating volume directories with correct permissions..."
5872 @mkdir -p ./volumes/postgres ./volumes/etcd ./volumes/minio ./volumes/milvus
@@ -68,7 +82,7 @@ run-services: create-volumes
6882 $(DOCKER_COMPOSE ) up -d postgres
6983 @echo " Waiting for PostgreSQL to be ready..."
7084 @for i in $$(seq 1 30 ) ; do \
71- if docker-compose exec postgres pg_isready -U ${COLLECTIONDB_USER} -d ${COLLECTIONDB_NAME} ; then \
85+ if $( DOCKER_COMPOSE ) exec postgres pg_isready -U ${COLLECTIONDB_USER} -d ${COLLECTIONDB_NAME} ; then \
7286 echo " PostgreSQL is ready" ; \
7387 break ; \
7488 fi ; \
@@ -85,7 +99,7 @@ run-services: create-volumes
8599 $(DOCKER_COMPOSE ) up -d etcd minio milvus-standalone || { echo " Failed to start Milvus and its dependencies" ; $( DOCKER_COMPOSE) logs; exit 1; }; \
86100 echo " Waiting for Milvus to be ready..." ; \
87101 for i in $$ (seq 1 30); do \
88- if docker-compose exec milvus-standalone curl -s http://localhost:9091/healthz | grep -q " OK" ; then \
102+ if $( DOCKER_COMPOSE ) exec milvus-standalone curl -s http://localhost:9091/healthz | grep -q " OK" ; then \
89103 echo " Milvus is ready" ; \
90104 break ; \
91105 fi ; \
@@ -109,8 +123,6 @@ run-services: create-volumes
109123 echo " Unknown VECTOR_DB value: $( VECTOR_DB) " ; \
110124 exit 1; \
111125 fi
112- @echo " Starting backend and frontend..."
113- $(DOCKER_COMPOSE ) up -d backend frontend
114126 @echo " Docker containers status:"
115127 @docker ps
116128 @echo " Milvus logs saved to milvus.log:"
@@ -120,27 +132,38 @@ run-tests:
120132 $(DOCKER_COMPOSE ) run --rm test pytest $(ARGS )
121133
122134build-frontend :
123- docker build -t $(PROJECT_NAME ) -frontend \
124- -f webui/Dockerfile.frontend ./webui
135+ docker build -t $(PROJECT_NAME ) -frontend -f webui/Dockerfile.frontend ./webui
125136
126137build-backend :
127- docker build -t $(PROJECT_NAME ) -backend \
128- -f Dockerfile.backend .
138+ docker build --build-arg CACHEBUST=$(date +%s ) -t $(PROJECT_NAME ) -backend --no-cache -f Dockerfile.backend .
129139
130140build-app :
131141 @echo " Building application containers..."
132142 $(DOCKER_COMPOSE ) build
133143
134- run-app : build-app run-services
135- @echo " Starting remaining application containers..."
136- $(DOCKER_COMPOSE ) up -d
144+ run-backend : run-services
145+ @echo " Starting backend..."
146+ $(DOCKER_COMPOSE ) up -d backend
147+ @echo " Backend is now running."
148+
149+ run-frontend : run-services
150+ @echo " Starting frontend..."
151+ $(DOCKER_COMPOSE ) up -d frontend
152+ @echo " Frontend is now running."
153+
154+ run-app : build-app run-backend run-frontend
137155 @echo " All application containers are now running."
138156
139157logs :
140158 $(DOCKER_COMPOSE ) logs -f
141159
142160clean :
161+ @echo " Cleaning up Docker Compose resources..."
143162 $(DOCKER_COMPOSE ) down -v
163+ @echo " Cleaning up existing pods and containers..."
164+ -@podman pod rm -f $(podman pod ps -q ) || true
165+ -@podman rm -f $(podman ps -a -q ) || true
166+ -@podman volume prune -f || true
144167 rm -rf .pytest_cache .mypy_cache data volumes my_chroma_data tests
145168
146169all : format lint audit test
@@ -156,15 +179,20 @@ help:
156179 @echo " "
157180 @echo " Targets:"
158181 @echo " init-env Initialize .env file with default values"
159- @echo " init Install dependencies"
182+ @echo " init Initialize environment and install dependencies"
183+ @echo " install-deps Install project dependencies"
160184 @echo " check-toml Check TOML files for syntax errors"
161185 @echo " format Format code using ruff, black, and isort"
162186 @echo " lint Lint code using ruff and mypy"
163187 @echo " audit Audit code using bandit"
164- @echo " test Run tests using pytest"
188+ @echo " test Run all tests using pytest"
189+ @echo " api-test Run API tests using pytest"
190+ @echo " newman-test Run API tests using Newman"
165191 @echo " run-services Start services using Docker Compose"
166192 @echo " build-app Build app using Docker Compose"
167- @echo " run-app Run app using Docker Compose"
193+ @echo " run-backend Run backend using Docker Compose"
194+ @echo " run-frontend Run frontend using Docker Compose"
195+ @echo " run-app Run both backend and frontend using Docker Compose"
168196 @echo " logs View logs of running containers"
169197 @echo " clean Clean up Docker Compose volumes and cache"
170198 @echo " all Format, lint, audit, and test"
0 commit comments