Skip to content

Commit 7bf5687

Browse files
callamdSergeyPirogov
authored andcommitted
#29 specify docker-compose file (#39)
* Fix #29 run compose files which aren't `docker-compose.yml` * Add -f flag to stop too
1 parent dc956cc commit 7bf5687

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

testcontainers/compose.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99

1010
class DockerCompose(object):
11-
def __init__(self, filepath):
11+
def __init__(self, filepath, compose_file_name="docker-compose.yml"):
1212
self.filepath = filepath
13+
self.compose_file_name = compose_file_name
1314

1415
def __enter__(self):
1516
return self.start()
@@ -19,11 +20,11 @@ def __exit__(self, exc_type, exc_val, exc_tb):
1920

2021
def start(self):
2122
with blindspin.spinner():
22-
subprocess.call(["docker-compose", "up", "-d"], cwd=self.filepath)
23+
subprocess.call(["docker-compose", "-f", self.compose_file_name, "up", "-d"], cwd=self.filepath)
2324

2425
def stop(self):
2526
with blindspin.spinner():
26-
subprocess.call(["docker-compose", "down", "-v"],
27+
subprocess.call(["docker-compose", "-f", self.compose_file_name, "down", "-v"],
2728
cwd=self.filepath)
2829

2930
def get_service_port(self, service_name, port):

0 commit comments

Comments
 (0)