The container decorator will check an environment variable, CONTAINER=yes|no, if that is set on 'yes', then it will execute the same step inside the container, not in the host.
def container(fn):
if in_container():
return fn()
else:
print('Detect what task it coresponds to and execute in container')
coresponding_task = 'HOW TO I GET IT ?'
os.system(f'docker exec -i -t "mycontainer" /bin/bash -i -l "inv {coresponding_task}"')
But now how do I know what task the function corresponds to ?
Trying to create a decorator
The
container
decorator will check an environment variable,CONTAINER=yes|no
, if that is set on 'yes', then it will execute the same step inside the container, not in the host.But now how do I know what
task
the function corresponds to ?Is this even the proper way ?