Skip to content
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

build Fedora+OpenSUSE arm64 container images #180

Merged
merged 4 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 64 additions & 3 deletions .github/workflows/container-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ jobs:
matrix:
package_source: [default, nightly]
os: [centos, fedora, opensuse]
arch: [amd64]
arch: [amd64, arm64]
exclude:
# there are no nightly packages for opensuse
- package_source: nightly
os: opensuse
- os: centos
arch: arm64
include:
- package_source: devbuilds
os: centos
Expand All @@ -74,14 +76,16 @@ jobs:
matrix:
package_source: [default, nightly]
os: [centos, fedora, opensuse]
arch: [amd64]
arch: [amd64, arm64]
exclude:
# there are no nightly packages for opensuse
- package_source: nightly
os: opensuse
# the distro packages for centos do not include an ad-dc
- package_source: default
os: centos
- os: centos
arch: arm64
runs-on: ubuntu-latest
env:
BUILDAH_FORMAT: oci
Expand All @@ -101,7 +105,10 @@ jobs:
strategy:
matrix:
os: [centos, fedora, opensuse]
arch: [amd64]
arch: [amd64, arm64]
exclude:
- os: centos
arch: arm64
runs-on: ubuntu-latest
env:
BUILDAH_FORMAT: oci
Expand Down Expand Up @@ -250,11 +257,26 @@ jobs:
with:
image: "samba-server:default-fedora-amd64"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Fetch server default-fedora-arm64
uses: ishworkh/[email protected]
with:
image: "samba-server:default-fedora-arm64"
container_engine: ${{ env.CONTAINER_CMD }}
Comment on lines +260 to +264
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm going to recommend skipping the tests for now. Let's just get the builds on emulated arm64 in this initial PR.

- name: Fetch server default-opensuse-arm64
uses: ishworkh/[email protected]
with:
image: "samba-server:default-opensuse-arm64"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Fetch server nightly-fedora-amd64
uses: ishworkh/[email protected]
with:
image: "samba-server:nightly-fedora-amd64"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Fetch server nightly-fedora-arm64
uses: ishworkh/[email protected]
with:
image: "samba-server:nightly-fedora-arm64"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Fetch server nightly-centos-amd64
uses: ishworkh/[email protected]
with:
Expand All @@ -271,17 +293,42 @@ jobs:
with:
image: "samba-ad-server:default-fedora-amd64"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Fetch ad-server default-fedora-arm64
uses: ishworkh/[email protected]
with:
image: "samba-ad-server:default-fedora-arm64"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Fetch ad-server default-opensuse-arm64
uses: ishworkh/[email protected]
with:
image: "samba-ad-server:default-opensuse-arm64"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Fetch ad-server nightly-fedora-amd64
uses: ishworkh/[email protected]
with:
image: "samba-ad-server:nightly-fedora-amd64"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Fetch ad-server nightly-fedora-arm64
uses: ishworkh/[email protected]
with:
image: "samba-ad-server:nightly-fedora-arm64"
container_engine: ${{ env.CONTAINER_CMD }}
# (client images)
- name: Fetch client default-fedora-amd64
uses: ishworkh/[email protected]
with:
image: "samba-client:default-fedora-amd64"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Fetch client default-fedora-arm64
uses: ishworkh/[email protected]
with:
image: "samba-client:default-fedora-arm64"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Fetch client default-opensuse-arm64
uses: ishworkh/[email protected]
with:
image: "samba-client:default-opensuse-arm64"
container_engine: ${{ env.CONTAINER_CMD }}
# (toolbox images)
- name: Fetch toolbox default-fedora-amd64
uses: ishworkh/[email protected]
Expand All @@ -297,12 +344,20 @@ jobs:
--repo-base=${REPO_BASE}
--no-distro-qualified
-i samba-server:default-fedora-amd64
-i samba-server:default-fedora-arm64
-i samba-server:default-opensuse-arm64
-i samba-server:nightly-fedora-amd64
-i samba-server:nightly-fedora-arm64
-i samba-server:nightly-centos-amd64
-i samba-server:devbuilds-centos-amd64
-i samba-ad-server:default-fedora-amd64
-i samba-ad-server:default-fedora-arm64
-i samba-ad-server:default-opensuse-arm64
-i samba-ad-server:nightly-fedora-amd64
-i samba-ad-server:nightly-fedora-arm64
-i samba-client:default-fedora-amd64
-i samba-client:default-fedora-arm64
-i samba-client:default-opensuse-arm64
-i samba-toolbox:default-fedora-amd64
- name: Push images
run: >
Expand All @@ -313,10 +368,16 @@ jobs:
--push-state=exists
--push-selected-tags=mixed
-i ${REPO_BASE}/samba-server:default-fedora-amd64
-i ${REPO_BASE}/samba-server:default-fedora-arm64
-i ${REPO_BASE}/samba-server:default-opensuse-arm64
-i ${REPO_BASE}/samba-server:nightly-fedora-amd64
-i ${REPO_BASE}/samba-server:nightly-centos-amd64
-i ${REPO_BASE}/samba-server:devbuilds-centos-amd64
-i ${REPO_BASE}/samba-ad-server:default-fedora-amd64
-i ${REPO_BASE}/samba-ad-server:default-fedora-arm64
-i ${REPO_BASE}/samba-ad-server:default-opensuse-arm64
-i ${REPO_BASE}/samba-ad-server:nightly-fedora-amd64
-i ${REPO_BASE}/samba-client:default-fedora-amd64
-i ${REPO_BASE}/samba-client:default-fedora-arm64
-i ${REPO_BASE}/samba-client:default-opensuse-arm64
-i ${REPO_BASE}/samba-toolbox:default-fedora-amd64
59 changes: 43 additions & 16 deletions hack/build-image
Original file line number Diff line number Diff line change
Expand Up @@ -203,33 +203,60 @@ def container_engine(cli):

