annotate service/dpms/tasks.py @ 1523:0da337780f22

dep updates; graph url renames; and other build updates Ignore-this: 4603ef3d8db650a13e543dad8580ade8 darcs-hash:0840491cd6a4e4966f47a2abca0ed30ec434022a
author drewp <drewp@bigasterisk.com>
date Wed, 05 Feb 2020 00:23:06 -0800
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1523
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
1 from invoke import task
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
2 JOB = 'dpms'
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
3 PORT = 9095
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
4 TAG_x86 = f'bang6:5000/{JOB.lower()}_x86:latest'
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
5 TAG_pi = f'bang6:5000/{JOB.lower()}_pi:latest'
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
6 ANSIBLE_TAG = 'homeauto_dpms'
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
7
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
8 @task
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
9 def build_image_x86(ctx):
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
10 ctx.run(f'docker build --network=host -t {TAG_x86} .')
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
11 @task
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
12 def build_image_pi(ctx):
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
13 ctx.run(f'docker build --file Dockerfile.pi --network=host -t {TAG_pi} .')
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
14
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
15 @task(pre=[build_image_x86])
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
16 def push_image_x86(ctx):
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
17 ctx.run(f'docker push {TAG_x86}')
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
18 @task(pre=[build_image_pi])
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
19 def push_image_pi(ctx):
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
20 ctx.run(f'docker push {TAG_pi}')
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
21
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
22 @task(pre=[build_image_x86])
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
23 def shell(ctx):
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
24 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)
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
25
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
26 @task(pre=[build_image_x86])
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
27 def local_run(ctx):
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
28 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 dpms_service.py -v', pty=True)
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
29
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
30 @task(pre=[push_image_x86, push_image_pi])
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
31 def redeploy(ctx):
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
32 ctx.run(f'sudo /my/proj/ansible/playbook -t {ANSIBLE_TAG}')
0da337780f22 dep updates; graph url renames; and other build updates
drewp <drewp@bigasterisk.com>
parents:
diff changeset
33 #ctx.run(f'supervisorctl -s http://bang:9001/ restart {JOB}_{PORT}')