view service/store/tasks.py @ 1493:391140f53dfd

reformat Ignore-this: 823c997b62c14b717c614c3205c23bd darcs-hash:1ce5bace80bbdad6fb904bd3dfcf32ed0f1fa127
author drewp <drewp@bigasterisk.com>
date Wed, 29 Jan 2020 01:04:09 -0800
parents 1dd4da407c0b
children 0da337780f22
line wrap: on
line source

from invoke import task

JOB = 'store'
PORT = 10015

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
def shell(ctx):
    ctx.run(f'docker run --rm -it --cap-add SYS_PTRACE  -v `pwd`:/opt/homeauto_store --dns 10.2.0.1 --dns-search bigasterisk.com --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}  -v `pwd`:/opt/homeauto_store --dns 10.2.0.1 --dns-search bigasterisk.com --net=host {TAG} python {JOB}.py -v', pty=True)

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