Used only to write a Dockerfile that will NOT be built by docker-make
183101
def write_dockerfile(self, output_dir):
        
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)

        lines = []
        for istep, step in enumerate(self.steps):
            if istep == 0:
                lines.extend(step.dockerfile_lines)
            else:
                lines.extend(step.dockerfile_lines[1:])
        path = os.path.join(output_dir, 'Dockerfile.%s' % self.imagename)
        with open(path, 'w') as outfile:
            outfile.write('\n'.join(lines))
        print('Wrote %s' % path)
1035664
def build_docker_sshd(ctx):
    
    dinfo = DOCKER_SSHD_IMG
    ctx.run('docker rmi -f {0}'.format(dinfo['name']), warn=True)
    ctx.run('docker build -t {0} {1}'.format(dinfo['name'], dinfo['path']))
597620
def build(config, services):
    
    filtered_services = {name: service for name, service in services.iteritems() if 'build' in service}

    _call_output('docker-compose build {}'.format(' '.join(filtered_services.iterkeys())))

    version = _get_version()

    for service_name, service_dict in filtered_services.iteritems():
        # Tag with proper version, they're already tagged latest from build
        image = service_dict['image']
        _call('docker tag {image}:latest {image}:{version}'.format(
                image=image,
                version=version
            )
        )
208373
def _build_save_container(platform, registry, load_cache) -> Optional[str]:
    
    docker_tag = build_util.get_docker_tag(platform=platform, registry=registry)

    # Preload cache
    if load_cache:
        load_docker_cache(registry=registry, docker_tag=docker_tag)

    # Start building
    logging.debug('Building %s as %s', platform, docker_tag)
    try:
        # Increase the number of retries for building the cache.
        image_id = build_util.build_docker(docker_binary='docker', platform=platform, registry=registry, num_retries=10, no_cache=False)
        logging.info('Built %s as %s', docker_tag, image_id)

        # Push cache to registry
        _upload_image(registry=registry, docker_tag=docker_tag, image_id=image_id)
        return None
    except Exception:
        logging.exception('Unexpected exception during build of %s', docker_tag)
        return platform
308297
def rm(self, container_alias):

        '''
            
        '''

        title = '%s.rm' % self.__class__.__name__

    # validate inputs
        input_fields = {
            'container_alias': container_alias
        }
        for key, value in input_fields.items():
            object_title = '%s(%s=%s)' % (title, key, str(value))
            self.fields.validate(value, '.%s' % key, object_title)

    # run remove command
        sys_cmd = 'docker rm -f %s' % container_alias
        output_lines = self.command(sys_cmd).split('\n')

        return output_lines[0]
399127
def exclude_paths(root, patterns, dockerfile=None):
    

    if dockerfile is None:
        dockerfile = 'Dockerfile'

    patterns.append('!' + dockerfile)
    pm = PatternMatcher(patterns)
    return set(pm.walk(root))
839517
function docker(cwd, cmd) {
  console.log(cwd, chalk.blue('running docker', cmd));
  return spawn('docker', (cmd || 'build .').split(' '), {cwd, env});
}
398053
private File createBuildTarBall(BuildDirs buildDirs, List<ArchiverCustomizer> archiverCustomizers,
                                    AssemblyConfiguration assemblyConfig, ArchiveCompression compression) throws MojoExecutionException {
        File archive = new File(buildDirs.getTemporaryRootDirectory(), "docker-build." + compression.getFileSuffix());
        try {
            TarArchiver archiver = createBuildArchiver(buildDirs.getOutputDirectory(), archive, assemblyConfig);
            for (ArchiverCustomizer customizer : archiverCustomizers) {
                if (customizer != null) {
                    archiver = customizer.customize(archiver);
                }
            }
            archiver.setCompression(compression.getTarCompressionMethod());
            archiver.createArchive();
            return archive;
        } catch (NoSuchArchiverException e) {
            throw new MojoExecutionException("No archiver for type 'tar' found", e);
        } catch (IOException e) {
            throw new MojoExecutionException("Cannot create archive " + archive, e);
        }
    }
69736
def shell(cmd):
    ""
    try:
        return subprocess.check_output(['docker'] + cmd, stderr=subprocess.STDOUT).decode('utf8').strip()
    except subprocess.CalledProcessError:
        return None
1136787
def makefile(self, sock, mode='r', bufsize=-1):
        """"""
        cls = (
            SSLFileobjectStreamReader
            if 'r' in mode else
            SSLFileobjectStreamWriter
        )
        if SSL and isinstance(sock, ssl_conn_type):
            wrapped_socket = cls(sock, mode, bufsize)
            wrapped_socket.ssl_timeout = sock.gettimeout()
            return wrapped_socket
        # This is from past:
        # TODO: figure out what it's meant for
        else:
            return cheroot_server.CP_fileobject(sock, mode, bufsize)
