Skip to content

Instantly share code, notes, and snippets.

@GaretJax
Created December 12, 2013 17:06
Show Gist options
  • Select an option

  • Save GaretJax/7931453 to your computer and use it in GitHub Desktop.

Select an option

Save GaretJax/7931453 to your computer and use it in GitHub Desktop.
def deploy(self, host, config):
client = host.get_client()
ports = {'{0[port]}/{0[type]}'.format(p): {} for p in config['ports']}
volumes = {v: {} for v in config['shared-folders']}
binds = {v: k for k, v in config['shared-folders'].iteritems()}
port_bindings = (
p for p in config['ports']
if 'host_ip' in p or 'host_port' in p
)
port_bindings = {
'{0[type]}/{0[port]}'.format(p): [{
'HostIp': p.get('host_ip', ''),
'HostPort': p.get('host_port', ''),
}]
for p in port_bindings
}
links = {v[1:]: k for k, v in config['links'].iteritems()}
client.pull(
self.application.full_repository,
self.tag
)
container = client.create_container(
self.full_image,
command=['django-admin.py', 'runuwsgi'],
#stdin_open=True, tty=True,
ports=ports,
volumes=volumes,
environment=config['environment']
)
client.start(
container,
binds=binds,
port_bindings=port_bindings,
links=links
)
return Instance(
started=datetime.now(),
build=self,
host=host,
config=config,
container=container['Id'],
)
@GaretJax

Copy link
Copy Markdown
Author
ports = {
    '22/tcp': {}
}

port_bindings = {
    '22/tcp': [{
        'HostIp': '',
        'HostPort': '',
    }]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment