Skip to content

Commit 9580f95

Browse files
XiaodongLoongbenshi001
authored andcommitted
[Dockerfile] Upgrade debian base image to version 10
Debian8 is too old to build LLVM project, the version of GCC, CMake and python are lower than the requirements: https://llvm.org/docs/GettingStarted.html#software Debian10 is the earliest release that has software packages that meet the above requirements. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D120826
1 parent 0fcff69 commit 9580f95

File tree

3 files changed

+23
-36
lines changed

3 files changed

+23
-36
lines changed

llvm/docs/Docker.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You can find a number of sources to build docker images with LLVM components in
99
images for their own use, or as a starting point for someone who wants to write
1010
their own Dockerfiles.
1111

12-
We currently provide Dockerfiles with ``debian8`` and ``nvidia-cuda`` base images.
12+
We currently provide Dockerfiles with ``debian10`` and ``nvidia-cuda`` base images.
1313
We also provide an ``example`` image, which contains placeholders that one would need
1414
to fill out in order to produce Dockerfiles for a new docker image.
1515

@@ -72,13 +72,13 @@ checkout from git and provide a list of CMake arguments to use during when
7272
building LLVM inside docker container.
7373

7474
Here's a very simple example of getting a docker image with clang binary,
75-
compiled by the system compiler in the debian8 image:
75+
compiled by the system compiler in the debian10 image:
7676

7777
.. code-block:: bash
7878
7979
./llvm/utils/docker/build_docker_image.sh \
80-
--source debian8 \
81-
--docker-repository clang-debian8 --docker-tag "staging" \
80+
--source debian10 \
81+
--docker-repository clang-debian10 --docker-tag "staging" \
8282
-p clang -i install-clang -i install-clang-resource-headers \
8383
-- \
8484
-DCMAKE_BUILD_TYPE=Release
@@ -93,22 +93,22 @@ this command will do that:
9393
# LLVM_TARGETS_TO_BUILD=Native is to reduce stage1 compile time.
9494
# Options, starting with BOOTSTRAP_* are passed to stage2 cmake invocation.
9595
./build_docker_image.sh \
96-
--source debian8 \
97-
--docker-repository clang-debian8 --docker-tag "staging" \
96+
--source debian10 \
97+
--docker-repository clang-debian10 --docker-tag "staging" \
9898
-p clang -i stage2-install-clang -i stage2-install-clang-resource-headers \
9999
-- \
100100
-DLLVM_TARGETS_TO_BUILD=Native -DCMAKE_BUILD_TYPE=Release \
101101
-DBOOTSTRAP_CMAKE_BUILD_TYPE=Release \
102102
-DCLANG_ENABLE_BOOTSTRAP=ON -DCLANG_BOOTSTRAP_TARGETS="install-clang;install-clang-resource-headers"
103103
104-
This will produce a new image ``clang-debian8:staging`` from the latest
104+
This will produce a new image ``clang-debian10:staging`` from the latest
105105
upstream revision.
106106
After the image is built you can run bash inside a container based on your image
107107
like this:
108108

109109
.. code-block:: bash
110110
111-
docker run -ti clang-debian8:staging bash
111+
docker run -ti clang-debian10:staging bash
112112
113113
Now you can run bash commands as you normally would:
114114

@@ -130,14 +130,14 @@ Now you can run bash commands as you normally would:
130130
131131
Which image should I choose?
132132
============================
133-
We currently provide two images: debian8-based and nvidia-cuda-based. They
133+
We currently provide two images: Debian10-based and nvidia-cuda-based. They
134134
differ in the base image that they use, i.e. they have a different set of
135135
preinstalled binaries. Debian8 is very minimal, nvidia-cuda is larger, but has
136136
preinstalled CUDA libraries and allows to access a GPU, installed on your
137137
machine.
138138

139139
If you need a minimal linux distribution with only clang and libstdc++ included,
140-
you should try debian8-based image.
140+
you should try Debian10-based image.
141141

