blob: 89c47825c8bd7fd069e55d03295112241efb3f1a [file] [log] [blame]
Leonardo Sandoval80223802021-12-07 13:18:06 -06001# ubuntu-16.04/Dockerfile
2#
3# Copyright (c) 2018-2021, ARM Limited, All Rights Reserved
4# SPDX-License-Identifier: Apache-2.0
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18# This file is part of Mbed TLS (https://www.trustedfirmware.org/projects/mbed-tls/)
19
20# Purpose
21# -------
22#
23# This docker file is for creating the ubuntu-16.04 image that is used in the
24# CI. It can also be used for reproducing and testing CI failures.
25
26FROM ubuntu:16.04
27
28ARG DEBIAN_FRONTEND=noninteractive
29WORKDIR /opt/src
30
31# Support for i386:
32# - for 32-bit builds+tests of Mbed TLS
33# - required to install Arm Compiler 5.06 (armcc)
34RUN dpkg --add-architecture i386
35
36# Main apt-get call with all packages except those that have conflicts,
37# handled below. One big alphabetised list, in order to avoid duplicates, with
38# comments explaining why each package is needed.
39RUN apt-get update -q && apt-get install -yq \
40 # installed from source, but this installs the dependencies
41 abi-dumper \
42 # to build Mbed TLS: gcc, binutils, make, etc.
43 build-essential \
44 # to build Mbed TLS
45 clang \
46 # to build Mbed TLS
47 cmake \
48 # to build Mbed TLS's documentation
49 doxygen \
50 # to cross-build Mbed TLS
51 gcc-mingw-w64-i686 \
52 # to check out Mbed TLS and others
53 git \
54 # to build Mbed TLS's documentation
55 graphviz \
56 # to measure code coverage of Mbed TLS
57 lcov \
58 # for 32-bit Mbed TLS testing and armcc
59 libc6-i386 \
60 # for 32-bit Mbed TLS testing and armcc
61 libc6:i386 \
62 # to build GnuTLS (nettle with public key support aka hogweed)
63 libgmp-dev \
64 # to build GnuTLS >= 3.6 (could also use --with-included-unistring)
65 libunistring-dev \
66 # for armcc
67 libstdc++6:i386 \
68 # to build GnuTLS (except 3.6 which uses --with-included-libtasn1)
69 libtasn1-6-dev \
70 # needed for armcc (see locale-gen below)
71 locales \
72 # used by compat.sh and ssl-opt.sh
73 lsof \
74 # to build GnuTLS (nettle)
75 m4 \
76 # to build Mbed TLS and others
77 make \
78 # to build GnuTLS with locally-compiled nettle
79 pkg-config \
80 # to install the preferred version of pylint
81 python3-pip \
82 # for Mbed TLS tests
83 valgrind \
84 # to download things installed from other places
85 wget \
86 # to build Mbed TLS with MBEDTLS_ZILIB_SUPPORT (removed in 3.0)
87 zlib1g \
88 # to build Mbed TLS with MBEDTLS_ZILIB_SUPPORT (removed in 3.0)
89 zlib1g-dev \
90 && rm -rf /var/lib/apt/lists/
91
92# Install all the parts of gcc-multilib, which is necessary for 32-bit builds.
93# gcc-multilib conflicts with cross-compiler packages that we'll install later,
94# so don't keep it around. Just let it install its dependencies
95# (gcc-<VERSION>-multilib and libc support), then remove it. Manually create
96# one crucial symlink that's otherwise provided by the gcc-multilib package
97# (without that symlink, 32-bit builds won't find system headers). Note that
98# just installing the dependencies of gcc-multilib also brings in gcc-multilib
99# as a Recommends dependency.
100RUN apt-get update -q && apt-get install -yq \
101 gcc-multilib \
102 && rm -rf /var/lib/apt/lists/ && \
103 dpkg -r gcc-multilib && \
104 ln -s x86_64-linux-gnu/asm /usr/include/asm
105
106# Install arm-linux-gnueabi-gcc - to cross-build Mbed TLS
107RUN apt-get update -q && apt-get install -yq \
108 gcc-arm-linux-gnueabi \
109 libc6-dev-armel-cross \
110 && rm -rf /var/lib/apt/lists/
111
112# Install ARM Compiler 5.06
113RUN wget -q https://developer.arm.com/-/media/Files/downloads/compiler/DS500-PA-00003-r5p0-22rel0.tgz && \
114 tar -zxf DS500-PA-00003-r5p0-22rel0.tgz && \
115 ./Installer/setup.sh --i-agree-to-the-contained-eula --no-interactive -d /usr/local/ARM_Compiler_5.06u3 --quiet && \
116 rm -rf DS500-PA-00003-r5p0-22rel0.tgz releasenotes.html Installer/
117
118ENV ARMC5_BIN_DIR=/usr/local/ARM_Compiler_5.06u3/bin/
119ENV PATH=$PATH:/usr/local/ARM_Compiler_5.06u3/bin
120ENV ARMLMD_LICENSE_FILE=27000@flexnet.trustedfirmware.org
121
122# Install ARM Compiler 6.6
123RUN mkdir temp && cd temp && \
124 wget -q --no-check-certificate https://developer.arm.com/-/media/Files/downloads/compiler/DS500-BN-00026-r5p0-07rel0.tgz?revision=8f0d9fb0-9616-458c-b2f5-d0dac83ea93c?product=Downloads,64-bit,,Linux,6.6 -O arm6.tgz && \
125 tar -zxf arm6.tgz && ls -ltr && \
126 ./install_x86_64.sh --i-agree-to-the-contained-eula --no-interactive -d /usr/local/ARM_Compiler_6.6 --quiet && \
127 cd .. && rm -rf temp/
128
129ENV ARMC6_BIN_DIR=/usr/local/ARM_Compiler_6.6/bin/
130
131# Install arm-none-eabi-gcc
132RUN wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/5_4-2016q3/gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 -O gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 && \
133 tar -xjf gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 -C /opt && \
134 rm gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2
135
136ENV PATH=/opt/gcc-arm-none-eabi-5_4-2016q3/bin:$PATH
137
138# Install exact upstream versions of OpenSSL and GnuTLS
139#
140# Distro packages tend to include patches that disrupt our testing scripts,
141# and such patches may be added at any time. Avoid surprises by using fixed
142# versions.
143#
144# GnuTLS has a number of (optional) dependencies:
145# - nettle (crypto library): quite tighly coupled, so build one for each
146# version of GnuTLS that we want.
147# - libtasn1: can use the Ubuntu version, except for GnuTLS 3.7 which needs
148# libtasn1 4.9 (Ubuntu 16.04 has 4.6); an config option
149# --with-included-libtasn1 is available, so use it for GnuTLS 3.7.
150# - p11-kit: optional, for smart-card support - configure it out
151# - libunistring: since 3.6 - the Ubuntu package works; if it didn't a config
152# option --with-included-libunistring is available.
153
154# Install openssl 1.0.2g - main version, in the PATH
155RUN wget -q https://www.openssl.org/source/old/1.0.2/openssl-1.0.2g.tar.gz && \
156 tar -zxf openssl-1.0.2g.tar.gz && cd openssl-1.0.2g && \
157 ./config --openssldir=/usr/local/openssl-1.0.2g enable-ssl-trace && \
158 make clean && make && make install && cd .. && \
159 rm -rf openssl-1.0.2g*
160
161ENV OPENSSL=/usr/local/openssl-1.0.2g/bin/openssl
162ENV PATH=/usr/local/openssl-1.0.2g/bin:$PATH
163
164# Install openssl 1.0.1j - "legacy" version
165RUN wget -q https://www.openssl.org/source/old/1.0.1/openssl-1.0.1j.tar.gz && \
166 tar -zxf openssl-1.0.1j.tar.gz && cd openssl-1.0.1j && \
167 ./config --openssldir=/usr/local/openssl-1.0.1j && \
168 make clean && make && make install && cd .. && \
169 rm -rf openssl-1.0.1j*
170
171ENV OPENSSL_LEGACY=/usr/local/openssl-1.0.1j/bin/openssl
172
173# Install openssl 1.1.1a - "next" version
174RUN wget -q https://www.openssl.org/source/openssl-1.1.1a.tar.gz && \
175 tar -zxf openssl-1.1.1a.tar.gz && cd openssl-1.1.1a && \
176 ./config --prefix=/usr/local/openssl-1.1.1a -Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)' enable-ssl-trace && \
177 make clean && make && make install && cd .. && \
178 rm -rf openssl-1.1.1a*
179
180ENV OPENSSL_NEXT=/usr/local/openssl-1.1.1a/bin/openssl
181
182# Install Gnu TLS 3.4.10 (nettle 3.1) - main version, in the PATH
183RUN wget -q https://ftp.gnu.org/gnu/nettle/nettle-3.1.tar.gz && \
184 tar -zxf nettle-3.1.tar.gz && cd nettle-3.1 && \
185 ./configure --prefix=/usr/local/libnettle-3.1 --exec_prefix=/usr/local/libnettle-3.1 --disable-shared --disable-openssl && \
186 make && make install && cd .. && rm -rf nettle-3.1* && \
187 export PKG_CONFIG_PATH=/usr/local/libnettle-3.1/lib/pkgconfig:/usr/local/libnettle-3.1/lib64/pkgconfig:/usr/local/lib/pkgconfig && \
188 wget -q https://www.gnupg.org/ftp/gcrypt/gnutls/v3.4/gnutls-3.4.10.tar.xz && \
189 tar -xJf gnutls-3.4.10.tar.xz && cd gnutls-3.4.10 && \
190 ./configure --prefix=/usr/local/gnutls-3.4.10 --exec_prefix=/usr/local/gnutls-3.4.10 --disable-shared --without-p11-kit && \
191 make && make install && cat config.log && cd .. && \
192 rm -rf gnutls-3.4.10*
193
194ENV GNUTLS_CLI=/usr/local/gnutls-3.4.10/bin/gnutls-cli
195ENV GNUTLS_SERV=/usr/local/gnutls-3.4.10/bin/gnutls-serv
196ENV PATH=/usr/local/gnutls-3.4.10/bin:$PATH
197
198# Install Gnu TLS 3.3.8 (nettle 2.7) - "legacy" version
199RUN wget -q https://ftp.gnu.org/gnu/nettle/nettle-2.7.1.tar.gz && \
200 tar -zxf nettle-2.7.1.tar.gz && cd nettle-2.7.1 && \
201 ./configure --prefix=/usr/local/libnettle-2.7.1 --exec_prefix=/usr/local/libnettle-2.7.1 --disable-shared --disable-openssl && \
202 make && make install && cd .. && rm -rf nettle-2.7.1* && \
203 export PKG_CONFIG_PATH=/usr/local/libnettle-2.7.1/lib/pkgconfig:/usr/local/libnettle-2.7.1/lib64/pkgconfig:/usr/local/lib/pkgconfig && \
204 wget -q https://www.gnupg.org/ftp/gcrypt/gnutls/v3.3/gnutls-3.3.8.tar.xz && \
205 tar -xJf gnutls-3.3.8.tar.xz && cd gnutls-3.3.8 && \
206 ./configure --prefix=/usr/local/gnutls-3.3.8 --exec_prefix=/usr/local/gnutls-3.3.8 --disable-shared --without-p11-kit && \
207 make && make install && cat config.log && cd .. && \
208 rm -rf gnutls-3.3.8*
209
210ENV GNUTLS_LEGACY_CLI=/usr/local/gnutls-3.3.8/bin/gnutls-cli
211ENV GNUTLS_LEGACY_SERV=/usr/local/gnutls-3.3.8/bin/gnutls-serv
212
213# Instal GNU TLS 3.7.2 (nettle 3.7) - "next" version
214RUN wget -q https://ftp.gnu.org/gnu/nettle/nettle-3.7.3.tar.gz && \
215 tar -zxf nettle-3.7.3.tar.gz && cd nettle-3.7.3 && \
216 ./configure --prefix=/usr/local/libnettle-3.7.3 --exec_prefix=/usr/local/libnettle-3.7.3 --disable-shared --disable-openssl && \
217 make && make install && cd .. && rm -rf nettle-3.7.3* && \
218 export PKG_CONFIG_PATH=/usr/local/libnettle-3.7.3/lib/pkgconfig:/usr/local/libnettle-3.7.3/lib64/pkgconfig:/usr/local/lib/pkgconfig && \
219 wget -q https://www.gnupg.org/ftp/gcrypt/gnutls/v3.7/gnutls-3.7.2.tar.xz && \
220 tar -xJf gnutls-3.7.2.tar.xz && cd gnutls-3.7.2 && \
221 ./configure --prefix=/usr/local/gnutls-3.7.2 --exec_prefix=/usr/local/gnutls-3.7.2 --disable-shared --with-included-libtasn1 --without-p11-kit && \
222 make && make install && cat config.log && cd .. && \
223 rm -rf gnutls-3.7.2*
224
225ENV GNUTLS_NEXT_CLI=/usr/local/gnutls-3.7.2/bin/gnutls-cli
226ENV GNUTLS_NEXT_SERV=/usr/local/gnutls-3.7.2/bin/gnutls-serv
227
228# Install abi-compliance-checker
229# The version in Ubuntu 16.04 is too old, we want at least the version below
230RUN wget -q https://github.com/lvc/abi-compliance-checker/archive/2.3.tar.gz && \
231 tar -zxf 2.3.tar.gz && cd abi-compliance-checker-2.3 && \
232 make clean && make && make install prefix=/usr && cd .. && \
233 rm -rf abi-compliance-checker* && rm 2.3.tar.gz
234
235# Install abi-dumper
236# The version in Ubuntu 16.04 is too old, we want at least the version below
237RUN git clone --branch 1.1 https://github.com/lvc/abi-dumper.git && \
238 cd abi-dumper && make install prefix=/usr && cd .. && rm -rf abi-dumper
239
240# Install Python pip packages
241#
242# The pip wrapper scripts can get out of sync with pip due to upgrading it
243# outside the package manager, so invoke the module directly.
244#
245# Ubuntu 16.04's pip (8.1) doesn't understand the Requires-Python
246# directive (introduced in pip 9.0), and tries to install the wrong versions
247# of pip and setuptools. Version 21 of pip drops support for Python 3.5 (the
248# latest in 16.04), so pick an earlier version.
249#
250# Piping to cat suppresses the progress bar, but means that a failure
251# won't be caught (`stuff | cat` succeeds if cat succeeds, even if `stuff`
252# fails). The subsequent use of "pip config" (which requires pip >=10)
253# will however fail if the installation of a more recent pip failed.
254RUN python3 -m pip install 'pip<21' --upgrade | cat && \
255 python3 -m pip config set global.progress_bar off && \
256 python3 -m pip install setuptools --upgrade && \
257 # For pylint we want a known version, as later versions may add checks at
258 # any time, making CI results unpredictable.
259 python3 -m pip install pylint==2.4.4 && \
260 # For mypy, use the earliest version that works with our code base.
261 # See https://github.com/ARMmbed/mbedtls/pull/3953 .
262 python3 -m pip install mypy==0.780 && \
263 # For jinja2, use the version that's in Ubuntu 20.04.
264 # See https://github.com/ARMmbed/mbedtls/pull/5067#discussion_r738794607 .
265 # Note that Jinja2 3.0 drops support for Python 3.5, so we need 2.x.
266 python3 -m pip install Jinja2==2.10.1 types-Jinja2 && \
267 true
268
269# Set locale for ARMCC to work
270RUN locale && \
271 locale-gen "en_US.UTF-8" && \
272 dpkg-reconfigure locales
273
274# Add user
275RUN useradd -m user
276
277# Create workspace
278ARG AGENT_WORKDIR=/var/lib/builds
279RUN mkdir -p ${AGENT_WORKDIR} && chown user:user ${AGENT_WORKDIR}
280USER user
281ENV AGENT_WORKDIR=${AGENT_WORKDIR}
282
283WORKDIR ${AGENT_WORKDIR}
284
285ENTRYPOINT ["bash"]