210831
def create_build_context(image, inputs, wdir):
    
    assert os.path.isabs(wdir)

    dockerlines = ["FROM %s" % image,
                    "RUN mkdir -p %s" % wdir]
    build_context = {}

    # This loop creates a Build Context for building the provisioned image
    # We create a tar archive to be added to the root of the image filesystem
    if inputs:
        dockerlines.append('COPY root /')
        for ifile, (path, obj) in enumerate(inputs.items()):
            if not os.path.isabs(path):
                path = os.path.join(wdir, path)
            assert path[0] == '/'
            build_context['root' + path] = obj

    dockerstring = '\n'.join(dockerlines)
    build_context['Dockerfile'] = pyccc.BytesContainer(dockerstring.encode('utf-8'))
    return build_context
1171182
function writeFile (outDir, vars, file) {
  return function (done) {
    const fileName = file.path
    const inFile = file.fullPath
    const parentDir = file.parentDir
    const outFile = path.join(outDir, maxstache(removeUnderscore(fileName), vars))

    mkdirp(path.join(outDir, maxstache(parentDir, vars)), function (err) {
      if (err) return done(err)

      const rs = fs.createReadStream(inFile)
      const ts = maxstacheStream(vars)
      const ws = fs.createWriteStream(outFile)

      pump(rs, ts, ws, done)
    })
  }
}
1051704
def write_makeconfig(_path):
    
    http_proxy = str(CFG["gentoo"]["http_proxy"])
    ftp_proxy = str(CFG["gentoo"]["ftp_proxy"])
    rsync_proxy = str(CFG["gentoo"]["rsync_proxy"])

    path.mkfile_uchroot(local.path('/') / _path)
    with open(_path, 'w') as makeconf:
        lines = '''
PORTAGE_USERNAME=root
PORTAGE_GROUPNAME=root
CFLAGS="-O2 -pipe"
CXXFLAGS="${CFLAGS}"
FEATURES="nostrip -xattr"
CHOST="x86_64-pc-linux-gnu"
USE="bindist mmx sse sse2"
PORTDIR="/usr/portage"
DISTDIR="/mnt/distfiles"
PKGDIR="${PORTDIR}/packages"
'''

        makeconf.write(lines)

        mounts = CFG["container"]["mounts"].value
        tmp_dir = str(CFG["tmp_dir"])
        mounts.append({"src": tmp_dir, "tgt": "/mnt/distfiles"})
        CFG["container"]["mounts"] = mounts

        if http_proxy is not None:
            http_s = "http_proxy={0}".format(http_proxy)
            https_s = "https_proxy={0}".format(http_proxy)
            makeconf.write(http_s + "\n")
            makeconf.write(https_s + "\n")

        if ftp_proxy is not None:
            fp_s = "ftp_proxy={0}".format(ftp_proxy)
            makeconf.write(fp_s + "\n")

        if rsync_proxy is not None:
            rp_s = "RSYNC_PROXY={0}".format(rsync_proxy)
            makeconf.write(rp_s + "\n")
481962
def build(self, shutit):
		
		if shutit.build['delivery'] in ('docker','dockerfile'):
			if shutit.get_current_shutit_pexpect_session_environment().install_type == 'apt':
				shutit.add_to_bashrc('export DEBIAN_FRONTEND=noninteractive')
				if not shutit.command_available('lsb_release'):
					shutit.install('lsb-release')
				shutit.lsb_release()
			elif shutit.get_current_shutit_pexpect_session_environment().install_type == 'yum':
				# yum updates are so often "bad" that we let exit codes of 1 through.
				# TODO: make this more sophisticated
				shutit.send('yum update -y', timeout=9999, exit_values=['0', '1'])
			shutit.pause_point('Anything you want to do to the target host ' + 'before the build starts?', level=2)
		return True
513060
def write(name, value):
    
    if value is not None:
        environ[name] = builtins.str(value)
    elif environ.get(name):
        del environ[name]
344972
def make_tarball(self, app_folder, build_data):
        
        # slugignore
        clean_slug_dir(app_folder)

        # tar up the result
        with tarfile.open('build.tar.gz', 'w:gz') as tar:
            tar.add(app_folder, arcname='')
        build_data.build_md5 = file_md5('build.tar.gz')

        tardest = os.path.join(self.outfolder, 'build.tar.gz')
        shutil.move('build.tar.gz', tardest)

        build_data_path = os.path.join(self.outfolder, 'build_result.yaml')
        print("Writing", build_data_path)
        with open(build_data_path, 'w') as f:
            f.write(build_data.as_yaml())
703903
def build_from_path(path)
      if !File.directory?(path) && File.basename(path) == 'Dockerfile'
        path = File.dirname(path)
      end
      File.directory?(path) ? build_from_dir(path) : build_from_file(path)
    end