From 0d31400b970ae76187519bd099f2eb8320ca8437 Mon Sep 17 00:00:00 2001 From: Paolo Bosetti Date: Fri, 16 Dec 2022 16:07:56 +0100 Subject: [PATCH] Support for building images locally --- CONTRIBUTING.md | 3 ++- Makefile | 1 + README.md | 20 ++++++++++++++++++++ android-arm/Dockerfile.in | 3 ++- android-arm64/Dockerfile.in | 3 ++- bare-armv7emhf-nano_newlib/Dockerfile.in | 3 ++- linux-arm64-full/Dockerfile.in | 3 ++- linux-arm64-lts/Dockerfile.in | 3 ++- linux-arm64-musl/Dockerfile.in | 3 ++- linux-arm64/Dockerfile.in | 3 ++- linux-armv5-musl/Dockerfile.in | 3 ++- linux-armv5-uclibc/Dockerfile.in | 3 ++- linux-armv5/Dockerfile.in | 3 ++- linux-armv6-lts/Dockerfile.in | 3 ++- linux-armv6-musl/Dockerfile.in | 3 ++- linux-armv6/Dockerfile.in | 3 ++- linux-armv7-lts/Dockerfile.in | 3 ++- linux-armv7/Dockerfile.in | 3 ++- linux-armv7a-lts/Dockerfile.in | 3 ++- linux-armv7a/Dockerfile.in | 3 ++- linux-armv7l-musl/Dockerfile.in | 3 ++- linux-i686/Dockerfile.in | 3 ++- linux-m68k-uclibc/Dockerfile.in | 3 ++- linux-mips-lts/Dockerfile.in | 3 ++- linux-mips/Dockerfile.in | 3 ++- linux-mipsel-lts/Dockerfile.in | 3 ++- linux-ppc64le/Dockerfile.in | 3 ++- linux-riscv32/Dockerfile.in | 3 ++- linux-riscv64/Dockerfile.in | 3 ++- linux-s390x/Dockerfile.in | 3 ++- linux-x64-clang/Dockerfile.in | 3 ++- linux-x64-tinycc/Dockerfile.in | 3 ++- linux-x64/Dockerfile.in | 3 ++- linux-x86/Dockerfile.in | 3 ++- linux-x86_64-full/Dockerfile.in | 3 ++- linux-xtensa-uclibc/Dockerfile.in | 3 ++- web-wasi/Dockerfile.in | 3 ++- windows-arm64/Dockerfile.in | 3 ++- windows-armv7/Dockerfile.in | 3 ++- windows-shared-x64-posix/Dockerfile.in | 3 ++- windows-shared-x64/Dockerfile.in | 3 ++- windows-shared-x86/Dockerfile.in | 3 ++- windows-static-x64-posix/Dockerfile.in | 3 ++- windows-static-x64/Dockerfile.in | 3 ++- windows-static-x86/Dockerfile.in | 3 ++- 45 files changed, 107 insertions(+), 43 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ee14d35..304a875 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -127,7 +127,8 @@ Then you must create a file named `Dockerfile.in` in the image folder (`linux-ar Copy text to `Dockerfile.in` file: ```docker -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/Makefile b/Makefile index fb7b188..0eb7da3 100644 --- a/Makefile +++ b/Makefile @@ -247,6 +247,7 @@ $(STANDARD_IMAGES): %: %/Dockerfile base mkdir -p $@/imagefiles && cp -r imagefiles $@/ $(DOCKER) build -t $(ORG)/$@:latest \ -t $(ORG)/$@:$(TAG) \ + --build-arg ORG=$(ORG) \ --build-arg IMAGE=$(ORG)/$@ \ --build-arg VERSION=$(TAG) \ --build-arg VCS_REF=`git rev-parse --short HEAD` \ diff --git a/README.md b/README.md index 9571307..ea8ca8a 100644 --- a/README.md +++ b/README.md @@ -565,6 +565,26 @@ The key difference is that [dockbuild](https://github.com/dockbuild/dockbuild#re **dockcross** is used to build binaries for many different platforms. **dockcross** performs a cross compilation where the host build system is a Linux x86_64 / amd64 Docker image (so that it can be used for building binaries on any system which can run Docker images) and the target runtime system varies. +## Build images by yourself + +Perbuilt images available on Docker hub are single architecture amd64 images. Those images work evan on different architectures: for example, if you run a dockcross image on Docker running on an Apple M1, the image will run in emulation mode, meaning that it will still work as expected, although it will be slower than running on native hardware (you can expect a factor or 10 or more). + +To overcome this limitation, you can build your own images on non-amd64 architectures. To do so, you can use the `Makefile` provided in this repository. For example, to build the `linux-armv7` image, and provided that your Docker hub organization name is `ACME`, you can run: + +```bash +$ make ORG=ACME base +$ make ORG=ACME linux-armv7 +``` + +This will create the Docker images `ACME/base` and `ACME/linux-armv7`, so that you can later launch a container using the `ACME/linux-armv7` image: + +``` +$ docker run --rm ACME/linux-armv7 uname -a +Linux 89b164ee8d90 5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022 aarch64 GNU/Linux +``` + +Note that the architecture is now `aarch64` instead of `amd64`, so it runs natively on the Apple M1. + \-\-- Credits: diff --git a/android-arm/Dockerfile.in b/android-arm/Dockerfile.in index 92544ae..e3382c7 100644 --- a/android-arm/Dockerfile.in +++ b/android-arm/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest MAINTAINER Matt McCormick "matt.mccormick@kitware.com" # The cross-compiling emulator diff --git a/android-arm64/Dockerfile.in b/android-arm64/Dockerfile.in index 3c7f477..52c91ee 100644 --- a/android-arm64/Dockerfile.in +++ b/android-arm64/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest MAINTAINER Matt McCormick "matt.mccormick@kitware.com" RUN \ sed -i '/debian-security/d' /etc/apt/sources.list && \ diff --git a/bare-armv7emhf-nano_newlib/Dockerfile.in b/bare-armv7emhf-nano_newlib/Dockerfile.in index 1a730d4..5ecd3f3 100644 --- a/bare-armv7emhf-nano_newlib/Dockerfile.in +++ b/bare-armv7emhf-nano_newlib/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Chen Tao t.clydechen@gmail.com" diff --git a/linux-arm64-full/Dockerfile.in b/linux-arm64-full/Dockerfile.in index 1851bfa..abd7473 100644 --- a/linux-arm64-full/Dockerfile.in +++ b/linux-arm64-full/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-arm64-lts/Dockerfile.in b/linux-arm64-lts/Dockerfile.in index ab93e16..b08ab79 100644 --- a/linux-arm64-lts/Dockerfile.in +++ b/linux-arm64-lts/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest # This is for 64-bit ARM Linux machine (Ubuntu 18.04 or Debian 9 mini) diff --git a/linux-arm64-musl/Dockerfile.in b/linux-arm64-musl/Dockerfile.in index 19cf1c1..bb4cf9d 100644 --- a/linux-arm64-musl/Dockerfile.in +++ b/linux-arm64-musl/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest ENV XCC_PREFIX /usr/xcc ENV CROSS_TRIPLE aarch64-linux-musl diff --git a/linux-arm64/Dockerfile.in b/linux-arm64/Dockerfile.in index d0cd968..5e7ab4f 100644 --- a/linux-arm64/Dockerfile.in +++ b/linux-arm64/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-armv5-musl/Dockerfile.in b/linux-armv5-musl/Dockerfile.in index 3b9a46b..32d219d 100755 --- a/linux-armv5-musl/Dockerfile.in +++ b/linux-armv5-musl/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-armv5-uclibc/Dockerfile.in b/linux-armv5-uclibc/Dockerfile.in index c8856bd..3a71e6b 100644 --- a/linux-armv5-uclibc/Dockerfile.in +++ b/linux-armv5-uclibc/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-armv5/Dockerfile.in b/linux-armv5/Dockerfile.in index 94b1077..0b93132 100644 --- a/linux-armv5/Dockerfile.in +++ b/linux-armv5/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-armv6-lts/Dockerfile.in b/linux-armv6-lts/Dockerfile.in index 20ae9f5..4ca4db4 100644 --- a/linux-armv6-lts/Dockerfile.in +++ b/linux-armv6-lts/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-armv6-musl/Dockerfile.in b/linux-armv6-musl/Dockerfile.in index 2cf5d27..980e925 100644 --- a/linux-armv6-musl/Dockerfile.in +++ b/linux-armv6-musl/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest ENV XCC_PREFIX /usr/xcc ENV CROSS_TRIPLE armv6-linux-musleabihf diff --git a/linux-armv6/Dockerfile.in b/linux-armv6/Dockerfile.in index 20ae9f5..4ca4db4 100644 --- a/linux-armv6/Dockerfile.in +++ b/linux-armv6/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-armv7-lts/Dockerfile.in b/linux-armv7-lts/Dockerfile.in index a78da94..dc38172 100644 --- a/linux-armv7-lts/Dockerfile.in +++ b/linux-armv7-lts/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-armv7/Dockerfile.in b/linux-armv7/Dockerfile.in index f669053..ac075bf 100644 --- a/linux-armv7/Dockerfile.in +++ b/linux-armv7/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-armv7a-lts/Dockerfile.in b/linux-armv7a-lts/Dockerfile.in index 80e7acd..e5e0a75 100644 --- a/linux-armv7a-lts/Dockerfile.in +++ b/linux-armv7a-lts/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-armv7a/Dockerfile.in b/linux-armv7a/Dockerfile.in index 2952fdd..aba98df 100644 --- a/linux-armv7a/Dockerfile.in +++ b/linux-armv7a/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-armv7l-musl/Dockerfile.in b/linux-armv7l-musl/Dockerfile.in index 0282640..0b276f0 100644 --- a/linux-armv7l-musl/Dockerfile.in +++ b/linux-armv7l-musl/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest ENV XCC_PREFIX /usr/xcc ENV CROSS_TRIPLE armv7l-linux-musleabihf diff --git a/linux-i686/Dockerfile.in b/linux-i686/Dockerfile.in index 826bb1c..091770b 100644 --- a/linux-i686/Dockerfile.in +++ b/linux-i686/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="PJ Reid PJ.Reid@Zetier.com" diff --git a/linux-m68k-uclibc/Dockerfile.in b/linux-m68k-uclibc/Dockerfile.in index 41eeb80..8f41715 100644 --- a/linux-m68k-uclibc/Dockerfile.in +++ b/linux-m68k-uclibc/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-mips-lts/Dockerfile.in b/linux-mips-lts/Dockerfile.in index 2fdf593..359504c 100644 --- a/linux-mips-lts/Dockerfile.in +++ b/linux-mips-lts/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-mips/Dockerfile.in b/linux-mips/Dockerfile.in index 2fdf593..359504c 100644 --- a/linux-mips/Dockerfile.in +++ b/linux-mips/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-mipsel-lts/Dockerfile.in b/linux-mipsel-lts/Dockerfile.in index 323bb84..2930326 100644 --- a/linux-mipsel-lts/Dockerfile.in +++ b/linux-mipsel-lts/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-ppc64le/Dockerfile.in b/linux-ppc64le/Dockerfile.in index 123ee16..f89efe8 100644 --- a/linux-ppc64le/Dockerfile.in +++ b/linux-ppc64le/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-riscv32/Dockerfile.in b/linux-riscv32/Dockerfile.in index e563c8d..9f2deae 100644 --- a/linux-riscv32/Dockerfile.in +++ b/linux-riscv32/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-riscv64/Dockerfile.in b/linux-riscv64/Dockerfile.in index a9ec8ba..c084733 100644 --- a/linux-riscv64/Dockerfile.in +++ b/linux-riscv64/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-s390x/Dockerfile.in b/linux-s390x/Dockerfile.in index 232636f..83b6cca 100644 --- a/linux-s390x/Dockerfile.in +++ b/linux-s390x/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-x64-clang/Dockerfile.in b/linux-x64-clang/Dockerfile.in index 64611c7..6b73ea6 100644 --- a/linux-x64-clang/Dockerfile.in +++ b/linux-x64-clang/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-x64-tinycc/Dockerfile.in b/linux-x64-tinycc/Dockerfile.in index db61fef..2104f51 100644 --- a/linux-x64-tinycc/Dockerfile.in +++ b/linux-x64-tinycc/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-x64/Dockerfile.in b/linux-x64/Dockerfile.in index 57c79a1..38d58a6 100644 --- a/linux-x64/Dockerfile.in +++ b/linux-x64/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-x86/Dockerfile.in b/linux-x86/Dockerfile.in index f6864dd..4049896 100644 --- a/linux-x86/Dockerfile.in +++ b/linux-x86/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-x86_64-full/Dockerfile.in b/linux-x86_64-full/Dockerfile.in index 742f80c..b008e94 100644 --- a/linux-x86_64-full/Dockerfile.in +++ b/linux-x86_64-full/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/linux-xtensa-uclibc/Dockerfile.in b/linux-xtensa-uclibc/Dockerfile.in index 96e8970..4a8e90d 100644 --- a/linux-xtensa-uclibc/Dockerfile.in +++ b/linux-xtensa-uclibc/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/web-wasi/Dockerfile.in b/web-wasi/Dockerfile.in index 83fdabe..e537d91 100644 --- a/web-wasi/Dockerfile.in +++ b/web-wasi/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/windows-arm64/Dockerfile.in b/windows-arm64/Dockerfile.in index 6876f4d..1d060a1 100644 --- a/windows-arm64/Dockerfile.in +++ b/windows-arm64/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/windows-armv7/Dockerfile.in b/windows-armv7/Dockerfile.in index fffed5e..3767097 100644 --- a/windows-armv7/Dockerfile.in +++ b/windows-armv7/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/windows-shared-x64-posix/Dockerfile.in b/windows-shared-x64-posix/Dockerfile.in index 9e42225..3e3386b 100644 --- a/windows-shared-x64-posix/Dockerfile.in +++ b/windows-shared-x64-posix/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/windows-shared-x64/Dockerfile.in b/windows-shared-x64/Dockerfile.in index 56f1115..e91f43c 100644 --- a/windows-shared-x64/Dockerfile.in +++ b/windows-shared-x64/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/windows-shared-x86/Dockerfile.in b/windows-shared-x86/Dockerfile.in index 17de0df..7407dd4 100644 --- a/windows-shared-x86/Dockerfile.in +++ b/windows-shared-x86/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/windows-static-x64-posix/Dockerfile.in b/windows-static-x64-posix/Dockerfile.in index 513d4ce..53454cc 100644 --- a/windows-static-x64-posix/Dockerfile.in +++ b/windows-static-x64-posix/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/windows-static-x64/Dockerfile.in b/windows-static-x64/Dockerfile.in index fe50776..b653455 100644 --- a/windows-static-x64/Dockerfile.in +++ b/windows-static-x64/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com" diff --git a/windows-static-x86/Dockerfile.in b/windows-static-x86/Dockerfile.in index 82df724..23e0b92 100644 --- a/windows-static-x86/Dockerfile.in +++ b/windows-static-x86/Dockerfile.in @@ -1,4 +1,5 @@ -FROM dockcross/base:latest +ARG ORG=dockcross +FROM ${ORG}/base:latest LABEL maintainer="Matt McCormick matt.mccormick@kitware.com"