From 191d773e016474b2136c57fb42ab14e54b497008 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Fri, 25 Nov 2016 15:51:38 -0500 Subject: [PATCH 1/4] makefile: Ensure imagefiles are available in build image context --- .gitignore | 4 ++-- Makefile | 14 ++++++++++++-- linux-x86/Dockerfile | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c5ab058..5d65b6d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ bin dockcross */test/ Dockerfile -*/install-openssl.sh -!imagefiles/install-openssl.sh +*/imagefiles/* +!imagefiles/* diff --git a/Makefile b/Makefile index 42582a3..fd38ee2 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,9 @@ test: base.test $(addsuffix .test,$(IMAGES)) # # browser-asmjs # -browser-asmjs: base +browser-asmjs: base browser-asmjs/Dockerfile.in common.docker + sed '/common.docker/ r common.docker' $@/Dockerfile.in > $@/Dockerfile + mkdir -p $@/imagefiles && cp -r imagefiles $@/ cp -r test browser-asmjs/ $(DOCKER) build -t $(ORG)/browser-asmjs \ --build-arg IMAGE=$(ORG)/browser-asmjs \ @@ -48,10 +50,13 @@ browser-asmjs: base --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ browser-asmjs rm -rf browser-asmjs/test + rm -rf $@/imagefiles browser-asmjs.test: browser-asmjs + cp -r test browser-asmjs/ $(DOCKER) run --rm dockcross/browser-asmjs > $(BIN)/dockcross-browser-asmjs && chmod +x $(BIN)/dockcross-browser-asmjs $(BIN)/dockcross-browser-asmjs python test/run.py --exe-suffix ".js" + rm -rf browser-asmjs/test # # manylinux-x64 @@ -60,12 +65,14 @@ manylinux-x64/Dockerfile: manylinux-x64/Dockerfile.in common.docker common.manyl sed -e '/common.docker/ r common.docker' -e '/common.manylinux/ r common.manylinux' manylinux-x64/Dockerfile.in > manylinux-x64/Dockerfile manylinux-x64: manylinux-x64/Dockerfile + mkdir -p $@/imagefiles && cp -r imagefiles $@/ $(DOCKER) build -t $(ORG)/manylinux-x64 \ --build-arg IMAGE=$(ORG)/manylinux-x64 \ --build-arg VCS_REF=`git rev-parse --short HEAD` \ --build-arg VCS_URL=`git config --get remote.origin.url` \ --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ -f manylinux-x64/Dockerfile . + rm -rf $@/imagefiles manylinux-x64.test: manylinux-x64 $(DOCKER) run --rm dockcross/manylinux-x64 > $(BIN)/dockcross-manylinux-x64 && chmod +x $(BIN)/dockcross-manylinux-x64 @@ -78,12 +85,14 @@ manylinux-x86/Dockerfile: manylinux-x86/Dockerfile.in common.docker common.manyl sed -e '/common.docker/ r common.docker' -e '/common.manylinux/ r common.manylinux' manylinux-x86/Dockerfile.in > manylinux-x86/Dockerfile manylinux-x86: manylinux-x86/Dockerfile + mkdir -p $@/imagefiles && cp -r imagefiles $@/ $(DOCKER) build -t $(ORG)/manylinux-x86 \ --build-arg IMAGE=$(ORG)/manylinux-x86 \ --build-arg VCS_REF=`git rev-parse --short HEAD` \ --build-arg VCS_URL=`git config --get remote.origin.url` \ --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ -f manylinux-x86/Dockerfile . + rm -rf $@/imagefiles manylinux-x86.test: manylinux-x86 $(DOCKER) run --rm dockcross/manylinux-x86 > $(BIN)/dockcross-manylinux-x86 && chmod +x $(BIN)/dockcross-manylinux-x86 @@ -116,13 +125,14 @@ $(VERBOSE).SILENT: display_images # build implicit rule # $(STANDARD_IMAGES): base - cp imagefiles/install-openssl.sh $@/ + mkdir -p $@/imagefiles && cp -r imagefiles $@/ $(DOCKER) build -t $(ORG)/$@ \ --build-arg IMAGE=$(ORG)/$@ \ --build-arg VCS_REF=`git rev-parse --short HEAD` \ --build-arg VCS_URL=`git config --get remote.origin.url` \ --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ $@ + rm -rf $@/imagefiles # # testing implicit rule diff --git a/linux-x86/Dockerfile b/linux-x86/Dockerfile index b3754c8..62fa062 100644 --- a/linux-x86/Dockerfile +++ b/linux-x86/Dockerfile @@ -34,7 +34,7 @@ ENV AS=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-as \ CXX=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-g++ -COPY install-openssl.sh /dockcross/ +COPY imagefiles/install-openssl.sh /dockcross/ RUN \ /dockcross/install-openssl.sh -32 && \ rm /dockcross/install-openssl.sh From 8077008a10b6ae63ab948bc2931a7acce594b931 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Fri, 25 Nov 2016 15:20:17 -0500 Subject: [PATCH 2/4] common: Introduce "install-ninja.sh" --- common.docker | 13 ++++++----- imagefiles/install-ninja.sh | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 7 deletions(-) create mode 100755 imagefiles/install-ninja.sh diff --git a/common.docker b/common.docker index 9e5c36e..19919e3 100644 --- a/common.docker +++ b/common.docker @@ -17,16 +17,15 @@ RUN \ fi; \ rm /dockcross/install-openssl.sh /dockcross/install-cmake.sh -RUN git clone "https://github.com/ninja-build/ninja.git" && \ - cd ninja && \ - git checkout v1.7.1 && \ - ([ -e /opt/python/cp35-cp35m/bin/python ] && /opt/python/cp35-cp35m/bin/python ./configure.py --bootstrap) || python ./configure.py --bootstrap && \ - ./ninja && \ - cp ./ninja /usr/bin/ && \ - cd .. && rm -rf ninja COPY imagefiles/cmake.sh /usr/local/bin/cmake COPY imagefiles/ccmake.sh /usr/local/bin/ccmake +COPY imagefiles/install-ninja.sh /dockcross/ +RUN \ + /dockcross/install-ninja.sh \ + -python $([ -e /opt/python/cp35-cp35m/bin/python ] && echo "/opt/python/cp35-cp35m/bin/python" || echo "python") && \ + rm /dockcross/install-ninja.sh + RUN echo "root:root" | chpasswd WORKDIR /work ENTRYPOINT ["/dockcross/entrypoint.sh"] diff --git a/imagefiles/install-ninja.sh b/imagefiles/install-ninja.sh new file mode 100755 index 0000000..41d2d7a --- /dev/null +++ b/imagefiles/install-ninja.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# +# Configure, build and install ninja +# +# Usage: +# +# install-ninja.sh [-python /path/to/bin/python] + +set -e +set -o pipefail + +PYTHON=python +while [ $# -gt 0 ]; do + case "$1" in + -python) + PYTHON=$2 + shift + ;; + *) + echo "Usage: Usage: ${0##*/} [-python /path/to/bin/python]" + exit 1 + ;; + esac + shift +done + +# Download +REV=v1.7.1 +wget https://github.com/ninja-build/ninja/archive/$REV.tar.gz -O ninja.tar.gz +mkdir ninja +tar -xzvf ./ninja.tar.gz --strip-components=1 -C ./ninja + +# Configure, build and install +pushd ./ninja +echo "Configuring ninja using [$PYTHON]" +$PYTHON ./configure.py --bootstrap && ./ninja +cp ./ninja /usr/bin/ +popd + +# Clean +rm -rf ./ninja* + From 46cef1a33a9112512995e6c360761f12cc9ebe27 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Fri, 25 Nov 2016 15:21:53 -0500 Subject: [PATCH 3/4] common: Introduce "common.debian" This will facilitate the configuration of other images based on debian but *NOT* depending on the dockcross/base image. --- Dockerfile.in | 30 +----------------------------- Makefile | 4 ++-- common.debian | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 31 deletions(-) create mode 100644 common.debian diff --git a/Dockerfile.in b/Dockerfile.in index 47af952..e2c8d64 100644 --- a/Dockerfile.in +++ b/Dockerfile.in @@ -1,35 +1,7 @@ FROM debian:jessie MAINTAINER Matt McCormick "matt.mccormick@kitware.com" -RUN REPO=http://cdn-fastly.deb.debian.org && \ - echo "deb $REPO/debian jessie main\ndeb $REPO/debian jessie-updates main\ndeb $REPO/debian-security jessie/updates main" > /etc/apt/sources.list - -RUN apt-get update && apt-get -y install \ - automake \ - autogen \ - bash \ - build-essential \ - bzip2 \ - ca-certificates \ - curl \ - file \ - git \ - gzip \ - make \ - ncurses-dev \ - pkg-config \ - libtool \ - python \ - rsync \ - sed \ - bison \ - flex \ - tar \ - vim \ - wget \ - runit \ - xz-utils && \ - apt-get -y clean +#include "common.debian" #include "common.docker" diff --git a/Makefile b/Makefile index fd38ee2..7027f92 100644 --- a/Makefile +++ b/Makefile @@ -101,8 +101,8 @@ manylinux-x86.test: manylinux-x86 # # base # -Dockerfile: Dockerfile.in common.docker - sed '/common.docker/ r common.docker' Dockerfile.in > Dockerfile +Dockerfile: Dockerfile.in common.docker common.debian + sed -e '/common.docker/ r common.docker' -e '/common.debian/ r common.debian' Dockerfile.in > Dockerfile base: Dockerfile imagefiles/ $(DOCKER) build -t $(ORG)/base \ diff --git a/common.debian b/common.debian new file mode 100644 index 0000000..940dde4 --- /dev/null +++ b/common.debian @@ -0,0 +1,29 @@ +RUN REPO=http://cdn-fastly.deb.debian.org && \ + echo "deb $REPO/debian jessie main\ndeb $REPO/debian jessie-updates main\ndeb $REPO/debian-security jessie/updates main" > /etc/apt/sources.list + +RUN apt-get update && apt-get -y install \ + automake \ + autogen \ + bash \ + build-essential \ + bzip2 \ + ca-certificates \ + curl \ + file \ + git \ + gzip \ + make \ + ncurses-dev \ + pkg-config \ + libtool \ + python \ + rsync \ + sed \ + bison \ + flex \ + tar \ + vim \ + wget \ + runit \ + xz-utils && \ + apt-get -y clean From 09868d5289f25a227ee18b0b892bda1bb2dbf17f Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Fri, 25 Nov 2016 15:45:32 -0500 Subject: [PATCH 4/4] browser-asmjs: Update to depend on existing image from "trzeci/emscripten" This commit updates the "browser-asmjs" images to avoid systematic rebuild of emscripten sdk. Instead, it introduces dependency on the image maintained by @trzeci Note also: * emscripten sdk updated from 1.36.7 to 1.36.14 * symlinking of "/bin/bash" as "/bin/sh" is reverted. This ensures other images including file like "common.debian" and relying on standard "sh" behavior will work as expected. * workaround associated with CMakeForceCompiler has been removed from Dockerfile. Emscripten as been fixed. See https://github.com/kripken/emscripten/pull/4477 * we will revisit once official images are available. See https://github.com/kripken/emscripten/issues/4682 --- .gitignore | 1 + Makefile | 4 +-- browser-asmjs/Dockerfile | 61 ------------------------------------- browser-asmjs/Dockerfile.in | 45 +++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 63 deletions(-) delete mode 100644 browser-asmjs/Dockerfile create mode 100644 browser-asmjs/Dockerfile.in diff --git a/.gitignore b/.gitignore index 5d65b6d..70362ec 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ bin dockcross */test/ Dockerfile +browser-asmjs/Dockerfile */imagefiles/* !imagefiles/* diff --git a/Makefile b/Makefile index 7027f92..fd02c3d 100644 --- a/Makefile +++ b/Makefile @@ -39,8 +39,8 @@ test: base.test $(addsuffix .test,$(IMAGES)) # # browser-asmjs # -browser-asmjs: base browser-asmjs/Dockerfile.in common.docker - sed '/common.docker/ r common.docker' $@/Dockerfile.in > $@/Dockerfile +browser-asmjs: base browser-asmjs/Dockerfile.in common.docker common.debian + sed -e '/common.docker/ r common.docker' -e '/common.debian/ r common.debian' $@/Dockerfile.in > $@/Dockerfile mkdir -p $@/imagefiles && cp -r imagefiles $@/ cp -r test browser-asmjs/ $(DOCKER) build -t $(ORG)/browser-asmjs \ diff --git a/browser-asmjs/Dockerfile b/browser-asmjs/Dockerfile deleted file mode 100644 index 0c53d32..0000000 --- a/browser-asmjs/Dockerfile +++ /dev/null @@ -1,61 +0,0 @@ -FROM dockcross/base -MAINTAINER Matt McCormick "matt.mccormick@kitware.com" - -# The cross-compiling emulator -RUN curl -sL https://deb.nodesource.com/setup_4.x | bash - && \ - apt-get install -y --no-install-recommends \ - default-jre \ - nodejs \ - python2.7 - -ENV EMSCRIPTEN_VERSION 1.36.7 -RUN cd /usr && \ - curl -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | tar xz && \ - cd ./emsdk_portable && \ - ./emsdk update && \ - ./emsdk install -j$(nproc) --build=Release sdk-tag-${EMSCRIPTEN_VERSION}-32bit && \ - ./emsdk activate --build=Release sdk-tag-${EMSCRIPTEN_VERSION}-32bit && \ - ./emsdk install node-4.1.1-64bit && \ - ./emsdk activate node-4.1.1-64bit && \ - ./emsdk uninstall node-4.1.1-32bit && \ - find . -name "*.o" -exec rm {} \; && \ - find . -name "*.a" -exec rm {} \; && \ - find . -name "*.tmp" -exec rm {} \; - -ENV PATH /usr/emsdk_portable:/usr/emsdk_portable/clang/tag-e${EMSCRIPTEN_VERSION}/build_tag-e${EMSCRIPTEN_VERSION}_32/bin:/usr/emsdk_portable/emscripten/tag-${EMSCRIPTEN_VERSION}:${PATH} -ENV CC=/usr/emsdk_portable/emscripten/tag-${EMSCRIPTEN_VERSION}/emcc \ - CXX=/usr/emsdk_portable/emscripten/tag-${EMSCRIPTEN_VERSION}/em++ \ - AR=/usr/emsdk_portable/emscripten/tag-${EMSCRIPTEN_VERSION}/emar - -# Emscripten generates system libraries the firsts time it runs -ADD test/ /tmp/test/ -RUN cd /tmp && \ - /bin/echo -e "#include \nint main() { std::cout << \"first run\"; return 0; }" > /tmp/first_run.cxx && \ - $CXX /tmp/first_run.cxx -o a.out.js && \ - rm /tmp/first_run.* && \ - /bin/echo -e "#include \nint main() { printf(\"first run\"); return 0; }" > /tmp/first_run.c && \ - $CC /tmp/first_run.c -o a.out.js && \ - rm /tmp/first_run.* a.out.js && \ - cd /tmp/test && \ - python /tmp/test/run.py; python /tmp/test/run.py && \ - cd && rm -rf /tmp/test - -ENV DEFAULT_DOCKCROSS_IMAGE dockcross/browser-asmjs - -ENV CMAKE_TOOLCHAIN_FILE /usr/emsdk_portable/emscripten/tag-${EMSCRIPTEN_VERSION}/cmake/Modules/Platform/Emscripten.cmake -# CMakeForceCompiler was marked deprecated in CMake 3.6.0. It emits many -# warnings when using Emscripten. These changes can be removed in a future -# version of Emscripten when it is disabled or removed per: -# https://github.com/kripken/emscripten/pull/4477 -RUN sed -i -e '/CMakeForceCompiler/d' -e '/CMAKE_FORCE_C/d' $CMAKE_TOOLCHAIN_FILE - -# Build-time metadata as defined at http://label-schema.org -ARG BUILD_DATE -ARG IMAGE -ARG VCS_REF -ARG VCS_URL -LABEL org.label-schema.build-date=$BUILD_DATE \ - org.label-schema.name=$IMAGE \ - org.label-schema.vcs-ref=$VCS_REF \ - org.label-schema.vcs-url=$VCS_URL \ - org.label-schema.schema-version="1.0" diff --git a/browser-asmjs/Dockerfile.in b/browser-asmjs/Dockerfile.in new file mode 100644 index 0000000..924b730 --- /dev/null +++ b/browser-asmjs/Dockerfile.in @@ -0,0 +1,45 @@ +FROM trzeci/emscripten:sdk-tag-1.36.14-64bit +MAINTAINER Matt McCormick "matt.mccormick@kitware.com" + +# Revert back to "/bin/sh" as default shell +# See https://github.com/asRIA/emscripten-docker/blob/master/Dockerfile.in#L4 +RUN rm /bin/sh && ln -s /bin/dash /bin/sh + +#include "common.debian" + +#include "common.docker" + +ENV EMSCRIPTEN_VERSION 1.36.14 + +ENV PATH /emsdk_portable:/emsdk_portable/clang/tag-e${EMSCRIPTEN_VERSION}/build_tag-e${EMSCRIPTEN_VERSION}_64/bin:/emsdk_portable/emscripten/tag-${EMSCRIPTEN_VERSION}:${PATH} +ENV CC=/emsdk_portable/emscripten/tag-${EMSCRIPTEN_VERSION}/emcc \ + CXX=/emsdk_portable/emscripten/tag-${EMSCRIPTEN_VERSION}/em++ \ + AR=/emsdk_portable/emscripten/tag-${EMSCRIPTEN_VERSION}/emar + +# Emscripten generates system libraries the firsts time it runs +ADD test/ /tmp/test/ +RUN cd /tmp && \ + /bin/echo -e "#include \nint main() { std::cout << \"first run\"; return 0; }" > /tmp/first_run.cxx && \ + $CXX /tmp/first_run.cxx -o a.out.js && \ + rm /tmp/first_run.* && \ + /bin/echo -e "#include \nint main() { printf(\"first run\"); return 0; }" > /tmp/first_run.c && \ + $CC /tmp/first_run.c -o a.out.js && \ + rm /tmp/first_run.* a.out.js && \ + cd /tmp/test && \ + python /tmp/test/run.py; python /tmp/test/run.py && \ + cd && rm -rf /tmp/test + +ENV DEFAULT_DOCKCROSS_IMAGE dockcross/browser-asmjs + +ENV CMAKE_TOOLCHAIN_FILE /emsdk_portable/emscripten/tag-${EMSCRIPTEN_VERSION}/cmake/Modules/Platform/Emscripten.cmake + +# Build-time metadata as defined at http://label-schema.org +ARG BUILD_DATE +ARG IMAGE +ARG VCS_REF +ARG VCS_URL +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name=$IMAGE \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.schema-version="1.0"