Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
December 28, 2022 04:22 pm GMT

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.11.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:

GitHub logo cicirello / pyaction

A base Docker image for Github Actions implemented in Python

pyaction

A base Docker image for Github Actions implemented in Python

Docker HubDocker Image Version (latest by date) Docker Pulls
GitHubGitHub release (latest by date)
Image StatsDocker Image Size (latest by date)
Build Statusbuild
LicenseLicense
SupportGitHub Sponsors Liberapay Ko-Fi

Summary

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

Note: Up through pyaction:3.14.0, we previously used Alpine Linux. Howeverthe GitHub CLI isn't currently supported on Alpine, which is why we haveswitched the base image.

Multiplatform Image

Version 4.0.0 and

Table of Contents:

  • What is pyaction?
  • Original Motivation
  • Docker Tags and Versioning Scheme
  • Installing
    • Docker Pull Command
    • Use as a base image in a Dockerfile
  • Where You Can Find Me

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

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:

GitHub logo cicirello / cicirello

My GitHub Profile

Vincent A Cicirello

Vincent A. Cicirello

Sites where you can find me or my work
Web and social mediaPersonal Website LinkedIn DEV Profile
Software developmentGithub Maven Central PyPI Docker Hub
PublicationsGoogle Scholar ORCID DBLP ACM Digital Library IEEE Xplore ResearchGate arXiv

My bibliometrics

My GitHub Activity

If you want to generate the equivalent to the above for your own GitHub profile,check out the cicirello/user-statisticianGitHub Action.




Or visit my website:

Vincent A. Cicirello - Professor of Computer Science

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

favicon cicirello.org

Original Link: https://dev.to/cicirello/pyaction-a-docker-container-with-python-git-and-the-github-cli-930

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To