diff service/dhcpleases/tasks.py @ 531:f372e9d358d2

rewrite dhcpleases to use dnsmasq's data files, and all the new build stuff Ignore-this: 2dffc17b676253d4fec234fc096db4d5
author drewp@bigasterisk.com
date Tue, 23 Apr 2019 02:56:07 -0700
parents
children d7e82b1b31c4
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/service/dhcpleases/tasks.py	Tue Apr 23 02:56:07 2019 -0700
@@ -0,0 +1,27 @@
+from invoke import task
+
+JOB = 'dhcpleases'
+PORT = 9073
+TAG = f'bang6:5000/{JOB}_x86:latest'
+
+
+@task
+def build_image(ctx):
+    ctx.run(f'docker build --network=host -t {TAG} .')
+
+@task(pre=[build_image])
+def push_image(ctx):
+    ctx.run(f'docker push {TAG}')
+
+@task(pre=[build_image])
+def shell(ctx):
+    ctx.run(f'docker run --rm -it --cap-add SYS_PTRACE --net=host {TAG} /bin/bash', pty=True)
+
+@task(pre=[build_image])
+def local_run(ctx):
+    ctx.run(f'docker run --rm -it -p {PORT}:{PORT} --net=host -v /opt/dnsmasq:/opt/dnsmasq {TAG} python3 dhcpleases.py -v', pty=True)
+
+@task(pre=[push_image])
+def redeploy(ctx):
+    ctx.run(f'sudo /my/proj/ansible/playbook -l bang -t {JOB}')
+    ctx.run(f'supervisorctl -s http://bang:9001/ restart {JOB}_{PORT}')