blob: 1d9618432810e885c347876af1b130d26f1b8ea2 [file] [log] [blame]
Peter Kolbus4225b1a2019-05-31 06:38:06 -05001# Dockerfile
Peter Kolbuse4e2d3a2018-12-24 09:04:54 -06002#
3# Purpose
Peter Kolbus4225b1a2019-05-31 06:38:06 -05004# -------
Peter Kolbuse4e2d3a2018-12-24 09:04:54 -06005# Defines a Docker container suitable to build and run all tests (all.sh),
6# except for those that use a proprietary toolchain.
7
Peter Kolbus4225b1a2019-05-31 06:38:06 -05008# Copyright (C) 2006-2019, Arm Limited (or its affiliates), All Rights Reserved.
9# SPDX-License-Identifier: Apache-2.0
10#
11# Licensed under the Apache License, Version 2.0 (the "License"); you may
12# not use this file except in compliance with the License.
13# You may obtain a copy of the License at
14#
15# http://www.apache.org/licenses/LICENSE-2.0
16#
17# Unless required by applicable law or agreed to in writing, software
18# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
19# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20# See the License for the specific language governing permissions and
21# limitations under the License.
22#
23# This file is part of Mbed TLS (https://tls.mbed.org)
24
Peter Kolbus49c24352019-06-01 08:44:30 -050025FROM ubuntu:bionic
Peter Kolbuse4e2d3a2018-12-24 09:04:54 -060026
27ARG MAKEFLAGS_PARALLEL=""
28
29ENV DEBIAN_FRONTEND noninteractive
30
31RUN apt update \
32 && apt -y install software-properties-common \
33 && rm -rf /var/lib/apt/lists
34
35RUN add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
36
37RUN apt-get update \
38 && apt-get -y install \
39 # mbedtls build/test dependencies
40 build-essential \
41 clang \
42 cmake \
43 doxygen \
44 gcc-arm-none-eabi \
45 gcc-mingw-w64-i686 \
46 gcc-multilib \
47 g++-multilib \
48 gdb \
49 git \
50 graphviz \
51 lsof \
52 python \
53 python3-pip \
54 python3 \
55 pylint3 \
56 valgrind \
57 wget \
58 # libnettle build dependencies
59 libgmp-dev \
60 m4 \
61 pkg-config \
62 && rm -rf /var/lib/apt/lists/*
63
64# Build a static, legacy openssl from sources with sslv3 enabled
65# Based on https://gist.github.com/bmaupin/8caca3a1e8c3c5686141 (build-openssl.sh)
66# Note: openssl-1.0.2 and earlier has known build issues with parallel make.
67RUN cd /tmp \
68 && wget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1j.tar.gz -qO- | tar xz \
69 && cd openssl-1.0.1j \
70 && ./config --openssldir=/usr/local/openssl-1.0.1j no-shared \
71 && (make ${MAKEFLAGS_PARALLEL} || make -j 1) \
72 && make install_sw \
73 && rm -rf /tmp/openssl*
74ENV OPENSSL_LEGACY=/usr/local/openssl-1.0.1j/bin/openssl
75
76# Build OPENSSL as 1.0.2g
77RUN cd /tmp \
78 && wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2g.tar.gz -qO- | tar xz \
79 && cd openssl-1.0.2g \
80 && ./config --openssldir=/usr/local/openssl-1.0.2g no-shared \
81 && (make ${MAKEFLAGS_PARALLEL} || make -j 1) \
82 && make install_sw \
83 && rm -rf /tmp/openssl*
84ENV OPENSSL=/usr/local/openssl-1.0.2g/bin/openssl
85
86# Build a new openssl binary for ARIA/CHACHA20 support
87# Based on https://gist.github.com/bmaupin/8caca3a1e8c3c5686141 (build-openssl.sh)
88RUN cd /tmp \
89 && wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz -qO- | tar xz \
90 && cd openssl-1.1.1a \
91 && ./config --prefix=/usr/local/openssl-1.1.1a -Wl,--enable-new-dtags,-rpath,'${LIBRPATH}' no-shared \
92 && make ${MAKEFLAGS_PARALLEL} \
93 && make install_sw \
94 && rm -rf /tmp/openssl*
95ENV OPENSSL_NEXT=/usr/local/openssl-1.1.1a/bin/openssl
96
97# Build libnettle 2.7.1 (needed by legacy gnutls)
98RUN cd /tmp \
99 && wget https://ftp.gnu.org/gnu/nettle/nettle-2.7.1.tar.gz -qO- | tar xz \
100 && cd nettle-2.7.1 \
101 && ./configure --disable-documentation \
102 && make ${MAKEFLAGS_PARALLEL} \
103 && make install \
104 && /sbin/ldconfig \
105 && rm -rf /tmp/nettle*
106
107# Build legacy gnutls (3.3.8)
108RUN cd /tmp \
109 && wget https://www.gnupg.org/ftp/gcrypt/gnutls/v3.3/gnutls-3.3.8.tar.xz -qO- | tar xJ \
110 && cd gnutls-3.3.8 \
111 && ./configure --prefix=/usr/local/gnutls-3.3.8 --exec_prefix=/usr/local/gnutls-3.3.8 --disable-shared --disable-guile --disable-doc \
112 && make ${MAKEFLAGS_PARALLEL} \
113 && make install \
114 && rm -rf /tmp/gnutls*
115ENV GNUTLS_LEGACY_CLI=/usr/local/gnutls-3.3.8/bin/gnutls-cli
116ENV GNUTLS_LEGACY_SERV=/usr/local/gnutls-3.3.8/bin/gnutls-serv
117
118# Build libnettle 3.1 (needed by gnutls)
119RUN cd /tmp \
120 && wget https://ftp.gnu.org/gnu/nettle/nettle-3.1.tar.gz -qO- | tar xz \
121 && cd nettle-3.1 \
122 && ./configure --disable-documentation \
123 && make ${MAKEFLAGS_PARALLEL} \
124 && make install \
125 && /sbin/ldconfig \
126 && rm -rf /tmp/nettle*
127
128# Build gnutls (3.4.10)
129RUN cd /tmp \
130 && wget https://www.gnupg.org/ftp/gcrypt/gnutls/v3.4/gnutls-3.4.10.tar.xz -qO- | tar xJ \
131 && cd gnutls-3.4.10 \
132 && ./configure --prefix=/usr/local/gnutls-3.4.10 --exec_prefix=/usr/local/gnutls-3.4.10 \
133 --with-included-libtasn1 --without-p11-kit \
134 --disable-shared --disable-guile --disable-doc \
135 && make ${MAKEFLAGS_PARALLEL} \
136 && make install \
137 && rm -rf /tmp/gnutls*
138ENV GNUTLS_CLI=/usr/local/gnutls-3.4.10/bin/gnutls-cli
139ENV GNUTLS_SERV=/usr/local/gnutls-3.4.10/bin/gnutls-serv
140
141# Build libnettle 3.4 (needed by gnutls next)
142RUN cd /tmp \
143 && wget https://ftp.gnu.org/gnu/nettle/nettle-3.4.1.tar.gz -qO- | tar xz \
144 && cd nettle-3.4.1 \
145 && ./configure --disable-documentation \
146 && make ${MAKEFLAGS_PARALLEL} \
147 && make install \
148 && /sbin/ldconfig \
149 && rm -rf /tmp/nettle*
150
151# Build gnutls next (3.6.5)
152RUN cd /tmp \
153 && wget https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/gnutls-3.6.5.tar.xz -qO- | tar xJ \
154 && cd gnutls-3.6.5 \
155 && ./configure --prefix=/usr/local/gnutls-3.6.5 --exec_prefix=/usr/local/gnutls-3.6.5 \
156 --with-included-libtasn1 --with-included-unistring --without-p11-kit \
157 --disable-shared --disable-guile --disable-doc \
158 && make ${MAKEFLAGS_PARALLEL} \
159 && make install \
160 && rm -rf /tmp/gnutls*
161
162ENV GNUTLS_NEXT_CLI=/usr/local/gnutls-3.6.5/bin/gnutls-cli
163ENV GNUTLS_NEXT_SERV=/usr/local/gnutls-3.6.5/bin/gnutls-serv
164
165RUN pip3 install --no-cache-dir \
166 mbed-host-tests \
167 mock