# HG changeset patch
# User Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr>
# Date 1698760259 -3600
#      Tue Oct 31 14:50:59 2023 +0100
# Node ID 7496aea73410b18340ff558f44d4de92fa6d71b0
# Parent  73e4d97e8d2312501020b8b5cc4e84c0fef4c852
Use buildx to compile when installed

diff --git a/NEWS.rst b/NEWS.rst
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -9,6 +9,8 @@
 
 https://github.com/docker/docker-py/issues/2230
 
+If buildx for docker is installed, use it to build.
+
 20.14.0
 -------
 
diff --git a/odoo_scripts/docker_build.py b/odoo_scripts/docker_build.py
--- a/odoo_scripts/docker_build.py
+++ b/odoo_scripts/docker_build.py
@@ -242,13 +242,23 @@
     _logger.debug("Docker Pull %s", pull)
     full_tags = [repository] if nmspc.local else [f"{repository}:{tag}" for tag in tags]
     with capture_docker_exit_code() as exit_code:
-        docker.image.build(
-            context_path=".",
-            pull=pull,
-            build_args=buildargs,
-            tags=full_tags,
-            file=dockerfile,
-        )
+        if docker.buildx.is_installed():
+            _logger.info("Starting build with buildx")
+            docker.buildx.build(
+                context_path=".",
+                pull=pull,
+                build_args=buildargs,
+                tags=full_tags,
+                file=dockerfile,
+            )
+        else:
+            docker.image.build(
+                context_path=".",
+                pull=pull,
+                build_args=buildargs,
+                tags=full_tags,
+                file=dockerfile,
+            )
     if dev:
         call(["rm", dockerfile])