DEV Community

Vincent A. Cicirello
Vincent A. Cicirello

Posted on

gnu-on-alpine and alpine-plus-plus: Two Lightweight Containers for Implementing GitHub Container Actions with Shell Scripting

Introduction

The motivation of the gnu-on-alpine and alpine-plus-plus Docker containers is the implementation of GitHub Container Actions via shell scripting. They are built upon alpine to keep the image size small for fast loading within GitHub Actions, and both are preinstalled with bash, coreutils, findutils, and gawk; and alpine-plus-plus is additionally preinstalled with git.

Both gnu-on-alpine and alpine-plus-plus are multiplatform images supporting the following platforms:

  • linux/386
  • linux/amd64
  • linux/arm/v6
  • linux/arm/v7
  • linux/arm64
  • linux/ppc64le
  • linux/s390x

Table of Contents:

Motivation

GitHub Actions can be implemented in a couple ways. The most common is with JavaScript. However, another way to implement a GitHub Action is as a container action. As a container action, you can use any language to implement the action, provided the container includes all of the tools that your action requires.

One simple approach is to use your favorite Linux distribution as the base image for your container, and to define the steps to install any tools that your action needs (e.g., compilers, interpreters, CLI tools, etc) within the Dockerfile of your action. The problem with that approach is that whenever a workflow of one of your users runs, the container for your action is built, which in this case includes installing the various tools that it needs.

A better approach that speeds up runs of your action is to use a base image that includes all of the tools that your action requires. This way, your Dockerfile only requires the steps necessary to copy the source of your action into the container and to set an entrypoint. Here is an example of the Dockerfile of one of my GitHub Actions (note this one doesn't use the containers that are the subject of this post):

FROM ghcr.io/cicirello/pyaction:4.16.0
COPY tidyjavadocs.py /tidyjavadocs.py
ENTRYPOINT ["/tidyjavadocs.py"]
Enter fullscreen mode Exit fullscreen mode

Docker Tags and Versioning Scheme

I push images to both Docker Hub and the GitHub Container Registry with the following tags:

  • The tag latest indicates, well, the latest image.
  • Tags of the form MAJOR.MINOR.PATCH (such as 3.17.2) indicate the Semantic Version of the Alpine image used as the base.
  • Tags of the form MAJOR.MINOR (e.g., 3.17) correspond to the most recent patch level of the Alpine image used as the base. For example, if 3.17.2 is the latest release, then 3.17 maps to this as well.
  • Tags of the form MAJOR (e.g., 3) correspond to the most recent patch level of the Alpine image used as the base, with major corresponding major version. For example, if 3.17.2 is the latest release, then 3 maps to this as well.

I use GitHub's dependabot to monitor for updates to the base Alpine image.

Installing

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

Docker Pull Command

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

docker pull cicirello/gnu-on-alpine:3.17.2
Enter fullscreen mode Exit fullscreen mode

Or for alpine-plus-plus:

docker pull cicirello/alpine-plus-plus:3.17.2
Enter fullscreen mode Exit fullscreen mode

Pull from the Github Container Registry with:

docker pull ghcr.io/cicirello/gnu-on-alpine:3.17.2
Enter fullscreen mode Exit fullscreen mode

Or for alpine-plus-plus:

docker pull ghcr.io/cicirello/alpine-plus-plus:3.17.2
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/gnu-on-alpine:3.17.2

# The rest of your Dockerfile would go here.
Enter fullscreen mode Exit fullscreen mode

Or for alpine-plus-plus:

FROM cicirello/alpine-plus-plus:3.17.2

# 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/gnu-on-alpine:3.17.2

# The rest of your Dockerfile would go here.
Enter fullscreen mode Exit fullscreen mode

Or for alpine-plus-plus:

FROM ghcr.io/cicirello/alpine-plus-plus:3.17.2

# The rest of your Dockerfile would go here.
Enter fullscreen mode Exit fullscreen mode

Learn More

To learn more, consult the GitHub repositories:

GitHub logo cicirello / gnu-on-alpine

A lightweight docker image for shell scripting with GNU tools

gnu-on-alpine

A lightweight docker image for shell scripting with GNU tools (Alpine plus bash, coreutils, findutils, gawk)

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

Summary

The gnu-on-alpine Docker image is designed to support shell scripting using GNU tools such as the bash shell, gawk, coreutils, and findutils, while keeping the image size relatively small. Alpine Linux is used as the base image. The gnu-on-alpine image adds bash, findutils, coreutils, and gawk on top of Alpine Linux.

Multiplatform Image

gnu-on-alpine has the following platforms available:

  • linux/386
  • linux/amd64
  • linux/arm/v6
  • linux/arm/v7
  • linux/arm64
  • linux/ppc64le
  • linux/s390x

Source Repository and Builds

The source repository is maintained on GitHub. The images are built on Github and pushed to Docker Hub, as well as the Github Container Registry using Github Actions.

Docker Tags and Versioning Scheme

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

  • The tag latest indicates…

GitHub logo cicirello / alpine-plus-plus

A lightweight docker image for shell scripting and git

alpine-plus-plus

A lightweight docker image for shell scripting and git (Alpine plus bash, coreutils, findutils, gawk, git)

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 GitHub
Support GitHub Sponsors Liberapay Ko-Fi

Summary

The alpine-plus-plus Docker image is motivated by Github-actions implemented primarily with bash and shell utilities, but is also potentially applicable to any use-case where you primarily need bash and GNU tools like gawk, etc, as well as git, but also want to keep the image size relatively small. Alpine Linux is used as the base image. Alone, Alpine almost suits this purpose However, it lacks the bash shell, and commonly used GNU tools such as findutils, gawk, etc. It also lacks git. The alpine-plus-plus image adds git, bash, findutils, coreutils, and gawk on top of Alpine Linux.

Multiplatform Image

alpine-plus-plus has the following platforms available:

  • linux/386
  • linux/amd64
  • linux/arm/v6
  • linux/arm/v7
  • linux/arm64
  • linux/ppc64le
  • linux/s390x

Source Repository and Builds

The source repository is maintained on GitHub…

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 media Personal Website LinkedIn DEV Profile
Software development Github Maven Central PyPI Docker Hub
Publications Google 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-statistician GitHub Action.




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)