Skip to content

Instantly share code, notes, and snippets.

Last active December 19, 2019 10:46
What would you like to do?
"""Runs NEAR core inside the docker container for isolation and easy update with Watchtower."""
def run_docker(image, home_dir, boot_nodes, telemetry_url, verbose):
print("Starting NEAR client and Watchtower dockers...")
# Start nearcore container, mapping home folder and ports.
envs = ['-e', 'BOOT_NODES=%s' % boot_nodes, '-e', 'TELEMETRY_URL=%s' % telemetry_url]
rpc_port = get_port(home_dir, 'rpc')
network_port = get_port(home_dir, 'network')
if verbose:
envs.extend(['-e', 'VERBOSE=1'])
subprocess.check_output(['mkdir', '-p', home_dir])
subprocess.check_output(['docker', 'run', '-u', USER,
'-d', '-p', rpc_port, '-p', network_port, '-v', '%s:/srv/near' % home_dir,
'-v', '/tmp:/tmp',
'--ulimit', 'core=-1',
'--name', 'nearcore_24568', '--restart', 'unless-stopped'] +
envs + [image])
# Start Watchtower that will automatically update the nearcore container when new version appears.
subprocess.check_output(['docker', 'run', '-u', USER,
'-d', '--restart', 'unless-stopped', '--name', 'watchtower_3031',
'-v', '/var/run/docker.sock:/var/run/docker.sock',
'v2tec/watchtower', image])
print("Node is running! \nTo check logs call: docker logs --follow nearcore")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment