Skip to content

Native cross-compilation, artifacts and multi-platform image #3315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 12, 2022

Conversation

crazy-max
Copy link
Contributor

@crazy-max crazy-max commented Dec 19, 2020

Ref. #3312 docker/buildx#451

This PR will handle validation (lint, vendoring) through GitHub Actions. We keep Travis workflow for now.

Handles native cross-compilation in the Dockerfile and also upload artifacts in the workflow and multi-platform image to Docker Hub.

cc. @arkodg @milosgajdos

Signed-off-by: CrazyMax crazy-max@users.noreply.github.com

@crazy-max crazy-max marked this pull request as ready for review December 19, 2020 10:10
@milosgajdos
Copy link
Member

Wonderful! Can't wait to chuck Travis CI just in time for the end of the year 👍

@crazy-max crazy-max force-pushed the ghactions branch 2 times, most recently from 06565e1 to cf232a7 Compare December 27, 2020 12:34
@crazy-max
Copy link
Contributor Author

crazy-max commented Dec 27, 2020

@arkodg I've made some changes to avoid shell scripts and only rely on buildx bake. This allows us to be sandboxed in CI and locally and therefore Docker itself is enough (will also work on Windows where make is not available):

# Validate vendor
$ docker buildx bake vendor-validate

# golangci-lint
$ docker buildx bake lint

# Run golangci-lint and vendor-validate
$ docker buildx bake validate

# Update vendor
$ docker buildx bake vendor-update

Base automatically changed from master to main January 27, 2021 15:51
@crazy-max crazy-max closed this Sep 26, 2021
@crazy-max crazy-max reopened this Dec 20, 2021
@crazy-max crazy-max changed the title Migrate to GitHub Actions Native cross-compilation, artifacts and multi-platform image Dec 20, 2021
@codecov-commenter
Copy link

codecov-commenter commented Dec 20, 2021

Codecov Report

Merging #3315 (185a460) into main (020bcce) will not change coverage.
The diff coverage is n/a.

❗ Current head 185a460 differs from pull request most recent head 7c8cb3b. Consider uploading reports for the commit 7c8cb3b to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3315   +/-   ##
=======================================
  Coverage   56.35%   56.35%           
=======================================
  Files         101      101           
  Lines        7307     7307           
=======================================
  Hits         4118     4118           
  Misses       2534     2534           
  Partials      655      655           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 020bcce...7c8cb3b. Read the comment docs.

@crazy-max crazy-max force-pushed the ghactions branch 2 times, most recently from dcef75b to 7c8cb3b Compare December 20, 2021 15:39
@crazy-max
Copy link
Contributor Author

crazy-max commented Dec 20, 2021

@milosgajdos As discussed, reviving this PR:

  • Use buildx bake and goreleaser-xx for native cross-compilation in the Dockerfile.
  • Create artifacts with artifact (current platform) or artifact-all target for cross-compilation:
    • darwin/amd64
    • darwin/arm64
    • linux/amd64
    • linux/arm/v5
    • linux/arm/v6
    • linux/arm/v7
    • linux/arm64
    • linux/ppc64le
    • linux/s390x
  • Support Docker multi-platform image
  • GitHub Actions
    • On git push tag event semver like v2.8.0:
      • Artifacts will be available in the pipeline through actions/upload-artifact
      • Will create the GitHub Release and push artifacts
      • Will create and push Docker tags distribution/distribution:2.8.0 / distribution/distribution:latest
    • On git push (main branch)
      • Artifacts will be available in the pipeline through actions/upload-artifact
      • Will push Docker tag distribution/distribution:edge
    • On git pull_request event

Everything is already in place on https://github.com/crazy-max/docker-distribution as well as the GitHub Actions pipeline if you want to take a look.

Here is how to build with buildx:

# create builder for multi-arch build and cache feature (see below)
docker buildx create --name distribution-builder --use

# build docker image and output to docker with registry:local tag (default)
docker buildx bake image-local

# build multi-platform image
docker buildx bake image-all

# create the artifact matching your current platform in ./bin
docker buildx bake artifact

# create artifacts for many platforms in ./bin
docker buildx bake artifact-all

# build binary in ./bin/registry
docker buildx bake binary

image

https://github.com/crazy-max/docker-distribution/runs/4584555911?check_suite_focus=true#step:10:23

image

https://github.com/crazy-max/docker-distribution/releases/tag/v2.8.0

image

https://hub.docker.com/r/crazymax/distribution/tags?page=1&ordering=last_updated

image

OCI test results

@crazy-max crazy-max force-pushed the ghactions branch 2 times, most recently from 1f70571 to edb423b Compare December 22, 2021 17:43
@crazy-max crazy-max requested a review from thaJeztah December 22, 2021 17:45
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Copy link
Collaborator

@wy65701436 wy65701436 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@milosgajdos milosgajdos merged commit bb1fb61 into distribution:main Jan 12, 2022
@crazy-max crazy-max deleted the ghactions branch January 12, 2022 11:26
crazy-max added a commit to crazy-max/docker-distribution that referenced this pull request Jan 12, 2022
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants