1#===- llvm/utils/docker/debian8/build/Dockerfile -------------------------===//
2#
3# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4# See https://llvm.org/LICENSE.txt for license information.
5# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6#
7#===----------------------------------------------------------------------===//
8# Stage 1. Check out LLVM source code and run the build.
9FROM launcher.gcr.io/google/debian8:latest as builder
10LABEL maintainer "LLVM Developers"
11# Install build dependencies of llvm.
12# First, Update the apt's source list and include the sources of the packages.
13RUN grep deb /etc/apt/sources.list | \
14    sed 's/^deb/deb-src /g' >> /etc/apt/sources.list
15# Install compiler, python and subversion.
16RUN apt-get update && \
17    apt-get install -y --no-install-recommends ca-certificates gnupg \
18           build-essential python wget subversion unzip && \
19    rm -rf /var/lib/apt/lists/*
20# Install a newer ninja release. It seems the older version in the debian repos
21# randomly crashes when compiling llvm.
22RUN wget "https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip" && \
23    echo "d2fea9ff33b3ef353161ed906f260d565ca55b8ca0568fa07b1d2cab90a84a07 ninja-linux.zip" \
24        | sha256sum -c  && \
25    unzip ninja-linux.zip -d /usr/local/bin && \
26    rm ninja-linux.zip
27# Import public key required for verifying signature of cmake download.
28RUN gpg --keyserver hkp://pgp.mit.edu --recv 0x2D2CEF1034921684
29# Download, verify and install cmake version that can compile clang into /usr/local.
30# (Version in debian8 repos is is too old)
31RUN mkdir /tmp/cmake-install && cd /tmp/cmake-install && \
32    wget "https://cmake.org/files/v3.7/cmake-3.7.2-SHA-256.txt.asc" && \
33    wget "https://cmake.org/files/v3.7/cmake-3.7.2-SHA-256.txt" && \
34    gpg --verify cmake-3.7.2-SHA-256.txt.asc cmake-3.7.2-SHA-256.txt && \
35    wget "https://cmake.org/files/v3.7/cmake-3.7.2-Linux-x86_64.tar.gz" && \
36    ( grep "cmake-3.7.2-Linux-x86_64.tar.gz" cmake-3.7.2-SHA-256.txt | \
37      sha256sum -c - ) && \
38    tar xzf cmake-3.7.2-Linux-x86_64.tar.gz -C /usr/local --strip-components=1 && \
39    cd / && rm -rf /tmp/cmake-install
40
41ADD checksums /tmp/checksums
42ADD scripts /tmp/scripts
43
44# Checkout the source code.
45ARG checkout_args
46RUN /tmp/scripts/checkout.sh ${checkout_args}
47# Run the build. Results of the build will be available at /tmp/clang-install/.
48ARG buildscript_args
49RUN /tmp/scripts/build_install_llvm.sh --to /tmp/clang-install ${buildscript_args}
50
51
52# Stage 2. Produce a minimal release image with build results.
53FROM launcher.gcr.io/google/debian8:latest
54LABEL maintainer "LLVM Developers"
55# Install packages for minimal useful image.
56RUN apt-get update && \
57    apt-get install -y --no-install-recommends libstdc++-4.9-dev binutils && \
58    rm -rf /var/lib/apt/lists/*
59# Copy build results of stage 1 to /usr/local.
60COPY --from=builder /tmp/clang-install/ /usr/local/
61