view service/dhcpleases/tasks.py @ 1346:f54660b33a24

release 0.3.0 Ignore-this: 24ef128b3e09333e2ed61b04e04b479a darcs-hash:512129e12304545dcc5e22a840c3910d258e5221
author drewp <drewp@bigasterisk.com>
date Thu, 25 Apr 2019 23:01:04 -0700
parents 73c2b13692b7
children d7e82b1b31c4
line wrap: on
line source

from invoke import task

JOB = 'dhcpleases'
PORT = 9073
TAG = f'bang6:5000/{JOB}_x86:latest'


@task
def build_image(ctx):
    ctx.run(f'docker build --network=host -t {TAG} .')

@task(pre=[build_image])
def push_image(ctx):
    ctx.run(f'docker push {TAG}')

@task(pre=[build_image])
def shell(ctx):
    ctx.run(f'docker run --rm -it --cap-add SYS_PTRACE --net=host {TAG} /bin/bash', pty=True)

@task(pre=[build_image])
def local_run(ctx):
    ctx.run(f'docker run --rm -it -p {PORT}:{PORT} --net=host -v /opt/dnsmasq:/opt/dnsmasq {TAG} python3 dhcpleases.py -v', pty=True)

@task(pre=[push_image])
def redeploy(ctx):
    ctx.run(f'sudo /my/proj/ansible/playbook -l bang -t {JOB}')
    ctx.run(f'supervisorctl -s http://bang:9001/ restart {JOB}_{PORT}')