annotate service/dpms/tasks.py @ 1743:daf9deee42ca

deployment
author drewp@bigasterisk.com
date Thu, 09 Nov 2023 14:55:26 -0800
parents a93fbf0d0daa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
722
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
1 from invoke import task
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
2 JOB = 'dpms'
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
3 PORT = 9095
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
4 TAG_x86 = f'bang6:5000/{JOB.lower()}_x86:latest'
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
5 TAG_pi = f'bang6:5000/{JOB.lower()}_pi:latest'
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
6 ANSIBLE_TAG = 'homeauto_dpms'
383
8f5a16a55f64 various docker setups and build fixes
drewp@bigasterisk.com
parents:
diff changeset
7
722
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
8 @task
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
9 def build_image_x86(ctx):
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
10 ctx.run(f'docker build --network=host -t {TAG_x86} .')
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
11 @task
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
12 def build_image_pi(ctx):
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
13 ctx.run(f'docker build --file Dockerfile.pi --network=host -t {TAG_pi} .')
383
8f5a16a55f64 various docker setups and build fixes
drewp@bigasterisk.com
parents:
diff changeset
14
722
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
15 @task(pre=[build_image_x86])
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
16 def push_image_x86(ctx):
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
17 ctx.run(f'docker push {TAG_x86}')
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
18 @task(pre=[build_image_pi])
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
19 def push_image_pi(ctx):
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
20 ctx.run(f'docker push {TAG_pi}')
383
8f5a16a55f64 various docker setups and build fixes
drewp@bigasterisk.com
parents:
diff changeset
21
722
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
22 @task(pre=[build_image_x86])
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
23 def shell(ctx):
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
24 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)
464
1007ca70c34d use PatchableGraph
drewp@bigasterisk.com
parents: 383
diff changeset
25
722
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
26 @task(pre=[build_image_x86])
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
27 def local_run(ctx):
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
28 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)
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
29
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
30 @task(pre=[push_image_x86, push_image_pi])
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
31 def redeploy(ctx):
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
32 ctx.run(f'sudo /my/proj/ansible/playbook -t {ANSIBLE_TAG}')
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 464
diff changeset
33 #ctx.run(f'supervisorctl -s http://bang:9001/ restart {JOB}_{PORT}')