def docker_service_up(docker_compose_file, service_name): check.str_param(service_name, "service_name") check.str_param(docker_compose_file, "docker_compose_file") check.invariant(os.path.isfile(docker_compose_file), "docker_compose_file must specify a valid file") if not IS_BUILDKITE: env = os.environ.copy() env["IMAGE_NAME"] = test_project_docker_image() try: subprocess.check_output( [ "docker-compose", "-f", docker_compose_file, "stop", service_name ], env=env, ) subprocess.check_output( [ "docker-compose", "-f", docker_compose_file, "rm", "-f", service_name ], env=env, ) except Exception: # pylint: disable=broad-except pass subprocess.check_output( [ "docker-compose", "-f", docker_compose_file, "up", "-d", service_name ], env=env, )
def dagster_docker_image(): docker_image = test_project_docker_image() if not IS_BUILDKITE: # Being conservative here when first introducing this. This could fail # if the Docker daemon is not running, so for now we just skip the tests using this # fixture if the build fails, and warn with the output from the build command try: client = docker.from_env() client.images.get(docker_image) print( # pylint: disable=print-call "Found existing image tagged {image}, skipping image build. To rebuild, first run: " "docker rmi {image}".format(image=docker_image)) except docker.errors.ImageNotFound: try: build_and_tag_test_image(docker_image) except subprocess.CalledProcessError as exc_info: pytest.skip( "Skipped container tests due to a failure when trying to build the image. " "Most likely, the docker deamon is not running.\n" "Output:\n{}".format(exc_info.output.decode())) return docker_image
def docker_service_up(docker_compose_file, service_name): check.str_param(service_name, 'service_name') check.str_param(docker_compose_file, 'docker_compose_file') check.invariant(os.path.isfile(docker_compose_file), 'docker_compose_file must specify a valid file') if not IS_BUILDKITE: env = os.environ.copy() env["IMAGE_NAME"] = test_project_docker_image() try: subprocess.check_output( [ 'docker-compose', '-f', docker_compose_file, 'stop', service_name ], env=env, ) subprocess.check_output( [ 'docker-compose', '-f', docker_compose_file, 'rm', '-f', service_name ], env=env, ) except Exception: # pylint: disable=broad-except pass subprocess.check_output( [ 'docker-compose', '-f', docker_compose_file, 'up', '-d', service_name ], env=env, ) yield