Merge pull request #104374 from adisbladis/dockertools-cross-aarch64

dockerTools: Always cross compile for another arch in the cross example
This commit is contained in:
adisbladis 2020-11-20 14:57:26 +01:00 committed by GitHub
commit da3516f694
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -237,14 +237,14 @@ import ./make-test-python.nix ({ pkgs, ... }: {
with subtest("Ensure cross compiled image can be loaded and has correct arch."): with subtest("Ensure cross compiled image can be loaded and has correct arch."):
docker.succeed( docker.succeed(
"docker load --input='${pkgs.dockerTools.examples.cross-aarch64}'", "docker load --input='${pkgs.dockerTools.examples.cross}'",
) )
assert ( assert (
docker.succeed( docker.succeed(
"docker inspect ${pkgs.dockerTools.examples.cross-aarch64.imageName} " "docker inspect ${pkgs.dockerTools.examples.cross.imageName} "
+ "| ${pkgs.jq}/bin/jq -r .[].Architecture" + "| ${pkgs.jq}/bin/jq -r .[].Architecture"
).strip() ).strip()
== "arm64v8" == "${if pkgs.system == "aarch64-linux" then "amd64" else "arm64v8"}"
) )
''; '';
}) })

View File

@ -408,10 +408,15 @@ rec {
}; };
# basic example, with cross compilation # basic example, with cross compilation
cross-aarch64 = pkgsCross.aarch64-multiplatform.dockerTools.buildImage { cross = let
# Cross compile for x86_64 if on aarch64
crossPkgs =
if pkgs.system == "aarch64-linux" then pkgsCross.gnu64
else pkgsCross.aarch64-multiplatform;
in crossPkgs.dockerTools.buildImage {
name = "hello-cross"; name = "hello-cross";
tag = "latest"; tag = "latest";
contents = pkgsCross.aarch64-multiplatform.hello; contents = crossPkgs.hello;
}; };
} }