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:
The GitHub repository is:
A base Docker image for Github Actions implemented in Python
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.
Version 4.0.0 and Newer: pyaction supports the following…
Table of Contents:
- What is pyaction?
- Original Motivation
- Docker Tags and Versioning Scheme
- Where You Can Find Me
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
latestindicates, 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).
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
Pull from the Github Container Registry with:
docker pull ghcr.io/cicirello/pyaction:4.14.0
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.
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.
Where You Can Find Me
Follow me here on DEV:
Follow me on GitHub:
Vincent A Cicirello
If you want to generate the equivalent to the above for your own GitHub profile, check out the cicirello/user-statistician GitHub Action.
Or visit my website:
Top comments (1)
Some comments have been hidden by the post's author - find out more