772
|
1 from invoke import task, Collection
|
|
2 import sys
|
|
3 sys.path.append('/my/proj/release')
|
|
4 from serv_tasks import serv_tasks
|
690
|
5
|
772
|
6 ns = Collection()
|
|
7 serv_tasks(ns, 'serv.n3', 'xidle_dash')
|
|
8
|
|
9 if 0:
|
|
10
|
|
11 TAG_x86 = f'bang6:5000/{JOB.lower()}_x86:latest'
|
|
12 TAG_pi = f'bang6:5000/{JOB.lower()}_pi:latest'
|
|
13 ANSIBLE_TAG = 'homeauto_xidle'
|
362
|
14
|
772
|
15 @task
|
|
16 def build_image_x86(ctx):
|
|
17 ctx.run(f'docker build --network=host -t {TAG_x86} .')
|
|
18 @task
|
|
19 def build_image_pi(ctx):
|
|
20 ctx.run(f'docker build --file Dockerfile.pi --network=host -t {TAG_pi} .')
|
362
|
21
|
772
|
22 @task(pre=[build_image_x86])
|
|
23 def push_image_x86(ctx):
|
|
24 ctx.run(f'docker push {TAG_x86}')
|
|
25 @task(pre=[build_image_pi])
|
|
26 def push_image_pi(ctx):
|
|
27 ctx.run(f'docker push {TAG_pi}')
|
362
|
28
|
772
|
29 @task(pre=[build_image_x86])
|
|
30 def shell(ctx):
|
|
31 ctx.run(f'docker run --rm -it --cap-add SYS_PTRACE -v /tmp/.X11-unix/:/tmp/.X11-unix/ -v /home/drewp/.Xauthority:/root/.Xauthority --net=host {TAG_x86} /bin/bash', pty=True)
|
457
|
32
|
772
|
33 @task(pre=[build_image_x86])
|
|
34 def local_run(ctx):
|
|
35 ctx.run(f'docker run --rm -it -v /tmp/.X11-unix/:/tmp/.X11-unix/ -v /home/drewp/.Xauthority:/root/.Xauthority -p {PORT}:{PORT} -v /etc/resolv.conf:/etc/resolv.conf --net=host {TAG_x86} python3 xidle.py -v', pty=True)
|
|
36
|
|
37 @task(pre=[push_image_x86, push_image_pi])
|
|
38 def redeploy(ctx):
|
|
39 ctx.run(f'sudo /my/proj/ansible/playbook -t {ANSIBLE_TAG}')
|
|
40 #ctx.run(f'supervisorctl -s http://bang:9001/ restart {JOB}_{PORT}')
|