diff service/dpms/tasks.py @ 722:a93fbf0d0daa

dep updates; graph url renames; and other build updates Ignore-this: 4603ef3d8db650a13e543dad8580ade8
author drewp@bigasterisk.com
date Wed, 05 Feb 2020 00:23:06 -0800
parents service/dpms/makefile@1007ca70c34d
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/service/dpms/tasks.py	Wed Feb 05 00:23:06 2020 -0800
@@ -0,0 +1,33 @@
+from invoke import task
+JOB = 'dpms'
+PORT = 9095
+TAG_x86 = f'bang6:5000/{JOB.lower()}_x86:latest'
+TAG_pi = f'bang6:5000/{JOB.lower()}_pi:latest'
+ANSIBLE_TAG = 'homeauto_dpms'
+
+@task
+def build_image_x86(ctx):
+    ctx.run(f'docker build --network=host -t {TAG_x86} .')
+@task
+def build_image_pi(ctx):
+    ctx.run(f'docker build --file Dockerfile.pi --network=host -t {TAG_pi} .')
+
+@task(pre=[build_image_x86])
+def push_image_x86(ctx):
+    ctx.run(f'docker push {TAG_x86}')
+@task(pre=[build_image_pi])
+def push_image_pi(ctx):
+    ctx.run(f'docker push {TAG_pi}')
+
+@task(pre=[build_image_x86])
+def shell(ctx):
+    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)
+
+@task(pre=[build_image_x86])
+def local_run(ctx):
+    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)
+
+@task(pre=[push_image_x86, push_image_pi])
+def redeploy(ctx):
+    ctx.run(f'sudo /my/proj/ansible/playbook -t {ANSIBLE_TAG}')
+    #ctx.run(f'supervisorctl -s http://bang:9001/ restart {JOB}_{PORT}')