Merge "add: cross-compile support"
This commit is contained in:
commit
95a671b00d
|
@ -526,6 +526,28 @@ variables that will be picked up from the user env:
|
|||
Also these variables could be overwritten using ``--build-args``, which have
|
||||
precedence.
|
||||
|
||||
Cross-compiling
|
||||
---------------
|
||||
|
||||
It is possible to cross-compile container images in order to, e.g., build
|
||||
``aarch64`` images on a ``x86_64`` machine.
|
||||
|
||||
To build ``ARM`` images on ``x86_64`` platform, pass the ``--base-arch`` and
|
||||
``--platform`` arguments:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
kolla-build --platform linux/arm64 --base-arch aarch64
|
||||
|
||||
.. note::
|
||||
|
||||
To make this work on x86_64 platform you can use tools like: `qemu-user-static
|
||||
<https://github.com/multiarch/qemu-user-static>`_ or `binfmt
|
||||
<https://github.com/tonistiigi/binfmt>`_.
|
||||
|
||||
To make this work on Apple Silicon you can use Docker Desktop or Podman
|
||||
Desktop to build ``x86_64`` or native ``ARM`` images.
|
||||
|
||||
Known issues
|
||||
============
|
||||
|
||||
|
|
|
@ -143,6 +143,10 @@ if hostarch == 'aarch64':
|
|||
elif hostarch == 'x86_64':
|
||||
debianarch = 'amd64'
|
||||
|
||||
# NOTE: Apple Silicon reports as arm64 which is aarch64
|
||||
if hostarch == "arm64":
|
||||
hostarch = "aarch64"
|
||||
|
||||
_CLI_OPTS = [
|
||||
cfg.StrOpt('base', short='b', default='rocky',
|
||||
choices=BASE_OS_DISTRO,
|
||||
|
@ -183,6 +187,10 @@ _CLI_OPTS = [
|
|||
help='The network mode for Docker build. Example: host'),
|
||||
cfg.BoolOpt('cache', default=True,
|
||||
help='Use the container engine cache when building'),
|
||||
cfg.StrOpt('platform', default=None,
|
||||
help=('The platform to use for a cross-compile build. Should '
|
||||
'be set in conjunction with "--base-arch" argument. '
|
||||
'Example: "--platform linux/arm64 --base-arch aarch64"')),
|
||||
cfg.MultiOpt('profile', types.String(), short='p',
|
||||
help=('Build a pre-defined set of images, see [profiles]'
|
||||
' section in config. The default profiles are:'
|
||||
|
|
|
@ -412,6 +412,7 @@ class BuildTask(EngineTask):
|
|||
network_mode=self.conf.network_mode,
|
||||
pull=pull,
|
||||
forcerm=self.forcerm,
|
||||
platform=self.conf.platform,
|
||||
buildargs=buildargs,
|
||||
**kwargs)[1]:
|
||||
if self.conf.engine == engine.Engine.PODMAN.value:
|
||||
|
|
|
@ -168,7 +168,7 @@ class TasksTest(base.TestCase):
|
|||
mock_client().images.build.assert_called_once_with(
|
||||
path=self.image.path, tag=self.image.canonical_name,
|
||||
network_mode='host', nocache=False, rm=True, pull=True,
|
||||
forcerm=True, buildargs=None, **self.build_kwargs)
|
||||
forcerm=True, platform=None, buildargs=None, **self.build_kwargs)
|
||||
|
||||
self.assertTrue(builder.success)
|
||||
|
||||
|
@ -185,7 +185,7 @@ class TasksTest(base.TestCase):
|
|||
mock_client().images.build.assert_called_once_with(
|
||||
path=self.image.path, tag=self.image.canonical_name,
|
||||
network_mode='bridge', nocache=False, rm=True, pull=True,
|
||||
forcerm=True, buildargs=None, **self.build_kwargs)
|
||||
forcerm=True, platform=None, buildargs=None, **self.build_kwargs)
|
||||
|
||||
self.assertTrue(builder.success)
|
||||
|
||||
|
@ -205,7 +205,8 @@ class TasksTest(base.TestCase):
|
|||
mock_client().images.build.assert_called_once_with(
|
||||
path=self.image.path, tag=self.image.canonical_name,
|
||||
network_mode='host', nocache=False, rm=True, pull=True,
|
||||
forcerm=True, buildargs=build_args, **self.build_kwargs)
|
||||
forcerm=True, platform=None, buildargs=build_args,
|
||||
**self.build_kwargs)
|
||||
|
||||
self.assertTrue(builder.success)
|
||||
|
||||
|
@ -224,7 +225,8 @@ class TasksTest(base.TestCase):
|
|||
mock_client().images.build.assert_called_once_with(
|
||||
path=self.image.path, tag=self.image.canonical_name,
|
||||
network_mode='host', nocache=False, rm=True, pull=True,
|
||||
forcerm=True, buildargs=build_args, **self.build_kwargs)
|
||||
forcerm=True, platform=None, buildargs=build_args,
|
||||
**self.build_kwargs)
|
||||
|
||||
self.assertTrue(builder.success)
|
||||
|
||||
|
@ -245,7 +247,8 @@ class TasksTest(base.TestCase):
|
|||
mock_client().images.build.assert_called_once_with(
|
||||
path=self.image.path, tag=self.image.canonical_name,
|
||||
network_mode='host', nocache=False, rm=True, pull=True,
|
||||
forcerm=True, buildargs=build_args, **self.build_kwargs)
|
||||
forcerm=True, platform=None, buildargs=build_args,
|
||||
**self.build_kwargs)
|
||||
|
||||
self.assertTrue(builder.success)
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
Add support for cross-compile. Enable creation of container images
|
||||
on emulated architectures.
|
Loading…
Reference in New Issue