Skip to content

day8/dockerfiles-for-ci-images

Repository files navigation

Dockerfiles for day8/core and Derivative Images

The ghcr.io/day8/core and derivative Docker images are the reference testing environment used throughout Day8's continuous integration pipeline.

On pushing code to GitHub, this Docker image is the environment used to execute tests and build releases for deployment with GitHub Actions.

This repository contains the Dockerfiles to build the ghcr.io/day8/core Docker image. It also contains the GitHub Actions that test and deploy the Docker image.

Ubuntu 20.04 LTS was chosen as the base image as it is a long term stable release of a widely understood and supported distribution.

Quick Start

To run an interactive terminal:

$ docker login ghcr.io
$ docker run -it --rm ghcr.io/day8/core:5.0.0

Build Requirements

On image startup the exact versions of important software are printed to the console.

Name Version Description Origin
Leiningen 2.9.x Clojure(Script) build tool. Day8's main build tool. GitHub Releases Assets
Clojure 1.11.x 'Official' Clojure CLI tools. Clojure Website
OpenJDK 11.x (LTS) Java runtime. Dependency of Leiningen, clojure CLI etc. Ubuntu Package: openjdk-11-headless
Node.js 18.12.x (LTS) JavaScript runtime. Dependency of shadow-cljs. NodeSource Package Repository
NPM 9.1.x (LTS) JavaScript package manager. Dependency of shadow-cljs. Bundled with Node.js
Python 2 2.7.x Python 2 runtime. Ubuntu Package: python2
Python 3 3.8.x Python 3 runtime. Ubuntu Package: python3
pip Latest at build time. Python package manager. Ubuntu Package: python3-pip
pipenv Latest at build time. Python package manager. Python Package: pipenv
pytest Latest at build time. Python test runner. Python Package: pytest
Git Latest at build time. Dependency of actions/checkout and day8/lein-git-inject 'Git stable releases' Ubuntu PPA
aws Latest at build time. Interface to Amazon Web Services. Dependency of S3 deployments. Official AWS Package: awscli-exe-linux-x86_64.zip
sam Creates and manages AWS serverless applications. Official AWS Package: aws-sam-cli-linux-x86_64.zip
GNU Compiler Collection 9.3.x C (gcc) and C++ (g++) compiler. Dependency of npm install... and therefore shadow-cljs. Ubuntu Package: build-essential
make Latest at build time. Build automation tool, esp common for older C/C++ projects. Dependency of space-vim. Ubuntu Package: build-essential
cmake Latest at build time. Build automation tool, esp common for newer C/C++ projects. Ubuntu Package: cmake
zstd Latest at build time. Fast, lossless compression. Dependency of actions/cache@v2. Ubuntu Package: zstd
Xvfb Latest at build time. X virtual framebuffer. Dependency of running Chrome without a display in GitHub Actions. Ubuntu Package: xvfb
karma CLI 2.0.0 Dependency of builds that use the Karma test runner. npm: karma-cli
Chromium 56.0.2924.0 Used as a browser to execute Karma tests. This specific old version tracks the version of Electron that Day8 has deployed. Long storey
ChromeDriver 2.29 Dependency of executing Karma tests in Chromium. Project Website

REPLs

The following REPLs are available for exploratory programming and debugging of code snippets.

Name Language Example
'Official' Clojure Clojure docker run -it --rm ghcr.io/day8/core:2 clojure
Leiningen Clojure docker run -it --rm ghcr.io/day8/core:2 lein repl
Node.js JavaScript docker run -it --rm ghcr.io/day8/core:2 node
Python 2 Python 2 docker run -it --rm ghcr.io/day8/core:2 python2
Python 3 Python 3 docker run -it --rm ghcr.io/day8/core:2 python3
Bash Bash docker run -it --rm ghcr.io/day8/core:2 bash

Command-Line Tools

The following tools are not usually required for builds (e.g. GitHub Actions). These are included for convenience and usability when using the image as an interactive shell.

Tool Description Origin
clj-kondo A linter for Clojure code that sparks joy. GitHub Releases Assets
babashka Native Clojure interpreter for scripting. GitHub Releases Assets
gh GitHub's official command line tool. GitHub Releases Assets: gh_N.N.N_linux_amd64.deb
ssh OpenSSH client. Ubuntu Package: openssh-client

Why Not Docker Hub ?

In 2020 Docker Hub introduced rate limiting and around the same time GitHub Actions finally fixed use of GitHub Container Registry.

Therefore we no longer publish images to Docker Hub and use GitHub Container Registry instead.

GitHub Actions Example

jobs:
  test:
    name: Test
    runs-on: ubuntu-20.04
    container:
      image: ghcr.io/day8/chrome-latest:5.0.0
      credentials:
        username: ${{ github.actor }}
        password: ${{ secrets.GLOBAL_TOKEN_FOR_GITHUB }} # <-- you need to create a GitHub Secret with a manual token that has global access as github.token only has access to the current repo! 

Troubleshooting

Upgrading Chrome / Chromium

Problem

The day8/chrome-87:6.0.0 Docker image is provided as we need to test against a version equivalent to an old Electron version.

When the version of Chromium used needs to be upgraded to match an Electron upgrade.

Solution

Hold on to your hat and walk this path.

Karma - 'Gtk: cannot open display: :99'

Problem

When executing Karma tests an error similar to the following is displayed:

21 08 2020 12:10:13.052:ERROR [launcher]: ChromeHeadless stdout:
21 08 2020 12:10:13.052:ERROR [launcher]: ChromeHeadless stderr: [0821/121012:ERROR:nacl_helper_linux.cc(311)] NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly
[2442:2442:0821/121013:ERROR:browser_main_loop.cc(272)] Gtk: cannot open display: :99

Solution

xvfb, the X virtual framebuffer, is not running. This should be started by the /docker-entrypoint.sh script in the container which is the ENTRYPOINT of the Docker image.

If this error is occurring on GitHub Actions it may be because:

  1. GitHub Actions overrides the Docker image ENTRYPOINT with the --entrypoint CLI option to be /usr/bin/tail.
  2. We replace /usr/bin/tail with an intercept script that executes /docker-entrypoint.sh before executing the original tail at /usr/bin/tail.original.
  3. GitHub Actions has changed the --entrypoint option to something other than /usr/bin/tail.

Deployment

Simply push a semver tag of the form v1.2.3. GitHub Actions will publish Docker images for day8/core:1.2.3, day8/core:1.2 and day8/core:1. E.g.:

$ git tag v1.2.3 HEAD
$ git push --tags

License

This repository is MIT licenced

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages