Skip to content
/ docker-ci-template Public template

This template will automatically build, release and push docker images for you as soon as a new base image is available.

License

Notifications You must be signed in to change notification settings

mietzen/docker-ci-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Docker CI Template

This template will automatically build, release and push docker images for you as soon as a new base image is available.

Simply place a Dockerfile at the root of the repo e.g.:

FROM debian:bookworm-20240211

RUN apt-get update && apt-get install -y \
    fortune \
    cowsay \
    && rm -rf /var/lib/apt/lists/*
RUN echo '/usr/games/fortune | /usr/games/cowsay && echo -e "\n"' >> /etc/bash.bashrc

Is important not to use a tag like latest, stable or any other tag that is not regular updated. For debian there are for example images with a date inside the tag.

The workflows will automatically build and release a new debian images with a cowsay message of the day under the following name: {DOCKER_HUB_USERNAME}/{REPO_NAME}:{BASE_IMAGE_TAG} e.g.: mietzen/debian-cowsay:bookworm-20240211 (The latest image also gets the latest tag)

Cowsay Example: https://github.com/mietzen/debian-cowsay

The workflow will build all platform listed in platforms.json and also push them as a multi-arch image.

Usage

Click on Use this template:

And follow the preparation steps.

Preparation

Github Token App

For the workflow to run you need to create a GitHub-App to generate tokens, follow:

https://github.com/actions/create-github-app-token

If you follow the instructions above you should have your App listed under Settings -> GitHub Apps:

Repository config

You need to activate auto-merge under Settings -> General -> Pull Requests:

and setup the branch protection for main under Settings -> Branch -> Add branch protection rule, for Branch name pattern type in main:

Then apply the following settings:

The status check Check-Build is only available after the docker-image.yml ran at least one time. You can trigger the workflow by simply opening a Pull-Request e.g. to add your Dockerfile.

Secrets

You need to add the following secrets as repository secrets in Actions:

  • APP_ID
  • APP_PRIVATE_KEY
  • DOCKER_HUB_DEPLOY_KEY

and to Dependabot:

  • APP_ID
  • APP_PRIVATE_KEY

[Optional] Add your DockerHub username and/or the docker image name under variables:

  • DOCKER_HUB_USERNAME
  • IMAGE_NAME

About

This template will automatically build, release and push docker images for you as soon as a new base image is available.

Topics

Resources

License

Stars

Watchers

Forks