Merge 3aef5868fb
into 1da623019f
This commit is contained in:
commit
bf36ab2c2d
6 changed files with 22 additions and 8 deletions
|
@ -310,6 +310,9 @@ def get_nginx_conf_from_container(container: Container) -> bytes:
|
||||||
return conffile.read()
|
return conffile.read()
|
||||||
|
|
||||||
|
|
||||||
|
class DockerComposeException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
def __prepare_and_execute_compose_cmd(compose_files: List[str], project_name: str, cmd: str):
|
def __prepare_and_execute_compose_cmd(compose_files: List[str], project_name: str, cmd: str):
|
||||||
"""
|
"""
|
||||||
Prepare and execute the Docker Compose command with the provided compose files and project name.
|
Prepare and execute the Docker Compose command with the provided compose files and project name.
|
||||||
|
@ -325,7 +328,7 @@ def __prepare_and_execute_compose_cmd(compose_files: List[str], project_name: st
|
||||||
try:
|
try:
|
||||||
subprocess.check_output(shlex.split(compose_cmd.getvalue()), stderr=subprocess.STDOUT)
|
subprocess.check_output(shlex.split(compose_cmd.getvalue()), stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
pytest.fail(f"Error while running '{compose_cmd.getvalue()}':\n{e.output}", pytrace=False)
|
raise DockerComposeException(f"Error while running '{compose_cmd.getvalue()}':\n{e.output}")
|
||||||
|
|
||||||
|
|
||||||
def docker_compose_up(compose_files: List[str], project_name: str):
|
def docker_compose_up(compose_files: List[str], project_name: str):
|
||||||
|
@ -334,7 +337,14 @@ def docker_compose_up(compose_files: List[str], project_name: str):
|
||||||
"""
|
"""
|
||||||
if compose_files is None or len(compose_files) == 0:
|
if compose_files is None or len(compose_files) == 0:
|
||||||
pytest.fail(f"No compose file passed to docker_compose_up", pytrace=False)
|
pytest.fail(f"No compose file passed to docker_compose_up", pytrace=False)
|
||||||
__prepare_and_execute_compose_cmd(compose_files, project_name, cmd="up --detach")
|
try:
|
||||||
|
__prepare_and_execute_compose_cmd(compose_files, project_name, cmd="up --detach")
|
||||||
|
except DockerComposeException as e:
|
||||||
|
try:
|
||||||
|
docker_compose_down(compose_files, project_name)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
pytest.fail(str(e), pytrace=False)
|
||||||
|
|
||||||
|
|
||||||
def docker_compose_down(compose_files: List[str], project_name: str):
|
def docker_compose_down(compose_files: List[str], project_name: str):
|
||||||
|
@ -616,5 +626,5 @@ try:
|
||||||
except docker.errors.ImageNotFound:
|
except docker.errors.ImageNotFound:
|
||||||
pytest.exit("The docker image 'nginxproxy/nginx-proxy:test' is missing")
|
pytest.exit("The docker image 'nginxproxy/nginx-proxy:test' is missing")
|
||||||
|
|
||||||
if Version(docker.__version__) < Version("7.0.0"):
|
if Version(docker.__version__) < Version("5.0.0"):
|
||||||
pytest.exit("This test suite is meant to work with the python docker module v7.0.0 or later")
|
pytest.exit("This test suite is meant to work with the python docker module v5.0.0 or later")
|
||||||
|
|
|
@ -27,4 +27,4 @@ services:
|
||||||
- "83"
|
- "83"
|
||||||
environment:
|
environment:
|
||||||
WEB_PORTS: "83"
|
WEB_PORTS: "83"
|
||||||
VIRTUAL_HOST: ~^regex.*\.nginx-proxy\.example$
|
VIRTUAL_HOST: ~^regex.*\.nginx-proxy\.example$$
|
||||||
|
|
|
@ -27,4 +27,4 @@ services:
|
||||||
- "83"
|
- "83"
|
||||||
environment:
|
environment:
|
||||||
WEB_PORTS: "83"
|
WEB_PORTS: "83"
|
||||||
VIRTUAL_HOST: ~^regex.*\.nginx-proxy\.example$
|
VIRTUAL_HOST: ~^regex.*\.nginx-proxy\.example$$
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
services:
|
services:
|
||||||
nginx-proxy:
|
nginx-proxy:
|
||||||
|
image: nginxproxy/nginx-proxy:test
|
||||||
|
container_name: nginx-proxy
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||||
environment:
|
environment:
|
||||||
HTTP_PORT: 8888
|
HTTP_PORT: 8888
|
||||||
network_mode: host
|
network_mode: host
|
|
@ -5,4 +5,4 @@ services:
|
||||||
- "80"
|
- "80"
|
||||||
environment:
|
environment:
|
||||||
WEB_PORTS: "80"
|
WEB_PORTS: "80"
|
||||||
VIRTUAL_HOST: ~^regex.*\.nginx-proxy\.example$
|
VIRTUAL_HOST: ~^regex.*\.nginx-proxy\.example$$
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
services:
|
services:
|
||||||
nginx-proxy:
|
nginx-proxy:
|
||||||
environment:
|
environment:
|
||||||
DISABLE_ACCESS_LOGS: true
|
DISABLE_ACCESS_LOGS: "true"
|
||||||
|
|
||||||
web1:
|
web1:
|
||||||
image: web
|
image: web
|
||||||
|
|
Loading…
Reference in a new issue