annotate service/frontDoorLock/tasks.py @ 563:7f57d171d6d3

py3 and new build Ignore-this: 69cf69e5d43adfa65b3f62c5c0af2014
author drewp@bigasterisk.com
date Wed, 01 May 2019 00:30:54 -0700
parents service/frontDoorLock/makefile@bfe555dd0c91
children 2a24a6c7a843
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
563
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
1 from invoke import task
377
5b690bfc31b2 docker/etc initial version of front door mqtt<->rdf using some rx
drewp@bigasterisk.com
parents:
diff changeset
2
5b690bfc31b2 docker/etc initial version of front door mqtt<->rdf using some rx
drewp@bigasterisk.com
parents:
diff changeset
3
563
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
4 JOB = 'front_door_lock'
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
5 PORT = 10011
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
6 TAG = f'bang6:5000/{JOB}_x86:latest'
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
7 ANSIBLE_TAG = 'door'
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
8
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
9 @task
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
10 def build_image(ctx):
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
11 ctx.run(f'docker build --network=host -t {TAG} .')
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
12
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
13 @task(pre=[build_image])
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
14 def push_image(ctx):
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
15 ctx.run(f'docker push {TAG}')
377
5b690bfc31b2 docker/etc initial version of front door mqtt<->rdf using some rx
drewp@bigasterisk.com
parents:
diff changeset
16
563
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
17 @task(pre=[build_image])
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
18 def shell(ctx):
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
19 ctx.run(f'docker run --name={JOB}_shell --rm -it --cap-add SYS_PTRACE --net=host {TAG} /bin/bash', pty=True)
426
bfe555dd0c91 talk to store graph, second button for holding unlocked, etc
drewp@bigasterisk.com
parents: 379
diff changeset
20
563
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
21 @task(pre=[build_image])
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
22 def local_run(ctx):
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
23 ctx.run(f'docker run --name={JOB}_local --rm -it --net=host -v `pwd`/index.html:/opt/index.html {TAG} python3 ./front_door_lock.py -v', pty=True)
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
24
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
25 @task(pre=[push_image])
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
26 def redeploy(ctx):
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
27 ctx.run(f'sudo /my/proj/ansible/playbook -l bang -t {ANSIBLE_TAG}')
7f57d171d6d3 py3 and new build
drewp@bigasterisk.com
parents: 426
diff changeset
28 ctx.run(f'supervisorctl -s http://bang:9001/ restart {JOB}_{PORT}')