142142
If you want to use CUDA libraries and have access to a GPU on your machine,
143143
you should choose nvidia-cuda-based image and use `nvidia-docker
@@ -150,20 +150,20 @@ If you have a different use-case, you could create your own image based on
150150
``example/`` folder.
151151

152152
Any docker image can be built and run using only the docker binary, i.e. you can
153-
run debian8 build on Fedora or any other Linux distribution. You don't need to
153+
run debian10 build on Fedora or any other Linux distribution. You don't need to
154154
install CMake, compilers or any other clang dependencies. It is all handled
155155
during the build process inside Docker's isolated environment.
156156

157157
Stable build
158158
============
159159
If you want a somewhat recent and somewhat stable build, use the
160160
``branches/google/stable`` branch, i.e. the following command will produce a
161-
debian8-based image using the latest ``google/stable`` sources for you:
161+
Debian10-based image using the latest ``google/stable`` sources for you:
162162

163163
.. code-block:: bash
164164
165165
./llvm/utils/docker/build_docker_image.sh \
166-
-s debian8 --d clang-debian8 -t "staging" \
166+
-s debian10 --d clang-debian10 -t "staging" \
167167
--branch branches/google/stable \
168168
-p clang -i install-clang -i install-clang-resource-headers \
169169
-- \

llvm/utils/docker/build_docker_image.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Available options:
2323
General:
2424
-h|--help show this help message
2525
Docker-specific:
26-
-s|--source image source dir (i.e. debian8, nvidia-cuda, etc)
26+
-s|--source image source dir (i.e. debian10, nvidia-cuda, etc)
2727
-d|--docker-repository docker repository for the image
2828
-t|--docker-tag docker tag for the image
2929
Checkout arguments:
@@ -54,18 +54,18 @@ Required options: --source and --docker-repository, at least one
5454
All options after '--' are passed to CMake invocation.
5555
5656
For example, running:
57-
$ build_docker_image.sh -s debian8 -d mydocker/debian8-clang -t latest \
57+
$ build_docker_image.sh -s debian10 -d mydocker/debian10-clang -t latest \
5858
-p clang -i install-clang -i install-clang-resource-headers
5959
will produce two docker images:
60-
mydocker/debian8-clang-build:latest - an intermediate image used to compile
60+
mydocker/debian10-clang-build:latest - an intermediate image used to compile
6161
clang.
62-
mydocker/clang-debian8:latest - a small image with preinstalled clang.
62+
mydocker/clang-debian10:latest - a small image with preinstalled clang.
6363
Please note that this example produces a not very useful installation, since it
6464
doesn't override CMake defaults, which produces a Debug and non-boostrapped
6565
version of clang.
6666
6767
To get a 2-stage clang build, you could use this command:
68-
$ ./build_docker_image.sh -s debian8 -d mydocker/clang-debian8 -t "latest" \
68+
$ ./build_docker_image.sh -s debian10 -d mydocker/clang-debian10 -t "latest" \
6969
-p clang -i stage2-install-clang -i stage2-install-clang-resource-headers \
7070
-- \
7171
-DLLVM_TARGETS_TO_BUILD=Native -DCMAKE_BUILD_TYPE=Release \
Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#===- llvm/utils/docker/debian8/build/Dockerfile -------------------------===//
1+
#===- llvm/utils/docker/debian10/build/Dockerfile -------------------------===//
22
#
33
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
# See https://llvm.org/LICENSE.txt for license information.
55
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
#
77
#===----------------------------------------------------------------------===//
88
# Stage 1. Check out LLVM source code and run the build.
9-
FROM launcher.gcr.io/google/debian8:latest as builder
9+
FROM launcher.gcr.io/google/debian10:latest as builder
1010
LABEL maintainer "LLVM Developers"
1111
# Install build dependencies of llvm.
1212
# First, Update the apt's source list and include the sources of the packages.
@@ -15,7 +15,7 @@ RUN grep deb /etc/apt/sources.list | \
1515
# Install compiler, python and subversion.
1616
RUN apt-get update && \
1717
apt-get install -y --no-install-recommends ca-certificates gnupg \
18-
build-essential python wget subversion unzip && \
18+
build-essential cmake make python3 zlib1g wget subversion unzip && \
1919
rm -rf /var/lib/apt/lists/*
2020
# Install a newer ninja release. It seems the older version in the debian repos
2121
# randomly crashes when compiling llvm.
@@ -24,19 +24,6 @@ RUN wget "https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-li
2424
| sha256sum -c && \
2525
unzip ninja-linux.zip -d /usr/local/bin && \
2626
rm ninja-linux.zip
27-
# Import public key required for verifying signature of cmake download.
28-
RUN 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)
31-
RUN 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
4027

4128
ADD checksums /tmp/checksums
4229
ADD scripts /tmp/scripts
@@ -50,11 +37,11 @@ RUN /tmp/scripts/build_install_llvm.sh --to /tmp/clang-install ${buildscript_arg
5037

5138

5239
# Stage 2. Produce a minimal release image with build results.
53-
FROM launcher.gcr.io/google/debian8:latest
40+
FROM launcher.gcr.io/google/debian10:latest
5441
LABEL maintainer "LLVM Developers"
5542
# Install packages for minimal useful image.
5643
RUN apt-get update && \
57-
apt-get install -y --no-install-recommends libstdc++-4.9-dev binutils && \
44+
apt-get install -y --no-install-recommends libstdc++-7-dev binutils && \
5845
rm -rf /var/lib/apt/lists/*
5946
# Copy build results of stage 1 to /usr/local.
6047
COPY --from=builder /tmp/clang-install/ /usr/local/

0 commit comments

Comments
 (0)