Invoke your tasks within containers.
Project description
Overview
Invoke your tasks within containers.
Run your tasks within containers
Given a task to create a binary with go
@task
def build(c):
c.run(f"go build")
don't assume everyone has go installed, run the task in a container
@container("go:1.20")
@task
def build(c):
c.run(f"go build")
Specify the container runner program to use
CONTAINER_INVOKE_PROGRAM="podman" inv build
Temporarily invoke tasks on host (not in containers)
CONTAINER_INVOKE_ON_HOST=1 inv build
TODO Run part of your task within one or more containers
@task
def super_task(c):
c.run("echo operation on host")
with container("go:1.20"):
c.run("go test")
c.run("go build")
with container("sphinxdoc/sphinx"):
c.run("make html")
It's likely that this particular example would be better off split into several tasks using @container
and using invokes task dependencies.
TODO specify shared environment
By default each c.run(COMMAND)
runs in it's own docker container which gets torn down between calls. ex:
c.run(COMMAND1)
c.run(COMMAND2)
...
c.run(COMMANDn)
becomes approximately:
docker run IMAGE COMMAND1
docker run IMAGE COMMAND2
...
docker run IMAGE COMMANDn
This results in the internal container state being destroyed on each COMMAND.
If we instead want to create the container environment and then run each command in the single environment, similar to:
docker container create IMAGE
docker exec CID COMMAND1
docker exec CID COMMAND2
...
docker exec CID COMMANDn
docker container stop CID
docker container rm CID
INVOKE_CONTAINERS_REUSE_CONTAINER=1 \
inv build
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for invoke_containers-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9d94c1f2d4e617fd64673af497c18d4d48857d0ecaa3b6fa65e420ba7060bfe |
|
MD5 | 48e9d80f49bc12a436e8557aecf8dde3 |
|
BLAKE2b-256 | fc792448722499607ceac87d0a1386dfdf907e38c7be0ff0e01da516cdf0807d |