Sign inSign up

agrozyme/podman-qemu

By agrozyme

Updated 3 months ago

Alpine-based image with podman and qemu. Easily allows cross platform image builds.

Image
2

10K+

agrozyme/podman-qemu repository overview

Summary

Source: https://gitlab.com/agrozyme-docker/podman-qemu

Alpine-based image with podman and qemu. Easily allows cross platform image builds.

Description

Inspired By jonoh/docker-buildx-qemu

It's been tested with GitLab CI on gitlab.com

Support Architectures

This Docker image can emulate the environments.

Use valid GOARCH values, see:

Target Architectures

The Docker image can run in the environment (The intersection of Alpine and QEMU support platforms):

  • amd64
  • 386
  • arm64
  • arm
  • ppc64le
  • riscv64

GitLab CI Template

It has two template files for building multi-platform Docker images.

  • Single: For a single branch repository, deploy main to latest
  • Multiple: Each branch is mapped to a docker image tag and the repository name is the same as Docker Registry.

Docker Hub

  • Single: /.gitlab/ci/single/docker-hub.yaml
  • Multiple: /.gitlab/ci/multiple/docker-hub.yaml

GitLab Container Registry

  • Single: /.gitlab/ci/single/gitlab.yaml
  • Multiple: /.gitlab/ci/multiple/gitlab.yaml

Workflow:

  • The main tag of the docker image is used to test the build.
  • The build-one-arch job pushes the main tag of the docker image.
  • When the build-one-arch job is successful, then the other build job pushes the multi-platform Docker image.
  • After pushing the docker image, the build-metadata-push job will update the description of the Docker Hub repository.
    • Short description: The description of the project.
    • Full description: README.md

Environment variables

Put all docker image repositories into a Group and set Variables in CI / CD Settings

Override priority

Put the variables in .gitlab-ci.yml or CI / CD Settings to override default.

  • .gitlab-ci.yml stage variables
  • .gitlab-ci.yml global variables
  • Project CI / CD Settings
  • Group CI / CD Settings

Required

No default value, all variables are required. (Only for Docker Hub)

Optional

  • DOCKER_HUB_API_URL
    • The Docker Registry API url
    • Only use .gitlab-ci.yml to override
    • default: https://hub.docker.com/v2
  • DOCKER_REGISTRY
    • The docker login server
    • Only use .gitlab-ci.yml to override
    • It will be passed to the Dockerfile as an ARG.
    • default: docker.io
  • DOCKER_ARCH
    • The target architectures for building docker image.
    • default: amd64.
  • DOCKER_TAG_SUFFIX
    • The tag suffix for multi-platform docker image, it will override DOCKER_ARCH

Hook Scripts

It has two bash scripts to hook before_script and after_script, the scripts run at beginning and end of the docker build and push action.

  • before_script.sh
  • after_script.sh

Note:

  • If you want to download the files during the build of docker image, you can do this by writing before_script.sh and using COPY command in the Dockerfile.
  • It is just done once before / after the podman build and you can speed up the build of multi-platform docker image.

Build Jobs

It define some tasks, you can combine for your tasks

.build-one-arch

Build the same architecture image as the CI runner for quick testing of build scripts

.build-all-arch

Build the DOCKER_ARCH architecture image

.build-update-manifest

Create and push the manifest using DOCKER_ARCH

.build-update-metadata

Update metadata to the docker registry

Example

This GitLab example should give you an idea of how to use the image.

.gitlab-ci.yml

include:
  - project: agrozyme-docker/podman-qemu
    ref: main
    file: /.gitlab/ci/single/docker-hub.yaml

variables:
  DOCKER_ARCH: amd64,arm64

build-one-arch:
  extends:
    - .build-one-arch

build-all-arch:
  extends:
    - .build-all-arch
  parallel:
    matrix:
      - DOCKER_TAG_SUFFIX: [amd64, arm64]
  needs: ['build-one-arch']

build-manifest-create:
  extends:
    - .build-manifest-create
  needs: ['build-all-arch']

build-metadata-push:
  extends:
    - .build-metadata-push
  needs: ['build-manifest-create']

Tag summary

Content type

Image

Digest

sha256:e6b84a299

Size

87.3 MB

Last updated

3 months ago

docker pull agrozyme/podman-qemu