Fix missing docker-compose (#2899)

Fix missing `docker-compose` command if only `docker compose` (note
space) is available.
This commit is contained in:
Maciej Pióro 2023-04-16 01:05:11 +02:00 committed by GitHub
parent b634489b2e
commit f7bf917baf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
"""Script to run langchain-server locally using docker-compose.""" """Script to run langchain-server locally using docker-compose."""
import shutil
import subprocess import subprocess
from pathlib import Path from pathlib import Path
@ -6,8 +7,14 @@ from pathlib import Path
def main() -> None: def main() -> None:
"""Run the langchain server locally.""" """Run the langchain server locally."""
p = Path(__file__).absolute().parent / "docker-compose.yaml" p = Path(__file__).absolute().parent / "docker-compose.yaml"
subprocess.run(["docker-compose", "-f", str(p), "pull"])
subprocess.run(["docker-compose", "-f", str(p), "up"]) if shutil.which("docker-compose") is None:
docker_compose_command = ["docker", "compose"]
else:
docker_compose_command = ["docker-compose"]
subprocess.run([*docker_compose_command, "-f", str(p), "pull"])
subprocess.run([*docker_compose_command, "-f", str(p), "up"])
if __name__ == "__main__": if __name__ == "__main__":