From 703053871c22fd3de2cb46c79fc599ed7e03fc7a Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Fri, 17 Oct 2014 13:42:56 +0200 Subject: [PATCH] Use base image, add Makefile, compress RUN statements to save on disk space Signed-off-by: Steeve Morin --- Makefile | 15 +++++++++++++++ android-arm/Dockerfile | 8 ++++---- base/Dockerfile | 15 +++++++++++++++ darwin-x64/Dockerfile | 26 +++++++++++--------------- linux-arm/Dockerfile | 11 +---------- linux-arm/Dockerfile.armv7 | 13 ++----------- linux-x64/Dockerfile | 12 ++++++++++++ linux-x86/Dockerfile | 27 +++++++++++++++++++++++++++ linux-x86/i686-linux-gnu.sh | 2 ++ windows-x64/Dockerfile | 11 ++--------- windows-x86/Dockerfile | 11 ++--------- 11 files changed, 93 insertions(+), 58 deletions(-) create mode 100644 Makefile create mode 100644 base/Dockerfile create mode 100644 linux-x64/Dockerfile create mode 100644 linux-x86/Dockerfile create mode 100644 linux-x86/i686-linux-gnu.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b90339c --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +PLATFORMS = base \ + android-arm \ + darwin-x64 \ + linux-x86 \ + linux-x64 \ + linux-arm \ + windows-x86 \ + windows-x64 +DOCKER = docker +IMAGE = steeve/cross-compiler + +all: + for i in $(PLATFORMS); do \ + $(DOCKER) build -t $(IMAGE):$$i $$i ; \ + done diff --git a/android-arm/Dockerfile b/android-arm/Dockerfile index de1ad3b..bf304b1 100644 --- a/android-arm/Dockerfile +++ b/android-arm/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:jessie +FROM steeve/cross-compiler:base MAINTAINER Steeve Morin "steeve.morin@gmail.com" RUN apt-get update && apt-get -y --force-yes install \ @@ -10,14 +10,14 @@ RUN apt-get update && apt-get -y --force-yes install \ tar xz-utils bzip2 gzip sed ENV CROSS_TRIPLE arm-linux-androideabi -ENV CROSS_ROOT /gcc-${CROSS_TRIPLE} +ENV CROSS_ROOT /usr/${CROSS_TRIPLE} ENV PATH ${PATH}:${CROSS_ROOT}/bin ENV LD_LIBRARY_PATH ${CROSS_ROOT}/lib:${LD_LIBRARY_PATH} RUN mkdir -p /build && \ cd /build && \ - curl -L http://dl.google.com/android/ndk/android-ndk32-r10-linux-x86_64.tar.bz2 | tar xvj && \ - cd /build/android-ndk-r10 && \ + curl -L http://dl.google.com/android/ndk/android-ndk32-r10b-linux-x86_64.tar.bz2 | tar xvj && \ + cd /build/android-ndk-r10b && \ /bin/bash ./build/tools/make-standalone-toolchain.sh --platform=android-14 --install-dir=${CROSS_ROOT} && \ cd / && \ rm -rf /build diff --git a/base/Dockerfile b/base/Dockerfile new file mode 100644 index 0000000..b08a191 --- /dev/null +++ b/base/Dockerfile @@ -0,0 +1,15 @@ +FROM debian:jessie +MAINTAINER Steeve Morin "steeve.morin@gmail.com" + +RUN apt-get update && apt-get -y install \ + bash \ + curl \ + pkg-config \ + build-essential \ + file \ + rsync \ + tar \ + xz-utils \ + bzip2 \ + gzip \ + sed diff --git a/darwin-x64/Dockerfile b/darwin-x64/Dockerfile index dedfd1e..f412e4e 100644 --- a/darwin-x64/Dockerfile +++ b/darwin-x64/Dockerfile @@ -1,26 +1,22 @@ -FROM debian:jessie +FROM steeve/cross-compiler:base MAINTAINER Steeve Morin "steeve.morin@gmail.com" -RUN apt-get update && apt-get -y --force-yes install \ - bash \ - curl \ - pkg-config \ - build-essential \ - clang-3.5 llvm-3.5-dev automake autogen \ - libtool libxml2-dev uuid-dev libssl-dev bash patch make \ - tar xz-utils bzip2 gzip sed cpio - ENV CROSS_TRIPLE x86_64-apple-darwin13 -ENV CROSS_ROOT /clang-${CROSS_TRIPLE} -ENV MAC_SDK_VERSION 10.9 +ENV CROSS_ROOT /usr/${CROSS_TRIPLE} ENV PATH ${PATH}:${CROSS_ROOT}/bin -ENV LD_LIBRARY_PATH /usr/lib/llvm-3.5/lib:${CROSS_ROOT}/lib:${LD_LIBRARY_PATH} +ENV LD_LIBRARY_PATH /usr/lib/llvm-3.5/lib:${CROSS_ROOT}/lib +ENV MAC_SDK_VERSION 10.9 RUN curl -L https://github.com/tpoechtrager/osxcross/archive/master.tar.gz | tar xvz COPY MacOSX${MAC_SDK_VERSION}.sdk.tar.bz2 /osxcross-master/tarballs/ # Build the toolchain -RUN cd /osxcross-master && echo | SDK_VERSION=${MAC_SDK_VERSION} OSX_VERSION_MIN=10.6 ./build.sh -RUN mv /osxcross-master/target ${CROSS_ROOT} && \ +WORKDIR /osxcross-master + +RUN ./tools/get_dependencies.sh && \ + echo | SDK_VERSION=${MAC_SDK_VERSION} OSX_VERSION_MIN=10.6 ./build.sh && \ + mv /osxcross-master/target ${CROSS_ROOT} && \ mkdir -p ${CROSS_ROOT}/lib && \ rm -rf /osxcross-master + +WORKDIR / diff --git a/linux-arm/Dockerfile b/linux-arm/Dockerfile index 0e5f410..4fff54b 100644 --- a/linux-arm/Dockerfile +++ b/linux-arm/Dockerfile @@ -1,15 +1,6 @@ -FROM debian:jessie +FROM steeve/cross-compiler:base MAINTAINER Steeve Morin "steeve.morin@gmail.com" -RUN apt-get update && apt-get -y --force-yes install \ - bash \ - curl \ - pkg-config \ - build-essential \ - file \ - rsync \ - tar xz-utils bzip2 gzip sed - ENV CROSS_TRIPLE arm-linux-gnueabihf ENV CROSS_ROOT /usr/${CROSS_TRIPLE} ENV PATH ${PATH}:${CROSS_ROOT}/bin diff --git a/linux-arm/Dockerfile.armv7 b/linux-arm/Dockerfile.armv7 index 15ff39d..ccb5bab 100644 --- a/linux-arm/Dockerfile.armv7 +++ b/linux-arm/Dockerfile.armv7 @@ -1,21 +1,12 @@ -FROM debian:jessie +FROM steeve/cross-compiler:base MAINTAINER Steeve Morin "steeve.morin@gmail.com" -RUN apt-get update && apt-get -y --force-yes install \ - bash \ - curl \ - pkg-config \ - build-essential \ - file \ - tar xz-utils bzip2 gzip sed - - # Add the cross compiler sources RUN echo "deb http://toolchains.secretsauce.net unstable main" >> /etc/apt/sources.list && \ dpkg --add-architecture armhf && \ curl -L http://toolchains.secretsauce.net/key.gpg | apt-key add - -RUN apt-get update && apt-get -y --force-yes install \ +RUN apt-get update && apt-get -y install \ gcc-4.9-arm-linux-gnueabihf \ g++-4.9-arm-linux-gnueabihf diff --git a/linux-x64/Dockerfile b/linux-x64/Dockerfile new file mode 100644 index 0000000..885e0bc --- /dev/null +++ b/linux-x64/Dockerfile @@ -0,0 +1,12 @@ +FROM steeve/cross-compiler:base +MAINTAINER Steeve Morin "steeve.morin@gmail.com" + +ENV CROSS_TRIPLE x86_64-linux-gnu +ENV CROSS_ROOT /usr/${CROSS_TRIPLE} +ENV PATH ${PATH}:${CROSS_ROOT}/bin +ENV LD_LIBRARY_PATH ${CROSS_ROOT}/lib:${LD_LIBRARY_PATH} + +RUN mkdir -p ${CROSS_ROOT} && \ + cd /usr/bin && \ + ln -s ${CROSS_TRIPLE}-gcc ${CROSS_TRIPLE}-cc && \ + ln -s ${CROSS_TRIPLE}-g++ ${CROSS_TRIPLE}-c++ diff --git a/linux-x86/Dockerfile b/linux-x86/Dockerfile new file mode 100644 index 0000000..5901b8b --- /dev/null +++ b/linux-x86/Dockerfile @@ -0,0 +1,27 @@ +FROM steeve/cross-compiler:base +MAINTAINER Steeve Morin "steeve.morin@gmail.com" + +RUN apt-get update && apt-get -y install \ + gcc-multilib \ + g++-multilib + +ENV CROSS_TRIPLE i686-linux-gnu +ENV CROSS_ROOT /usr/i686-linux-gnu +ENV PATH ${PATH}:${CROSS_ROOT}/bin +ENV LD_LIBRARY_PATH ${CROSS_ROOT}/lib:${LD_LIBRARY_PATH} + +COPY ${CROSS_TRIPLE}.sh /usr/bin/${CROSS_TRIPLE}.sh +RUN mkdir -p ${CROSS_ROOT} && \ + cd /usr/bin && \ + chmod +x ${CROSS_TRIPLE}.sh && \ + ln -s x86_64-linux-gnu-gcc x86_64-linux-gnu-cc && \ + ln -s x86_64-linux-gnu-g++ x86_64-linux-gnu-c++ && \ + ln -s ${CROSS_TRIPLE}.sh ${CROSS_TRIPLE}-gcc-4.9 && \ + ln -s ${CROSS_TRIPLE}.sh ${CROSS_TRIPLE}-gcc && \ + ln -s ${CROSS_TRIPLE}.sh ${CROSS_TRIPLE}-cc && \ + ln -s ${CROSS_TRIPLE}.sh ${CROSS_TRIPLE}-g++-4.9 && \ + ln -s ${CROSS_TRIPLE}.sh ${CROSS_TRIPLE}-g++ && \ + ln -s ${CROSS_TRIPLE}.sh ${CROSS_TRIPLE}-c++ && \ + for i in x86_64-linux-gnu-*; do \ + ln -s $i `echo $i | sed "s/x86_64-linux-gnu-/${CROSS_TRIPLE}-/"`; \ + done diff --git a/linux-x86/i686-linux-gnu.sh b/linux-x86/i686-linux-gnu.sh new file mode 100644 index 0000000..17a4a40 --- /dev/null +++ b/linux-x86/i686-linux-gnu.sh @@ -0,0 +1,2 @@ +#!/bin/bash +exec ${0/${CROSS_TRIPLE}-/x86_64-linux-gnu-} -m32 "$@" diff --git a/windows-x64/Dockerfile b/windows-x64/Dockerfile index b38458e..3bd1a1e 100644 --- a/windows-x64/Dockerfile +++ b/windows-x64/Dockerfile @@ -1,14 +1,7 @@ -FROM debian:jessie +FROM steeve/cross-compiler:base MAINTAINER Steeve Morin "steeve.morin@gmail.com" -RUN apt-get update && apt-get -y --force-yes install \ - bash \ - curl \ - pkg-config \ - build-essential \ - file \ - mingw-w64 \ - tar xz-utils bzip2 gzip sed +RUN apt-get update && apt-get -y install mingw-w64 ENV CROSS_TRIPLE x86_64-w64-mingw32 ENV CROSS_ROOT /usr/${CROSS_TRIPLE} diff --git a/windows-x86/Dockerfile b/windows-x86/Dockerfile index 4a75874..e7c5410 100644 --- a/windows-x86/Dockerfile +++ b/windows-x86/Dockerfile @@ -1,14 +1,7 @@ -FROM debian:jessie +FROM steeve/cross-compiler:base MAINTAINER Steeve Morin "steeve.morin@gmail.com" -RUN apt-get update && apt-get -y --force-yes install \ - bash \ - curl \ - pkg-config \ - build-essential \ - file \ - mingw-w64 \ - tar xz-utils bzip2 gzip sed +RUN apt-get update && apt-get -y install mingw-w64 ENV CROSS_TRIPLE i686-w64-mingw32 ENV CROSS_ROOT /usr/${CROSS_TRIPLE}