Mercurial > code > home > repos > homeauto
annotate service/piNode/tasks.py @ 1430:445e24e8c8bb
lib upgrades; fix a static http server path
Ignore-this: f48022f37590e8bdb16957c49168d31b
darcs-hash:018ffeb640e1ce9307daf4a320fbd0c807e66a07
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Thu, 08 Aug 2019 16:54:46 -0700 |
parents | f2159312b0e7 |
children | af2d0249a2cc |
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 @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
|
17 def shell(ctx): |
1430
445e24e8c8bb
lib upgrades; fix a static http server path
drewp <drewp@bigasterisk.com>
parents:
1355
diff
changeset
|
18 ctx.run(f'docker run --name={JOB}_shell --rm -it --cap-add SYS_PTRACE --net=host --uts=host --cap-add SYS_RAWIO --device /dev/mem --privileged {TAG} /bin/bash', pty=True) |
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
|
19 |
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 |
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 @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
|
22 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
|
23 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
|
24 |
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 @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
|
26 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
|
27 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
|
28 |
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 @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
|
30 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
|
31 ctx.run(f'docker run --rm --net=host -v `pwd`/config:/opt/config bang6:5000/arduino_node python pushConfig.py pi/') |