Mercurial > code > home > repos > homeauto
annotate service/piNode/tasks.py @ 1355:f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
Ignore-this: 78f09ba8a1898fd5f79cfc260cd36185
darcs-hash:500de704f71e24aafeb0b6ecf750a7c9f3f2a513
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Thu, 25 Apr 2019 23:38:47 -0700 |
parents | |
children | 445e24e8c8bb |
rev | line source |
---|---|
1355
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
1 from invoke import task |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
2 |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
3 JOB = 'piNode' |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
4 PORT = 9059 |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
5 TAG = f'bang6:5000/{JOB.lower()}_pi:latest' |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
6 ANSIBLE_TAG = 'raspi_io_node' |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
7 |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
8 @task |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
9 def build_image(ctx): |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
10 ctx.run(f'docker build --network=host -t {TAG} .') |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
11 |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
12 @task(pre=[build_image]) |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
13 def push_image(ctx): |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
14 ctx.run(f'docker push {TAG}') |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
15 |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
16 # (cd /my/proj/homeauto/service/arduinoNode; tar czf /my/site/projects/rdfdb/more2.tgz static) |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
17 |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
18 @task(pre=[build_image]) |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
19 def shell(ctx): |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
20 ctx.run(f'docker run --name={JOB}_shell --rm -it --cap-add SYS_PTRACE --net=host {TAG} /bin/bash', pty=True) |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
21 |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
22 |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
23 @task(pre=[build_image]) |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
24 def local_run(ctx): |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
25 ctx.run(f'docker run --name={JOB}_local --rm -it {TAG} python ./piNode.py -v', pty=True) |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
26 |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
27 @task(pre=[push_image]) |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
28 def redeploy(ctx): |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
29 ctx.run(f'sudo /my/proj/ansible/playbook -l pi -t {ANSIBLE_TAG}') |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
30 |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
31 @task |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
32 def push_config(ctx): |
f2159312b0e7
update build and deps to use invoke and to use new lib layout, plus more stats collection
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
33 ctx.run(f'docker run --rm --net=host -v `pwd`/config:/opt/config bang6:5000/arduino_node python pushConfig.py pi/') |