diff --git a/.dockerignore b/.dockerignore index 1e02921..f6d59c3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,7 @@ *.md *.sh -*/hello -*/nanoserver/hello.txt +**/hello +**/nanoserver/hello.txt .dockerignore .git Dockerfile* diff --git a/.travis.yml b/.travis.yml index e3965b2..c70dca4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,8 @@ before_script: script: - ./update.sh - - test -z "$(git status --porcelain '*/hello' '*/nanoserver/hello.txt')" - - travis_retry travis_retry travis_retry docker build -t "$image" hello-world + - test -z "$(git status --porcelain '**/hello' '**/nanoserver/hello.txt')" + - travis_retry docker build -t "$image" amd64/hello-world - ~/official-images/test/run.sh "$image" after_script: diff --git a/Dockerfile.build b/Dockerfile.build index 91302d9..74e9ddd 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -1,17 +1,71 @@ # explicitly use Debian for maximum cross-architecture compatibility -FROM debian:jessie-slim +FROM debian:stretch-slim + +#RUN dpkg --add-architecture i386 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ libc6-dev \ make \ +# \ +# gcc-multilib \ +# libc6-dev-i386 \ +# linux-libc-dev:i386 \ + \ + libc6-dev-arm64-cross \ + libc6-dev-armel-cross \ + libc6-dev-armhf-cross \ + libc6-dev-ppc64el-cross \ + libc6-dev-s390x-cross \ + \ + gcc-aarch64-linux-gnu \ + gcc-arm-linux-gnueabi \ + gcc-arm-linux-gnueabihf \ + gcc-powerpc64le-linux-gnu \ + gcc-s390x-linux-gnu \ && rm -rf /var/lib/apt/lists/* WORKDIR /usr/src/hello COPY . . RUN set -ex; \ - make clean all test; \ - find \( -name 'hello' -or -name 'hello.txt' \) -exec ls -l '{}' + + make clean all test \ + TARGET_ARCH='amd64' \ + CC='x86_64-linux-gnu-gcc' \ + STRIP='x86_64-linux-gnu-strip' + +RUN set -ex; \ + make clean all \ + TARGET_ARCH='arm32v5' \ + CC='arm-linux-gnueabi-gcc' \ + STRIP='arm-linux-gnueabi-strip' + +RUN set -ex; \ + make clean all \ + TARGET_ARCH='arm32v7' \ + CC='arm-linux-gnueabihf-gcc' \ + STRIP='arm-linux-gnueabihf-strip' + +RUN set -ex; \ + make clean all \ + TARGET_ARCH='arm64v8' \ + CC='aarch64-linux-gnu-gcc' \ + STRIP='aarch64-linux-gnu-strip' + +# TODO TARGET_ARCH='i386' (heinous package conflicts trying to get "gcc -m32"/"gcc-multilib" to work with all the cross-compiling gccs) + +RUN set -ex; \ + make clean all \ + TARGET_ARCH='ppc64le' \ + CC='powerpc64le-linux-gnu-gcc' \ + STRIP='powerpc64le-linux-gnu-strip' + +RUN set -ex; \ + make clean all \ + TARGET_ARCH='s390x' \ + CC='s390x-linux-gnu-gcc' \ + STRIP='s390x-linux-gnu-strip' + +RUN find \( -name 'hello' -or -name 'hello.txt' \) -exec ls -lh '{}' + CMD ["./hello-world/hello"] diff --git a/Makefile b/Makefile index 480b318..9675078 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,20 @@ -C_TARGETS := $(addsuffix hello, $(wildcard */)) +TARGET_ARCH := amd64 +C_TARGETS := $(addsuffix hello, $(wildcard $(TARGET_ARCH)/*/)) CC := gcc CFLAGS := -static -Os -nostartfiles -fno-asynchronous-unwind-tables +STRIP := strip .PHONY: all all: $(C_TARGETS) $(C_TARGETS): hello.c - $(CC) $(CFLAGS) -o '$@' -D DOCKER_IMAGE='"$(@D)"' -D DOCKER_GREETING="\"$$(cat '$(@D)/greeting.txt')\"" '$<' - strip -R .comment -s '$@' - @mkdir -p '$(@D)/nanoserver' - '$@' | sed -e 's/an Ubuntu container/a Nano Server container/g' -e 's!ubuntu bash!microsoft/nanoserver powershell!g' > '$(@D)/nanoserver/hello.txt' + $(CC) $(CFLAGS) -o '$@' -D DOCKER_IMAGE='"$(notdir $(@D))"' -D DOCKER_GREETING="\"$$(cat 'greetings/$(notdir $(@D)).txt')\"" '$<' + $(STRIP) -R .comment -s '$@' + @if [ '$(TARGET_ARCH)' = 'amd64' ]; then \ + mkdir -p '$(@D)/nanoserver'; \ + '$@' | sed -e 's/an Ubuntu container/a Nano Server container/g' -e 's!ubuntu bash!microsoft/nanoserver powershell!g' > '$(@D)/nanoserver/hello.txt'; \ + fi .PHONY: clean clean: @@ -20,5 +24,5 @@ clean: test: $(C_TARGETS) @for b in $^; do \ ( set -x && "./$$b" ); \ - ( set -x && "./$$b" | grep -q '"'"$$(dirname "$$b")"'"' ); \ + ( set -x && "./$$b" | grep -q '"'"$$(basename "$$(dirname "$$b")")"'"' ); \ done diff --git a/hello-seattle/Dockerfile b/amd64/hello-seattle/Dockerfile similarity index 100% rename from hello-seattle/Dockerfile rename to amd64/hello-seattle/Dockerfile diff --git a/hello-seattle/hello b/amd64/hello-seattle/hello similarity index 89% rename from hello-seattle/hello rename to amd64/hello-seattle/hello index 11be0af..5cba74e 100755 Binary files a/hello-seattle/hello and b/amd64/hello-seattle/hello differ diff --git a/hello-seattle/nanoserver/Dockerfile b/amd64/hello-seattle/nanoserver/Dockerfile similarity index 100% rename from hello-seattle/nanoserver/Dockerfile rename to amd64/hello-seattle/nanoserver/Dockerfile diff --git a/hello-seattle/nanoserver/hello.txt b/amd64/hello-seattle/nanoserver/hello.txt similarity index 100% rename from hello-seattle/nanoserver/hello.txt rename to amd64/hello-seattle/nanoserver/hello.txt diff --git a/hello-world/Dockerfile b/amd64/hello-world/Dockerfile similarity index 100% rename from hello-world/Dockerfile rename to amd64/hello-world/Dockerfile diff --git a/hello-world/hello b/amd64/hello-world/hello similarity index 88% rename from hello-world/hello rename to amd64/hello-world/hello index 5812d13..ae5e703 100755 Binary files a/hello-world/hello and b/amd64/hello-world/hello differ diff --git a/hello-world/nanoserver/Dockerfile b/amd64/hello-world/nanoserver/Dockerfile similarity index 100% rename from hello-world/nanoserver/Dockerfile rename to amd64/hello-world/nanoserver/Dockerfile diff --git a/hello-world/nanoserver/hello.txt b/amd64/hello-world/nanoserver/hello.txt similarity index 100% rename from hello-world/nanoserver/hello.txt rename to amd64/hello-world/nanoserver/hello.txt diff --git a/hola-mundo/Dockerfile b/amd64/hola-mundo/Dockerfile similarity index 100% rename from hola-mundo/Dockerfile rename to amd64/hola-mundo/Dockerfile diff --git a/hola-mundo/hello b/amd64/hola-mundo/hello similarity index 85% rename from hola-mundo/hello rename to amd64/hola-mundo/hello index 3219652..0e14f3e 100755 Binary files a/hola-mundo/hello and b/amd64/hola-mundo/hello differ diff --git a/hola-mundo/nanoserver/Dockerfile b/amd64/hola-mundo/nanoserver/Dockerfile similarity index 100% rename from hola-mundo/nanoserver/Dockerfile rename to amd64/hola-mundo/nanoserver/Dockerfile diff --git a/hola-mundo/nanoserver/hello.txt b/amd64/hola-mundo/nanoserver/hello.txt similarity index 100% rename from hola-mundo/nanoserver/hello.txt rename to amd64/hola-mundo/nanoserver/hello.txt diff --git a/arm32v5/hello-seattle/Dockerfile b/arm32v5/hello-seattle/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/arm32v5/hello-seattle/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/arm32v5/hello-seattle/hello b/arm32v5/hello-seattle/hello new file mode 100755 index 0000000..7f28666 Binary files /dev/null and b/arm32v5/hello-seattle/hello differ diff --git a/arm32v5/hello-world/Dockerfile b/arm32v5/hello-world/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/arm32v5/hello-world/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/arm32v5/hello-world/hello b/arm32v5/hello-world/hello new file mode 100755 index 0000000..19af2db Binary files /dev/null and b/arm32v5/hello-world/hello differ diff --git a/arm32v5/hola-mundo/Dockerfile b/arm32v5/hola-mundo/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/arm32v5/hola-mundo/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/arm32v5/hola-mundo/hello b/arm32v5/hola-mundo/hello new file mode 100755 index 0000000..cbb4346 Binary files /dev/null and b/arm32v5/hola-mundo/hello differ diff --git a/arm32v7/hello-seattle/Dockerfile b/arm32v7/hello-seattle/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/arm32v7/hello-seattle/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/arm32v7/hello-seattle/hello b/arm32v7/hello-seattle/hello new file mode 100755 index 0000000..7b4db81 Binary files /dev/null and b/arm32v7/hello-seattle/hello differ diff --git a/arm32v7/hello-world/Dockerfile b/arm32v7/hello-world/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/arm32v7/hello-world/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/arm32v7/hello-world/hello b/arm32v7/hello-world/hello new file mode 100755 index 0000000..b854ad9 Binary files /dev/null and b/arm32v7/hello-world/hello differ diff --git a/arm32v7/hola-mundo/Dockerfile b/arm32v7/hola-mundo/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/arm32v7/hola-mundo/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/arm32v7/hola-mundo/hello b/arm32v7/hola-mundo/hello new file mode 100755 index 0000000..ca71a04 Binary files /dev/null and b/arm32v7/hola-mundo/hello differ diff --git a/arm64v8/hello-seattle/Dockerfile b/arm64v8/hello-seattle/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/arm64v8/hello-seattle/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/arm64v8/hello-seattle/hello b/arm64v8/hello-seattle/hello new file mode 100755 index 0000000..7a4967a Binary files /dev/null and b/arm64v8/hello-seattle/hello differ diff --git a/arm64v8/hello-world/Dockerfile b/arm64v8/hello-world/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/arm64v8/hello-world/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/arm64v8/hello-world/hello b/arm64v8/hello-world/hello new file mode 100755 index 0000000..d6b9439 Binary files /dev/null and b/arm64v8/hello-world/hello differ diff --git a/arm64v8/hola-mundo/Dockerfile b/arm64v8/hola-mundo/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/arm64v8/hola-mundo/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/arm64v8/hola-mundo/hello b/arm64v8/hola-mundo/hello new file mode 100755 index 0000000..99063ab Binary files /dev/null and b/arm64v8/hola-mundo/hello differ diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index feea22a..517fb69 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -28,31 +28,56 @@ dirCommit() { ) } +generateCommit="$(fileCommit "$self")" cat <<-EOH -# this file is generated via https://github.com/docker-library/hello-world/blob/$(fileCommit "$self")/$self +# this file is generated via https://github.com/docker-library/hello-world/blob/$generateCommit/$self Maintainers: Tianon Gravi (@tianon), Joseph Ferguson (@yosifkit) GitRepo: https://github.com/docker-library/hello-world.git +GitCommit: $generateCommit EOH -commit="$(dirCommit "$image")" +# prints "$2$1$3$1...$N" +join() { + local sep="$1"; shift + local out; printf -v out "${sep//%/%%}%s" "$@" + echo "${out#$sep}" +} + +arches=( *"/$image/hello" ) +arches=( "${arches[@]%"/$image/hello"}" ) echo cat <<-EOE Tags: latest - GitCommit: $commit - Directory: $image + Architectures: $(join ', ' "${arches[@]}") EOE +for arch in "${arches[@]}"; do + commit="$(dirCommit "$arch/$image")" + cat <<-EOE + $arch-GitCommit: $commit + $arch-Directory: $arch/$image + EOE +done -if [ -d "$image/nanoserver" ]; then - commit="$(dirCommit "$image/nanoserver")" +winArches=( *"/$image/nanoserver/hello.txt" ) +winArches=( "${winArches[@]%"/$image/nanoserver/hello.txt"}" ) +if [ "${#winArches[@]}" -gt 0 ]; then echo cat <<-EOE Tags: nanoserver - GitCommit: $commit - Directory: $image/nanoserver + Architectures: $(join ', ' "${winArches[@]/#/windows-}") + EOE + for arch in "${winArches[@]}"; do + commit="$(dirCommit "$arch/$image/nanoserver")" + cat <<-EOE + windows-$arch-GitCommit: $commit + windows-$arch-Directory: $arch/$image/nanoserver + EOE + done + cat <<-EOE Constraints: nanoserver EOE fi diff --git a/hello-seattle/greeting.txt b/greetings/hello-seattle.txt similarity index 100% rename from hello-seattle/greeting.txt rename to greetings/hello-seattle.txt diff --git a/hello-world/greeting.txt b/greetings/hello-world.txt similarity index 100% rename from hello-world/greeting.txt rename to greetings/hello-world.txt diff --git a/hola-mundo/greeting.txt b/greetings/hola-mundo.txt similarity index 100% rename from hola-mundo/greeting.txt rename to greetings/hola-mundo.txt diff --git a/i386/hello-seattle/Dockerfile b/i386/hello-seattle/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/i386/hello-seattle/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/i386/hello-world/Dockerfile b/i386/hello-world/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/i386/hello-world/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/i386/hola-mundo/Dockerfile b/i386/hola-mundo/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/i386/hola-mundo/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/ppc64le/hello-seattle/Dockerfile b/ppc64le/hello-seattle/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/ppc64le/hello-seattle/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/ppc64le/hello-seattle/hello b/ppc64le/hello-seattle/hello new file mode 100755 index 0000000..aeae476 Binary files /dev/null and b/ppc64le/hello-seattle/hello differ diff --git a/ppc64le/hello-world/Dockerfile b/ppc64le/hello-world/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/ppc64le/hello-world/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/ppc64le/hello-world/hello b/ppc64le/hello-world/hello new file mode 100755 index 0000000..27a009b Binary files /dev/null and b/ppc64le/hello-world/hello differ diff --git a/ppc64le/hola-mundo/Dockerfile b/ppc64le/hola-mundo/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/ppc64le/hola-mundo/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/ppc64le/hola-mundo/hello b/ppc64le/hola-mundo/hello new file mode 100755 index 0000000..cff75ba Binary files /dev/null and b/ppc64le/hola-mundo/hello differ diff --git a/s390x/hello-seattle/Dockerfile b/s390x/hello-seattle/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/s390x/hello-seattle/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/s390x/hello-seattle/hello b/s390x/hello-seattle/hello new file mode 100755 index 0000000..a112211 Binary files /dev/null and b/s390x/hello-seattle/hello differ diff --git a/s390x/hello-world/Dockerfile b/s390x/hello-world/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/s390x/hello-world/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/s390x/hello-world/hello b/s390x/hello-world/hello new file mode 100755 index 0000000..ecc42bc Binary files /dev/null and b/s390x/hello-world/hello differ diff --git a/s390x/hola-mundo/Dockerfile b/s390x/hola-mundo/Dockerfile new file mode 100644 index 0000000..d4ff707 --- /dev/null +++ b/s390x/hola-mundo/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY hello / +CMD ["/hello"] diff --git a/s390x/hola-mundo/hello b/s390x/hola-mundo/hello new file mode 100755 index 0000000..106a077 Binary files /dev/null and b/s390x/hola-mundo/hello differ diff --git a/update.sh b/update.sh index 2acb8eb..9bf5cbf 100755 --- a/update.sh +++ b/update.sh @@ -10,10 +10,11 @@ docker build -f Dockerfile.build -t hello-world:build . rm -rf */hello */nanoserver/hello.txt docker run --rm hello-world:build sh -c 'find \( -name hello -or -name hello.txt \) -print0 | xargs -0 tar --create' | tar --extract --verbose -for h in */hello; do +for h in amd64/*/hello; do d="$(dirname "$h")" + b="$(basename "$d")" "$h" > /dev/null - docker build -t hello-world:"test-$d" "$d" - docker run --rm hello-world:"test-$d" + docker build -t hello-world:"test-$b" "$d" + docker run --rm hello-world:"test-$b" done -ls -l */nanoserver/hello.txt || : +ls -lh */*/{hello,nanoserver/hello.txt} || :