Skip to content

Automatic Builds

Jennings Zhang edited this page Mar 1, 2021 · 2 revisions

Background

Github Actions provides continuous integration, which automatically tests your code whenever you make a commit. If tests pass, your ChRIS plugin will be automatically uploaded to two places: DockerHub and the ChRIS Store.

DockerHub is a repository for container images. This is where the executables of your app live.

The ChRIS Store https://chrisstore.co is a second service which describes ChRIS plugins that live in DockerHub.

The developer’s workflow looks like:

  1. Write code.

  2. git push

  3. Create a Github release.

A chain of automatic steps execute on every push (and release) which builds and publishes your software. Additionally, pull requests will be automatically built and tested but they will not be published until they are merged.

Goals

Each time you push to Github, container images should be rebuilt and pushed to Dockerhub.

  • platform support should include x86_64, PowerPC, and ARM

  • master branch will be built as :latest

  • tags and releases will be built as :<tag>

Steps to enable

During cookiecutter creation, answer "yes" (1) to publish_from_github_actions?

Tip
The cookiecutter-chrisapp outputs Github Actions configuration to .github/workflows/ci.yml

Your Github repository settings should define the following secrets. For help, see https://docs.github.com/en/actions/reference/encrypted-secrets

Tip
use organization level secrets. If your repository lives under https://github.com/FNNDSC, there is nothing you need to do.
Table 1. Required Secrets
Name Value

DOCKERHUB_USERNAME

DockerHub username, e.g. "fnndscbot"

DOCKERHUB_PASSWORD

DockerHub password

CHRIS_STORE_USER

https://chrisstore.co login in the form of username:password e.g. "chris:chris123"

Disable Cross-Compilation

Multi-arch docker image builds is experimental and has many known problems. You can change the automatic build configuration in .github/workflows/ci.yml to disable targeting of non-x86_64 platforms.

.github/workflows/ci.yml
@@ -100,7 +100,7 @@ jobs:
      - name: Build and push
        uses: docker/build-push-action@v2
        id: docker_build
        with:
          context: .
          file: ./Dockerfile
           tags: |
             ${{ steps.determine.outputs.dock_image }}
             localhost:5000/${{ steps.determine.outputs.dock_image }}
-          platforms: linux/amd64,linux/ppc64le,linux/arm64
+          platforms: linux/amd64
           push: true

Extra Information

We choose Github Actions over competing platforms, e.g. DockerHub autobuilds and Travis CI.

The convenience of single-platform is unrivaled. Moreover, true CI is more flexible than Dockerhub autobuilds, allowing buildx to be used for multi-platform images.