Last active
December 19, 2019 10:46
-
-
Save eorituz/3b4b674cc596036f3cc54ef078366ddb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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...") | |
docker_stop_if_exists('nearcore_24568') | |
docker_stop_if_exists('watchtower_3031') | |
# 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