@@ -104,32 +104,32 @@ def _get_service_url(self, service: str) -> str:
104104 return f"http://localhost:{ port } "
105105
106106 def is_docker_available (self ) -> bool :
107- """Check if Docker or Podman is available."""
108- # Try Docker first
107+ """Check if Podman or Docker is available, prioritizing Podman ."""
108+ # Try Podman first (Podman shop priority)
109109 try :
110110 result = subprocess .run (
111- ["docker " , "--version" ], capture_output = True , text = True , timeout = 5
111+ ["podman " , "--version" ], capture_output = True , text = True , timeout = 5
112112 )
113113 if result .returncode == 0 :
114114 return True
115115 except (subprocess .TimeoutExpired , FileNotFoundError ):
116116 pass
117117
118- # Try Podman as fallback
118+ # Try Docker as fallback
119119 try :
120120 result = subprocess .run (
121- ["podman " , "--version" ], capture_output = True , text = True , timeout = 5
121+ ["docker " , "--version" ], capture_output = True , text = True , timeout = 5
122122 )
123123 return result .returncode == 0
124124 except (subprocess .TimeoutExpired , FileNotFoundError ):
125125 return False
126126
127127 def is_compose_available (self ) -> bool :
128- """Check if Docker Compose or Podman Compose is available."""
129- # Try docker compose (new syntax )
128+ """Check if Podman Compose or Docker Compose is available, prioritizing Podman ."""
129+ # Try podman- compose first (Podman shop priority )
130130 try :
131131 result = subprocess .run (
132- ["docker" , " compose" , "version" ],
132+ ["podman- compose" , "-- version" ],
133133 capture_output = True ,
134134 text = True ,
135135 timeout = 5 ,
@@ -139,10 +139,10 @@ def is_compose_available(self) -> bool:
139139 except (subprocess .TimeoutExpired , FileNotFoundError ):
140140 pass
141141
142- # Try docker- compose (old syntax)
142+ # Try docker compose (new syntax)
143143 try :
144144 result = subprocess .run (
145- ["docker- compose" , "-- version" ],
145+ ["docker" , " compose" , "version" ],
146146 capture_output = True ,
147147 text = True ,
148148 timeout = 5 ,
@@ -152,10 +152,10 @@ def is_compose_available(self) -> bool:
152152 except (subprocess .TimeoutExpired , FileNotFoundError ):
153153 pass
154154
155- # Try podman -compose
155+ # Try docker -compose (old syntax)
156156 try :
157157 result = subprocess .run (
158- ["podman -compose" , "--version" ],
158+ ["docker -compose" , "--version" ],
159159 capture_output = True ,
160160 text = True ,
161161 timeout = 5 ,
@@ -165,8 +165,18 @@ def is_compose_available(self) -> bool:
165165 return False
166166
167167 def get_compose_command (self ) -> List [str ]:
168- """Get the appropriate docker compose command."""
169- # Prefer docker compose (new syntax)
168+ """Get the appropriate compose command, prioritizing Podman."""
169+ # Prefer podman-compose (Podman shop priority)
170+ try :
171+ result = subprocess .run (
172+ ["podman-compose" , "--version" ], capture_output = True , timeout = 5
173+ )
174+ if result .returncode == 0 :
175+ return ["podman-compose" ]
176+ except (subprocess .TimeoutExpired , FileNotFoundError ):
177+ pass
178+
179+ # Try docker compose (new syntax)
170180 try :
171181 result = subprocess .run (
172182 ["docker" , "compose" , "version" ], capture_output = True , timeout = 5
@@ -176,7 +186,7 @@ def get_compose_command(self) -> List[str]:
176186 except (subprocess .TimeoutExpired , FileNotFoundError ):
177187 pass
178188
179- # Try docker-compose (old syntax)
189+ # Fall back to docker-compose (old syntax)
180190 try :
181191 result = subprocess .run (
182192 ["docker-compose" , "--version" ], capture_output = True , timeout = 5
@@ -186,7 +196,7 @@ def get_compose_command(self) -> List[str]:
186196 except (subprocess .TimeoutExpired , FileNotFoundError ):
187197 pass
188198
189- # Fall back to podman-compose
199+ # Last resort fallback
190200 return ["podman-compose" ]
191201
192202 def _find_project_root (self ) -> Path :
@@ -231,67 +241,6 @@ def _find_dockerfile(self, dockerfile_name: str) -> Path:
231241 project_dockerfile = project_root / dockerfile_name
232242 return project_dockerfile # Return this even if it doesn't exist for error messages
233243
234- def create_compose_file (self , data_dir : Path = Path (".code-indexer" )) -> None :
235- """Create docker-compose.yml file."""
236- # Find Dockerfiles (package location first, then project root)
237- ollama_dockerfile = self ._find_dockerfile ("Dockerfile.ollama" )
238- qdrant_dockerfile = self ._find_dockerfile ("Dockerfile.qdrant" )
239-
240- compose_config = {
241- "services" : {
242- "ollama" : {
243- "build" : {
244- "context" : str (ollama_dockerfile .parent ),
245- "dockerfile" : str (ollama_dockerfile .name ),
246- },
247- "container_name" : f"code-ollama-{ self .project_name } " ,
248- "volumes" : [f"{ data_dir } /ollama:/root/.ollama" ],
249- "restart" : "unless-stopped" ,
250- "healthcheck" : {
251- "test" : [
252- "CMD" ,
253- "curl" ,
254- "-f" ,
255- "http://localhost:11434/api/tags" ,
256- ],
257- "interval" : "30s" ,
258- "timeout" : "10s" ,
259- "retries" : 3 ,
260- "start_period" : "30s" ,
261- },
262- },
263- "qdrant" : {
264- "build" : {
265- "context" : str (qdrant_dockerfile .parent ),
266- "dockerfile" : str (qdrant_dockerfile .name ),
267- },
268- "container_name" : f"code-qdrant-{ self .project_name } " ,
269- "volumes" : [f"{ data_dir } /qdrant:/qdrant/storage" ],
270- "environment" : ["QDRANT_ALLOW_ANONYMOUS_READ=true" ],
271- "restart" : "unless-stopped" ,
272- "healthcheck" : {
273- "test" : [
274- "CMD" ,
275- "curl" ,
276- "-f" ,
277- "http://localhost:6333/" ,
278- ],
279- "interval" : "30s" ,
280- "timeout" : "10s" ,
281- "retries" : 3 ,
282- "start_period" : "40s" ,
283- },
284- },
285- },
286- "networks" : {"default" : {"name" : f"code-indexer-{ self .project_name } " }},
287- }
288-
289- # Ensure data directory exists
290- data_dir .mkdir (parents = True , exist_ok = True )
291-
292- with open (self .compose_file , "w" ) as f :
293- yaml .dump (compose_config , f , default_flow_style = False )
294-
295244 def start_services (self , recreate : bool = False ) -> bool :
296245 """Start Docker services."""
297246 if not self .compose_file .exists ():
@@ -725,6 +674,18 @@ def generate_compose_config(
725674 ollama_dockerfile = self ._find_dockerfile ("Dockerfile.ollama" )
726675 qdrant_dockerfile = self ._find_dockerfile ("Dockerfile.qdrant" )
727676
677+ # Copy Dockerfiles to temporary directory so Docker can find them
678+ import tempfile
679+ import shutil
680+
681+ # Create a temporary directory for Dockerfiles
682+ temp_docker_dir = Path (tempfile .mkdtemp (prefix = "code-indexer-docker-" ))
683+ local_ollama_dockerfile = temp_docker_dir / "Dockerfile.ollama"
684+ local_qdrant_dockerfile = temp_docker_dir / "Dockerfile.qdrant"
685+
686+ shutil .copy2 (ollama_dockerfile , local_ollama_dockerfile )
687+ shutil .copy2 (qdrant_dockerfile , local_qdrant_dockerfile )
688+
728689 # Get global configuration directory
729690 global_config_dir = Path .home () / ".code-indexer" / "global"
730691
@@ -735,8 +696,8 @@ def generate_compose_config(
735696 "services" : {
736697 "ollama" : {
737698 "build" : {
738- "context" : str (ollama_dockerfile . parent ),
739- "dockerfile" : str (ollama_dockerfile .name ),
699+ "context" : str (temp_docker_dir ),
700+ "dockerfile" : str (local_ollama_dockerfile .name ),
740701 },
741702 "container_name" : "code-indexer-ollama" ,
742703 "ports" : ["11434:11434" ], # External port mapping
@@ -758,8 +719,8 @@ def generate_compose_config(
758719 },
759720 "qdrant" : {
760721 "build" : {
761- "context" : str (qdrant_dockerfile . parent ),
762- "dockerfile" : str (qdrant_dockerfile .name ),
722+ "context" : str (temp_docker_dir ),
723+ "dockerfile" : str (local_qdrant_dockerfile .name ),
763724 },
764725 "container_name" : "code-indexer-qdrant" ,
765726 "ports" : ["6333:6333" ], # External port mapping
0 commit comments