From e9975fabab8eb24215d5a9ae81ca6c45ebfea440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 1 Apr 2018 22:30:01 +0300 Subject: [PATCH] Squash all build steps in the dockerfile, producing a much smaller image Keep the old dockerfile with a different file name, for easier testing/debugging (where later steps can be tweaked without rebuilding everything). --- Dockerfile | 55 +++++-------------------------------- Dockerfile.dev | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 48 deletions(-) create mode 100644 Dockerfile.dev diff --git a/Dockerfile b/Dockerfile index 336b878..ca6f788 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,60 +15,19 @@ WORKDIR /build ARG CORES=4 ENV TOOLCHAIN_PREFIX=/opt/llvm-mingw - -# Build LLVM -COPY build-llvm.sh . -RUN ./build-llvm.sh $TOOLCHAIN_PREFIX - ENV TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64" -# Install the usual $TUPLE-clang binaries +# Build everything and clean up, in one step +COPY *.sh ./ COPY wrappers/*.sh ./wrappers/ -COPY install-wrappers.sh . -RUN ./install-wrappers.sh $TOOLCHAIN_PREFIX - -# Cheating: Pull windres from the normal binutils package. -# llvm-rc isn't fully usable as a replacement for windres yet. -RUN apt-get update -qq && \ +RUN ./build-all.sh $TOOLCHAIN_PREFIX && \ + ./strip-llvm.sh $TOOLCHAIN_PREFIX && \ + apt-get update -qq && \ apt-get install -qqy binutils-mingw-w64-x86-64 && \ cp /usr/bin/x86_64-w64-mingw32-windres $TOOLCHAIN_PREFIX/bin/x86_64-w64-mingw32-windresreal && \ apt-get remove -qqy binutils-mingw-w64-x86-64 && \ apt-get clean -y && \ - rm -rf /var/lib/apt/lists/* + rm -rf /var/lib/apt/lists/* && \ + rm -rf /build -# Build MinGW-w64 -COPY build-mingw-w64.sh . -RUN ./build-mingw-w64.sh $TOOLCHAIN_PREFIX - -# Build compiler-rt -COPY build-compiler-rt.sh . -RUN ./build-compiler-rt.sh $TOOLCHAIN_PREFIX - -# Build C test applications ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH - -COPY test/*.c ./test/ -RUN cd test && \ - for arch in $TOOLCHAIN_ARCHS; do \ - for test in hello hello-tls crt-test; do \ - $arch-w64-mingw32-clang $test.c -o $test-$arch.exe || exit 1; \ - done; \ - done - -# Build libunwind/libcxxabi/libcxx -COPY build-libcxx.sh merge-archives.sh ./ -RUN ./build-libcxx.sh $TOOLCHAIN_PREFIX - -# Build C++ test applications -COPY test/*.cpp ./test/ -RUN cd test && \ - for arch in $TOOLCHAIN_ARCHS; do \ - for test in hello-cpp hello-exception; do \ - $arch-w64-mingw32-clang++ $test.cpp -o $test-$arch.exe || exit 1; \ - done; \ - done - -# Strip the final toolchain. (This doesn't reduce the total docker image -# size as long as it is in a separate RUN layer though.) -COPY strip-llvm.sh . -RUN ./strip-llvm.sh $TOOLCHAIN_PREFIX diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..336b878 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,74 @@ +FROM ubuntu:16.04 + +RUN apt-get update -qq && apt-get install -qqy \ + git wget bzip2 file unzip libtool pkg-config cmake build-essential \ + automake yasm gettext autopoint vim python git-svn ninja-build && \ + apt-get clean -y && \ + rm -rf /var/lib/apt/lists/* + + +RUN git config --global user.name "LLVM MinGW" && \ + git config --global user.email root@localhost + +WORKDIR /build + +ARG CORES=4 + +ENV TOOLCHAIN_PREFIX=/opt/llvm-mingw + +# Build LLVM +COPY build-llvm.sh . +RUN ./build-llvm.sh $TOOLCHAIN_PREFIX + +ENV TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64" + +# Install the usual $TUPLE-clang binaries +COPY wrappers/*.sh ./wrappers/ +COPY install-wrappers.sh . +RUN ./install-wrappers.sh $TOOLCHAIN_PREFIX + +# Cheating: Pull windres from the normal binutils package. +# llvm-rc isn't fully usable as a replacement for windres yet. +RUN apt-get update -qq && \ + apt-get install -qqy binutils-mingw-w64-x86-64 && \ + cp /usr/bin/x86_64-w64-mingw32-windres $TOOLCHAIN_PREFIX/bin/x86_64-w64-mingw32-windresreal && \ + apt-get remove -qqy binutils-mingw-w64-x86-64 && \ + apt-get clean -y && \ + rm -rf /var/lib/apt/lists/* + +# Build MinGW-w64 +COPY build-mingw-w64.sh . +RUN ./build-mingw-w64.sh $TOOLCHAIN_PREFIX + +# Build compiler-rt +COPY build-compiler-rt.sh . +RUN ./build-compiler-rt.sh $TOOLCHAIN_PREFIX + +# Build C test applications +ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH + +COPY test/*.c ./test/ +RUN cd test && \ + for arch in $TOOLCHAIN_ARCHS; do \ + for test in hello hello-tls crt-test; do \ + $arch-w64-mingw32-clang $test.c -o $test-$arch.exe || exit 1; \ + done; \ + done + +# Build libunwind/libcxxabi/libcxx +COPY build-libcxx.sh merge-archives.sh ./ +RUN ./build-libcxx.sh $TOOLCHAIN_PREFIX + +# Build C++ test applications +COPY test/*.cpp ./test/ +RUN cd test && \ + for arch in $TOOLCHAIN_ARCHS; do \ + for test in hello-cpp hello-exception; do \ + $arch-w64-mingw32-clang++ $test.cpp -o $test-$arch.exe || exit 1; \ + done; \ + done + +# Strip the final toolchain. (This doesn't reduce the total docker image +# size as long as it is in a separate RUN layer though.) +COPY strip-llvm.sh . +RUN ./strip-llvm.sh $TOOLCHAIN_PREFIX