def container_build(cli, target):
"""Construct and execute a command to build the target container image."""
args = [container_engine(cli), "build"]
eng = container_engine(cli)
tasks = []

# For docker cross-builds we need to use buildx
if "docker" in eng and target.arch != host_arch():
args = [eng, "buildx"]

# Docker's default builder only supports the host architecture.
# Therefore, we need to create a new builder to support other
# architectures, and we must ensure we start with a fresh builder
# that does not contain any images from previous builds.
tasks.append(lambda : run(cli, args + ["rm", target.flat_name()], check=False))
tasks.append(lambda : run(cli, args + ["create", f"--name={target.flat_name()}"], check=True))

tasks.append(lambda : run(cli, args + [
"build",
f"--builder={target.flat_name()}",
f"--platform=linux/{target.arch}",
"--load"] + create_common_container_engine_args(cli, target), check=True))

tasks.append(lambda : run(cli, args + ["rm", target.flat_name()], check=True))
else:
args = [eng, "build"]
if target.arch != host_arch() or FORCE_ARCH_FLAG:
# We've noticed a few small quirks when using podman with the --arch
# option. The main issue is that building the client image works
# but then the toolbox image fails because it somehow doesn't see
# the image we just built as usable. This doesn't happen when
# --arch is not provided. So if the target arch and the host_arch
# are the same, skip passing the extra argument.
args += [f"--arch={target.arch}"]

tasks.append(lambda : run(cli, args + create_common_container_engine_args(cli, target), check=True))

for task in tasks:
task()

def create_common_container_engine_args(cli, target):
args = []
pkgs_from = PACKAGES_FROM[target.pkg_source]
if pkgs_from:
args.append(f"--build-arg=INSTALL_PACKAGES_FROM={pkgs_from}")
# docker doesn't currently support alt. architectures
if "docker" in args[0]:
if target.arch != host_arch():
raise RuntimeError("Docker does not support --arch")
elif target.arch != host_arch() or FORCE_ARCH_FLAG:
# We've noticed a few small quirks when using podman with the --arch
# option. The main issue is that building the client image works
# but then the toolbox image fails because it somehow doesn't see
# the image we just built as usable. This doesn't happen when
# --arch is not provided. So if the target arch and the host_arch
# are the same, skip passing the extra argument.
args.append(f"--arch={target.arch}")

if cli.extra_build_arg:
args.extend(cli.extra_build_arg)

for tname in target.all_names(baseless=cli.without_repo_bases):
args.append("-t")
args.append(tname)

args.append("-f")
args.append(target_containerfile(target))
args.append(kind_source_dir(target.name))
args = [str(a) for a in args]
run(cli, args, check=True)

return [str(a) for a in args]

def container_push(cli, push_name):
"""Construct and execute a command to push a container image."""
Expand Down