Skip to content

Commit bb55d17

Browse files
committed
update vpn and cocalc; also add some notes to the README for other people
1 parent 13dba2d commit bb55d17

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ URL: https://github.com/sagemathinc/cocalc-compute-docker
44

55
[Compute Server Documentation](https://doc.cocalc.com/compute_server.html)
66

7-
There will be sections below with step-by-step instructions
7+
There will be sections below with step\-by\-step instructions
88
about how to update, build and test the compute server Docker images and npm pacckages we manage. For things that aren't documented yet, you have to
9-
just read the source code, Makefiles and Dockerfiles. The Makefile is useful as a makefile, but it's not at all a traditional "bullet proof" makefile that ensure any relevant dependency is automatically built. It's a useful way to run scripts, as documented here, and that is all.
9+
just read the source code, Makefiles and Dockerfiles. The Makefile is useful as a makefile, but it's not at all a traditional "bullet proof" makefile that ensure any relevant dependency is automatically built. It's a useful way to run scripts, as documented here, and that is all. Sometimes you'll just have to read the makefile to figure out how to build dependencies of a target.
10+
11+
**IMPORTANT:** For Docker containers we always <u>_explicitly use version numbers_</u>, and NEVER rely on latest anywhere here or in CoCalc. This is important to understand. The version to use is explicitly listed in images.json, and in the admin panel of cocalc, you specify to use a particular version of images.json \(which could be in a fork of this repo!\). For the cocalc npm package we do use the latest and test tags.
1012

1113
## Architectures: `x86_64` and `arm64`
1214

13-
I've taken great pains to ensure we fully support both architectures. This adds complexity and extra work at every step, unfortunately.
15+
I've taken great pains to ensure we fully support both architectures. This adds complexity and extra work at every step, but is the right thing to do at this point.
16+
17+
In particular, often the pattern is something like \(1\) running `make x && make push-x` on x86\_64, then run the same on arm64, then on exactly one of the two platforms run `make assemble-x`. In particular, you must setup separate x86\_64 and arm64 build hosts \-\- there is no way around it. We do not try to use the internal qemu based emulation, since many of our images \(e.g., building sage\) are just way too complicated for that to work.
1418

1519
## How to update the cocalc npm package
1620

images.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"tested": true
1414
},
1515
{
16-
"version": "1.14.1",
16+
"version": "1.14.2",
1717
"tag": "test",
1818
"tested": false
1919
}
@@ -65,7 +65,10 @@
6565
"icon": "files",
6666
"url": "https://github.com/sagemathinc/cocalc-compute-docker/tree/main/src/vpn",
6767
"source": "https://github.com/sagemathinc/cocalc-compute-docker/tree/main/src/vpn",
68-
"versions": [{ "tag": "1.6", "tested": false }],
68+
"versions": [
69+
{ "tag": "1.6", "tested": false },
70+
{ "tag": "1.7", "tested": false }
71+
],
6972
"description": "VPN - encrypted virtual private network (built on wireguard)"
7073
},
7174
"base": {

src/cocalc/check_in.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
and when storage changes, write it /cocalc/conf/storage.json.
2929
3030
"""
31-
import datetime, json, subprocess, sys, time, requests
31+
import datetime, json, os, sys, time, requests
3232
import update_hosts
3333
from requests.auth import HTTPBasicAuth
3434

@@ -105,26 +105,25 @@ def check_in():
105105

106106
def run(cmd):
107107
print(f"Run '{cmd}'")
108-
result = subprocess.run(cmd.split(),
109-
check=True,
110-
stdout=subprocess.PIPE,
111-
stderr=subprocess.PIPE)
112-
print("Done - Command Output:", result.stdout.decode())
108+
os.system(cmd)
113109

114110

115111
def update_vpn():
116112
image = json.loads(open('/cocalc/conf/vpn.json').read())['image']
117113
# Process latest vpn configuration
118-
run(f'docker run -it --rm --network host --privileged -v /cocalc/conf:/cocalc/conf {image}'
114+
run(f'docker run --rm --network host --privileged -v /cocalc/conf:/cocalc/conf {image}'
119115
)
120116
# Update /etc/hosts on the root VM
121117
update_hosts.update_hosts()
122118
# Update /etc/hosts in the compute docker container
123-
run('docker exec -it compute sudo /cocalc/update_hosts.py')
119+
run('docker exec compute sudo /cocalc/update_hosts.py')
124120
# NOTE: you can't just bind mount /etc/hosts into the container, and you can't just edit /etc/hosts
125121
# from a bind mounted /etc in a container -- i.e., every approach to *directly* using /etc/hosts
126122
# that I tried failed, and should fail (as it would lead to subtle bugs). Being explicit with the update_hosts.py
127123
# command is much better.
124+
if os.path.exists('/cocalc/conf/pings.sh'):
125+
# launch pings in the background to keep us on the vpn from behind our firewall.
126+
os.system("exec /cocalc/conf/pings.sh &")
128127

129128

130129
if __name__ == '__main__':

src/vpn/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def write_conf(compute_server_id, nodes):
111111
for peer in peers:
112112
pings += f"ping -r -I wg{compute_server_id} -n -i 15 -c 4 {peer['vpn_ip']} &\n"
113113
if len(peers) > 0:
114-
open(f'pings.sh', 'w').write(pings)
114+
open('pings.sh', 'w').write(pings)
115115

116116

117117
HOSTS_COMMENT = '### COCALC VPN -- EVERYTHING BELOW IS AUTOGENERATED -- DO NOT EDIT'

src/vpn/run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ cp -v hosts /cocalc/conf/hosts
1717
if [ -e pings.sh ]; then
1818
cp -v pings.sh /cocalc/conf
1919
chmod a+x /cocalc/conf/pings.sh
20+
else
21+
# ensure it is not there if not needed
22+
rm -f /cocalc/conf/pings.sh
2023
fi
2124

2225
# actually do the configuration -- if up doesn't work, e.g., because

0 commit comments

Comments
 (0)