1366
|
1 from invoke import task
|
|
2
|
|
3
|
|
4 JOB = 'front_door_lock'
|
|
5 PORT = 10011
|
|
6 TAG = f'bang6:5000/{JOB}_x86:latest'
|
|
7 ANSIBLE_TAG = 'door'
|
|
8
|
|
9 @task
|
|
10 def build_image(ctx):
|
|
11 ctx.run(f'docker build --network=host -t {TAG} .')
|
|
12
|
|
13 @task(pre=[build_image])
|
|
14 def push_image(ctx):
|
|
15 ctx.run(f'docker push {TAG}')
|
|
16
|
|
17 @task(pre=[build_image])
|
|
18 def shell(ctx):
|
|
19 ctx.run(f'docker run --name={JOB}_shell --rm -it --cap-add SYS_PTRACE --net=host {TAG} /bin/bash', pty=True)
|
|
20
|
|
21 @task(pre=[build_image])
|
|
22 def local_run(ctx):
|
|
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)
|
|
24
|
|
25 @task(pre=[push_image])
|
|
26 def redeploy(ctx):
|
|
27 ctx.run(f'sudo /my/proj/ansible/playbook -l bang -t {ANSIBLE_TAG}')
|
|
28 ctx.run(f'supervisorctl -s http://bang:9001/ restart {JOB}_{PORT}')
|