Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

invoke_containers-0.2.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

invoke_containers-0.2.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file invoke_containers-0.2.0.tar.gz.

File metadata

  • Download URL: invoke_containers-0.2.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.9.3 CPython/3.10.12

File hashes

Hashes for invoke_containers-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8b585fb455e785a2d8ff26c1c9576034a49160d3e78c653e1e0dba09fa802514
MD5 5ecccf6993ae46d40c2c8f9ea459d0e9
BLAKE2b-256 32e2f76c47a089bab703498a6775d5d586ff34265605566951d4fa455a35f4b6

See more details on using hashes here.

File details

Details for the file invoke_containers-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for invoke_containers-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9d94c1f2d4e617fd64673af497c18d4d48857d0ecaa3b6fa65e420ba7060bfe
MD5 48e9d80f49bc12a436e8557aecf8dde3
BLAKE2b-256 fc792448722499607ceac87d0a1386dfdf907e38c7be0ff0e01da516cdf0807d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page