DEV Community

Cover image for pyaction: A Docker container with Python, git, and the GitHub CLI
Vincent A. Cicirello
Vincent A. Cicirello

Posted on • Edited on

pyaction: A Docker container with Python, git, and the GitHub CLI

What is pyaction?

The pyaction container is a Python slim image on top of which I've added git and the GitHub CLI, as well as gpg and curl. For the motivating usecases, I mainly need Python, git, and the GitHub CLI. The pyaction image includes gpg and curl because they are needed to install the GitHub CLI, and I saw no point in uninstalling them afterwards as part of the container build. It is available from both Docker Hub and the GitHub Container Registry.

The latest release, 4.14.0, includes the following versions:

  • Python 3.11.1
  • GitHub CLI 2.21.1
  • git 2.30.2
  • curl 7.74.0
  • gpg 2.2.27

I use GitHub's dependabot to monitor for updates to the Python Docker slim image, and a custom script to monitor for new releases of the GitHub CLI. And I regularly create new releases of pyaction when either the official Python slim Docker image or the GitHub CLI publishes a new release.

pyaction is a multiplatform image supporting the following platforms:

  • linux/386
  • linux/amd64
  • linux/arm/v7
  • linux/arm64

The GitHub repository is (please consider starring it):

GitHub logo cicirello / pyaction

A Docker container with Python, git, and the Github CLI

pyaction

pyaction - A Docker container with Python, git, and the GitHub CLI

Website for our GitHub Actions and tools for developing them: https://actions.cicirello.org/

Summary

Docker Hub Docker Image Version (latest by date) Docker Pulls
GitHub GitHub release (latest by date)
Image Stats Docker Image Size (latest by date)
Build Status build
License License
Support GitHub Sponsors Liberapay Ko-Fi

This Docker image is designed to support implementing Github Actions with Python. As of version 4.0.0., it starts with the official python docker image as the base which is a Debian OS. It specifically uses python:3-slim to keep the image size down for faster loading of Github Actions that use pyaction. On top of the base, we've installed curl, gpg, git, and the GitHub CLI. We added curl and gpg because they are needed to install the GitHub CLI, and they may come in handy anyway (especially curl) when implementing a GitHub Action.

Blog Post on DEV: pyaction: A Docker container with Python, git, and the GitHub CLI, posted on December 28, 2022. See a list of additional blog posts later in this…

Table of Contents:

Original Motivation

I maintain several GitHub Actions that are implemented in Python as container actions. To speed up loading of those Actions, I maintain a Docker container with all of the tools those Actions may need preinstalled. This way, when a workflow run references one of my Actions, the container build for the Action only needs to add the layer with the source code of the Action itself without the need to install various tools during each workflow run. The pyaction container is certainly not limited to such usage.

Docker Tags and Versioning Scheme

I push images to both Docker Hub and the GitHub Container Registry.

I use Semantic Versioning for the tags. Semantic Versioning uses version numbers of the form: MAJOR.MINOR.PATCH, where differences in MAJOR correspond to incompatible changes, differences in MINOR correspond to introduction of backwards compatible new functionality, and PATCH corresponds to backwards compatible bug fixes.

In this case, if a release includes only patch level updates to the GitHub CLI, Python, etc, then I simply bump the patch part of the version number. If a release includes any minor updates to the GitHub CLI, Python, etc, then I bump the minor part of pyaction's version. If the GitHub CLI, Python, etc includes any breaking changes, then I'll bump the major part of the version number.

Each image pushed to Docker Hub and the Github Container Registry is tagged as follows:

  • The tag latest indicates, well, the latest image.
  • Tags of the form MAJOR.MINOR.PATCH (e.g., 4.14.0).
  • Tags of the form MAJOR.MINOR (e.g., 4.14).
  • Tags of the form MAJOR (e.g., 4).

Installing

The pre-built image is hosted on both Docker Hub and the GitHub Container Registry. You can use it in the following ways.

Docker Pull Command

Pull the latest image from Docker Hub with the following (or replace with tag of desired version):



docker pull cicirello/pyaction:4.14.0


Enter fullscreen mode Exit fullscreen mode

Pull from the Github Container Registry with:



docker pull ghcr.io/cicirello/pyaction:4.14.0


Enter fullscreen mode Exit fullscreen mode

Use as a base image in a Dockerfile

Use as a base image in a Dockerfile (or replace with tag of desired version):



FROM cicirello/pyaction:4.14.0

# The rest of your Dockerfile would go here.


Enter fullscreen mode Exit fullscreen mode

Or you can use as a base image (via the Github Container Registry) with:



FROM ghcr.io/cicirello/pyaction:4.14.0

# The rest of your Dockerfile would go here.


Enter fullscreen mode Exit fullscreen mode

More Information

Additional information available on its website:

pyaction - A Docker container with Python, git, and the Github CLI

The pyaction Docker container is designed to support implementing Github Actions with Python. It starts with the official python slim docker image as the base, using slim to keep the image size down for faster loading of Github Actions that use pyaction. The pyaction container also includes curl, gpg, git, and the GitHub CLI.

favicon actions.cicirello.org

Where You Can Find Me

Follow me here on DEV and on GitHub:

Or visit my website:

Vincent A. Cicirello - Professor of Computer Science

Vincent A. Cicirello - Professor of Computer Science at Stockton University - is a researcher in artificial intelligence, evolutionary computation, swarm intelligence, and computational intelligence, with a Ph.D. in Robotics from Carnegie Mellon University. He is an ACM Senior Member, IEEE Senior Member, AAAI Life Member, EAI Distinguished Member, and SIAM Member.

favicon cicirello.org

Top comments (0)

Some comments have been hidden by the post's author - find out more