def instance_container_with_unpacked_tgz(docker_client, tmpdir, tgz_archive_with_cartridge, request): project = tgz_archive_with_cartridge.project # build image with installed Tarantool build_path = os.path.join(tmpdir, 'build_image') os.makedirs(build_path) dockerfile_layers = ["FROM centos:7"] if not tarantool_enterprise_is_used(): tarantool_installer = get_tarantool_installer_cmd("yum") dockerfile_layers.append(f"RUN {tarantool_installer}") with open(os.path.join(build_path, 'Dockerfile'), 'w') as f: f.write('\n'.join(dockerfile_layers)) image_name = '%s-test-tgz' % project.name build_image(build_path, image_name) request.addfinalizer(lambda: delete_image(docker_client, image_name)) # create container instance_name = 'instance-1' http_port = '8183' advertise_port = '3302' environment = [ 'TARANTOOL_APP_NAME=%s' % project.name, 'TARANTOOL_INSTANCE_NAME=%s' % instance_name, 'TARANTOOL_ADVERTISE_URI=%s' % advertise_port, 'TARANTOOL_HTTP_PORT=%s' % http_port, ] container_proj_path = os.path.join('/opt', project.name) init_script_path = os.path.join(container_proj_path, 'init.lua') tarantool_executable = \ os.path.join(container_proj_path, 'tarantool') \ if tarantool_enterprise_is_used() \ else 'tarantool' cmd = [tarantool_executable, init_script_path] container = docker_client.containers.create( image_name, cmd, environment=environment, ports={http_port: http_port}, name='{}-{}'.format(project.name, instance_name), detach=True, ) with gzip.open(tgz_archive_with_cartridge.filepath, 'rb') as f: container.put_archive('/opt', f.read()) request.addfinalizer(lambda: container.remove(force=True)) return InstanceContainer(container=container, instance_name=instance_name, http_port=http_port, advertise_port=advertise_port)
def custom_base_image(session_tmpdir): image_name = "my-custom-centos8" custom_image_path = os.path.join(session_tmpdir, 'Dockerfile') with open(custom_image_path, 'w') as f: f.write("FROM centos:8") build_image(session_tmpdir, image_name) return {"image_name": image_name}
def container_with_installed_deb(docker_client, deb_archive_with_cartridge, request, tmpdir): project = deb_archive_with_cartridge.project # build image with installed DEB build_path = os.path.join(tmpdir, 'build_image') os.makedirs(build_path) shutil.copy(deb_archive_with_cartridge.filepath, build_path) dockerfile_layers = ["FROM jrei/systemd-ubuntu"] if not tarantool_enterprise_is_used(): dockerfile_layers.append( '''RUN apt-get update && apt-get install -y curl \ && DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata \ && curl -s \ https://packagecloud.io/install/repositories/tarantool/{}/script.deb.sh | bash '''.format(tarantool_repo_version())) dockerfile_layers.append(''' COPY {deb_filename} /opt RUN apt-get install -y /opt/{deb_filename} '''.format( deb_filename=os.path.basename(deb_archive_with_cartridge.filepath))) with open(os.path.join(build_path, 'Dockerfile'), 'w') as f: f.write('\n'.join(dockerfile_layers)) image_name = '%s-test-deb' % project.name build_image(build_path, image_name) request.addfinalizer(lambda: delete_image(docker_client, image_name)) # create container http_port = '8183' container = docker_client.containers.create( image_name, command='/lib/systemd/systemd', ports={http_port: http_port}, name='%s-test-deb' % project.name, detach=True, privileged=True, volumes=['/sys/fs/cgroup:/sys/fs/cgroup:ro'], ) request.addfinalizer(lambda: container.remove(force=True)) return ProjectContainer(project=project, container=container, http_port=http_port)
def container_with_installed_rpm(docker_client, rpm_archive_with_cartridge, request, tmpdir): project = rpm_archive_with_cartridge.project # build image with installed RPM build_path = os.path.join(tmpdir, 'build_image') os.makedirs(build_path) shutil.copy(rpm_archive_with_cartridge.filepath, build_path) dockerfile_layers = ["FROM centos:7"] if not tarantool_enterprise_is_used(): installer_cmd = get_tarantool_installer_cmd("yum") dockerfile_layers.append(f"RUN {installer_cmd}") else: dockerfile_layers.append("RUN yum update -y") dockerfile_layers.append(''' COPY {rpm_filename} /opt RUN yum install -y /opt/{rpm_filename} '''.format( rpm_filename=os.path.basename(rpm_archive_with_cartridge.filepath))) with open(os.path.join(build_path, 'Dockerfile'), 'w') as f: f.write('\n'.join(dockerfile_layers)) image_name = '%s-test-rpm' % project.name build_image(build_path, image_name) request.addfinalizer(lambda: delete_image(docker_client, image_name)) # create container http_port = '8183' container = docker_client.containers.create( image_name, command='/sbin/init', ports={http_port: http_port}, name='%s-test-rpm' % project.name, detach=True, privileged=True, volumes=['/sys/fs/cgroup:/sys/fs/cgroup:ro'], ) request.addfinalizer(lambda: container.remove(force=True)) return ProjectContainer(project=project, container=container, http_port=http_port)
def image_name_for_tests(docker_client, tmpdir, request): if tarantool_enterprise_is_used(): docker_client.images.pull('centos', '8') return 'centos:8' build_path = os.path.join(tmpdir, 'build_image') os.makedirs(build_path) test_image_dockerfile_path = os.path.join(build_path, 'Dockerfile') with open(test_image_dockerfile_path, 'w') as f: f.write(''' FROM centos:8 RUN curl -s \ https://packagecloud.io/install/repositories/tarantool/{}/script.rpm.sh | bash \ && yum -y install tarantool tarantool-devel '''.format(tarantool_repo_version())) image_name = 'test-image' build_image(build_path, image_name) request.addfinalizer(lambda: delete_image(docker_client, image_name)) return image_name
def setUp(self): self.image = "confluentinc/cp-kafka" utils.build_image(self.image, get_dockerfile_path("debian/base")) utils.build_image(self.image, get_dockerfile_path("debian/kafka"))
def setUp(self): self.image = "confluentinc/cp-zookeeper" utils.build_image(self.image, get_dockerfile_path("debian/base")) utils.build_image(self.image, get_dockerfile_path("debian/zookeeper"))
def setUp(self): self.image = "confluentinc/control-center" utils.build_image(self.image, get_dockerfile_path("debian/base")) utils.build_image(self.image, get_dockerfile_path("debian/control-center"))
def setUp(self): self.image = "confluentinc/cp-schema-registry" utils.build_image(self.image, get_dockerfile_path("debian/base")) utils.build_image(self.image, get_dockerfile_path("debian/schema-registry"))