Skip to main content

Run actions in disposable containers

Project description

Ephemerun

Incredibly temporary containers

Ephemerun wraps around an existing container system on your computer. It lets you run a single one-liner which spins up a container, does a series of things in it, and then tears it all down again afterwards.

It is a good way to run a test suite. It is particularly good at running the tests multiple times using slightly different base images (e.g. to ensure compatibility with multiple platform versions). In the future it might be good for building artefacts too.

It is especially helpful when combined with make. There is no good way to define a teardown recipe in a Makefile, so if you spin up a container and one of your actions fails make will stop and leave your "temporary" container permanently floating around. But Ephemerun will always tidy up after itself so can be safely called from a Makefile.

Installation

This codebase is not (currently) on PyPI, but can be installed with pip straight from the Git source:

$ pip install git+https://github.com/pscl4rke/ephemerun.git

Example Usage

Silly demo:

$ ephemerun \
    -i python:3.9-slim-bullseye \
    -S pwd \
    -W /tmp \
    -S pwd

Real-world example:

$ ephemerun \
    -i "python:3.9-slim-bullseye" \
    -v "$(pwd):/root/src:ro" \
    -W "/root" \
    -S "cp -air ./src/* ." \
    -S "pip --no-cache-dir install .[testing]" \
    -S "mypy --cache-dir /dev/null projectdir" \
    -S "coverage run -m unittest discover tests/" \
    -S "coverage report -m"

Quick Docs

  • Use -i to set the base image for the temporary container.
  • Use -v to mount a directory into it (where the :ro suffix makes it readonly).
  • Run -W to change the current working directory.
  • Run -S to execute a line in a shell.
  • And of course -h gives you usage info!

Roadmap

  • The output would be easier to read if Epheruns's messages were coloured in.

  • Currently only Docker and Podman are available as backends and ephemerun autodetects which one is installed. Perhaps Containerd or something using a Kubernetes cluster could be added without too much difficulty. I would like to support many other mechanisms too (e.g. Systemd Nspawn) but currently everything assumes the image is specified in OCI format.

  • Currently the only useful thing you can do is run shell commands with -S and capture the stdout/stderr output. I would like to add a "download" mechanism, so artefacts can be built in a container and then copied out to the host. Presumably an "upload" mechanism would be easy to add at the same time.

  • Many tools can make use of a cache, but anything that gets cached is thrown away by Ephemerun. I do not have a strategy for handling that at the moment.

  • More generally we could do with developing and documenting a strategy for one Makefile recipe to build a reusable image and then different recipes using it for different purposes. Presumably ephemerun wouldn't be used for the building.

Licence

This code is licensed under the terms of the GNU General Public Licence version 3.

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

ephemerun-1.0.1.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

ephemerun-1.0.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file ephemerun-1.0.1.tar.gz.

File metadata

  • Download URL: ephemerun-1.0.1.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for ephemerun-1.0.1.tar.gz
Algorithm Hash digest
SHA256 647333d2f12cde806e1a74caf014209de3d57773a28c2b1c6fa15fae66be5a02
MD5 1127b230ea6161fb79175069f1014b4b
BLAKE2b-256 c2dc3c1b590c4e219fefb9966b590fdc6f8b3a210b71e564fad062bc96361823

See more details on using hashes here.

File details

Details for the file ephemerun-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ephemerun-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for ephemerun-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 256d9691b0c1fa5f53f070662445e150dc6c049efe404d78743260cc14074540
MD5 061db797789ecadfba9d3561f6324318
BLAKE2b-256 56a0c36f69c8dfee136515afbf5b96ddcd19b07c10a0709bcfbdd560cce37ee9

See more details on using hashes here.

Supported by

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